Skip to content

Commit

Permalink
Fix the Program constructor checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Sep 6, 2024
1 parent 4914b30 commit acf12b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/program.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Base.pointer(p::Program) = p.id
Base.getindex(p::Program, pinfo::Symbol) = info(p, pinfo)

function Program(ctx::Context; source=nothing, binaries=nothing, il=nothing)
if source !== nothing && binaries !== nothing && il !== nothing
throw(ArgumentError("Program be source, binary, or intermediate language"))
if count(!isnothing, (source, binaries, il)) != 1
throw(ArgumentError("Program must be source, binary, or intermediate language"))
end
if source !== nothing
byte_source = [String(source)]
Expand Down
5 changes: 5 additions & 0 deletions test/program.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
@testset "Program" begin
let ctx = cl.Context(device)
@test_throws ArgumentError cl.Program(ctx)
@test_throws ArgumentError cl.Program(ctx; source="", il="")
end

test_source = "
__kernel void sum(__global const float *a,
__global const float *b,
Expand Down

0 comments on commit acf12b7

Please sign in to comment.