From acf12b7891e01fa97d7f724fe8e478fa38aa02bd Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 6 Sep 2024 16:08:33 +0200 Subject: [PATCH] Fix the Program constructor checks. --- lib/program.jl | 4 ++-- test/program.jl | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/program.jl b/lib/program.jl index d4368bd..fd879e3 100644 --- a/lib/program.jl +++ b/lib/program.jl @@ -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)] diff --git a/test/program.jl b/test/program.jl index e70fd02..975392b 100644 --- a/test/program.jl +++ b/test/program.jl @@ -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,