zig/test/cases/switch_prong_implicit_cast.zig
2017-01-05 03:57:48 -05:00

27 lines
464 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,
}
}
fn switchProngImplicitCast() {
@setFnTest(this);
const result = switch (%%foo(2)) {
FormValue.One => false,
FormValue.Two => |x| x,
};
assert(result);
}