zig/test/behavior/hasdecl.zig
Robin Voetter b9d738a5cf
spirv: disable tests that fail on pocl
Besides the Intel OpenCL CPU runtime, we can now run the
behavior tests using the Portable Computing Language. This
implementation is open-source, so it will be easier for us
to patch in updated versions of spirv-llvm-translator that
have bug fixes etc.
2024-06-10 20:32:34 +02:00

38 lines
1.2 KiB
Zig

const std = @import("std");
const builtin = @import("builtin");
const expect = std.testing.expect;
const Foo = @import("hasdecl/foo.zig");
const Bar = struct {
nope: i32,
const hi = 1;
pub var blah = "xxx";
};
test "@hasDecl" {
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
try expect(@hasDecl(Foo, "public_thing"));
try expect(!@hasDecl(Foo, "private_thing"));
try expect(!@hasDecl(Foo, "no_thing"));
try expect(@hasDecl(Bar, "hi"));
try expect(@hasDecl(Bar, "blah"));
try expect(!@hasDecl(Bar, "nope"));
}
test "@hasDecl using a sliced string literal" {
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
try expect(@hasDecl(@This(), "std") == true);
try expect(@hasDecl(@This(), "std"[0..0]) == false);
try expect(@hasDecl(@This(), "std"[0..1]) == false);
try expect(@hasDecl(@This(), "std"[0..2]) == false);
try expect(@hasDecl(@This(), "std"[0..3]) == true);
try expect(@hasDecl(@This(), "std"[0..]) == true);
}