aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/hasdecl.zig
blob: 381e79760c1f99998265e9f4591475916e941970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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" {
    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"));
}