2019-05-26 21:21:03 +01:00
|
|
|
const std = @import("std");
|
|
|
|
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" {
|
2021-05-04 19:23:22 +01:00
|
|
|
try expect(@hasDecl(Foo, "public_thing"));
|
|
|
|
try expect(!@hasDecl(Foo, "private_thing"));
|
|
|
|
try expect(!@hasDecl(Foo, "no_thing"));
|
2019-05-26 21:21:03 +01:00
|
|
|
|
2021-05-04 19:23:22 +01:00
|
|
|
try expect(@hasDecl(Bar, "hi"));
|
|
|
|
try expect(@hasDecl(Bar, "blah"));
|
|
|
|
try expect(!@hasDecl(Bar, "nope"));
|
2019-05-26 21:21:03 +01:00
|
|
|
}
|