zig/test/behavior/hasfield.zig
Meghan Denny 0ef2e2520a stage2: implement @hasField
struct and union are kept in stage1 because struct/unionFieldCount are returning zero
2021-10-17 21:42:22 -07:00

16 lines
381 B
Zig

const expect = @import("std").testing.expect;
const builtin = @import("builtin");
test "@hasField" {
const enm = enum {
a,
b,
pub const nope = 1;
};
try expect(@hasField(enm, "a") == true);
try expect(@hasField(enm, "b") == true);
try expect(@hasField(enm, "non-existant") == false);
try expect(@hasField(enm, "nope") == false);
}