zig/test/cases/switch_prong_implicit_cast.zig
Andrew Kelley af536ac343 introduce new test syntax
* remove setFnTest builtin
 * add test "name" { ... } syntax
 * remove --check-unused argument. functions are always lazy now.
2017-03-16 16:02:35 -04:00

25 lines
443 B
Zig

const assert = @import("std").debug.assert;
const FormValue = enum {
One,
Two: bool,
};
error Whatever;
fn foo(id: u64) -> %FormValue {
switch (id) {
2 => FormValue.Two { true },
1 => FormValue.One,
else => return error.Whatever,
}
}
test "switchProngImplicitCast" {
const result = switch (%%foo(2)) {
FormValue.One => false,
FormValue.Two => |x| x,
};
assert(result);
}