zig/test/cases/switch_prong_err_enum.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

28 lines
494 B
Zig

const assert = @import("std").debug.assert;
var read_count: u64 = 0;
fn readOnce() -> %u64 {
read_count += 1;
return read_count;
}
error InvalidDebugInfo;
const FormValue = enum {
Address: u64,
Other: bool,
};
fn doThing(form_id: u64) -> %FormValue {
return switch (form_id) {
17 => FormValue.Address { %return readOnce() },
else => error.InvalidDebugInfo,
}
}
test "switchProngReturnsErrorEnum" {
%%doThing(17);
assert(read_count == 1);
}