1const std = @import("std");
2const expect = std.testing.expect;
3
4const Foo = struct {
5 nope: i32,
6
7 pub var blah = "xxx";
8 const hi = 1;
9};
10
11test "@hasDecl" {
12 try expect(@hasDecl(Foo, "blah"));
13
14 // @hasDecl returns false for private declarations.
15 try expect(!@hasDecl(Foo, "hi"));
16
17 // @hasDecl is for declarations; not fields.
18 try expect(!@hasDecl(Foo, "nope"));
19 try expect(!@hasDecl(Foo, "nope1234"));
20}
21
22// test