mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 19:00:52 +08:00
23 lines
446 B
Zig
23 lines
446 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const Foo = struct {
|
|
nope: i32,
|
|
|
|
pub var blah = "xxx";
|
|
const hi = 1;
|
|
};
|
|
|
|
test "@hasDecl" {
|
|
try expect(@hasDecl(Foo, "blah"));
|
|
|
|
// @hasDecl returns false for private declarations.
|
|
try expect(!@hasDecl(Foo, "hi"));
|
|
|
|
// @hasDecl is for declarations; not fields.
|
|
try expect(!@hasDecl(Foo, "nope"));
|
|
try expect(!@hasDecl(Foo, "nope1234"));
|
|
}
|
|
|
|
// test
|