diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-05-07 13:26:41 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-05-07 13:26:41 -0400 |
| commit | dc2df155285576b8da621fbffac451c036af0ed0 (patch) | |
| tree | 09524943dca48308239710a792645afdccaf2259 /test | |
| parent | 11d8a8cc7b6984f2c79923a5e3f763003f2b558f (diff) | |
| download | zig-dc2df155285576b8da621fbffac451c036af0ed0.tar.gz zig-dc2df155285576b8da621fbffac451c036af0ed0.zip | |
add test case for all prongs unreachable in switch
See #43
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/switch.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/cases/switch.zig b/test/cases/switch.zig index dfec42ea87..0559fc0064 100644 --- 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; +} |
