commit dc2df155285576b8da621fbffac451c036af0ed0 (tree) parent 11d8a8cc7b6984f2c79923a5e3f763003f2b558f Author: Andrew Kelley <superjoe30@gmail.com> Date: Sun, 7 May 2017 13:26:41 -0400 add test case for all prongs unreachable in switch See #43 Diffstat:
| M | test/cases/switch.zig | | | 20 | ++++++++++++++++++++ |
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/test/cases/switch.zig b/test/cases/switch.zig @@ -205,3 +205,23 @@ fn testSwitchHandleAllCasesRange(x: u8) -> u8 { } } +test "switch all prongs unreachable" { + testAllProngsUnreachable(); + comptime testAllProngsUnreachable(); +} + +fn testAllProngsUnreachable() { + assert(switchWithUnreachable(1) == 2); + assert(switchWithUnreachable(2) == 10); +} + +fn switchWithUnreachable(x: i32) -> i32 { + while (true) { + switch (x) { + 1 => return 2, + 2 => break, + else => continue, + } + } + return 10; +}