authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-07 13:26:41-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-07 13:26:41-04:00
logdc2df155285576b8da621fbffac451c036af0ed0
tree09524943dca48308239710a792645afdccaf2259
parent11d8a8cc7b6984f2c79923a5e3f763003f2b558f

add test case for all prongs unreachable in switch

See #43

1 files changed, 20 insertions(+), 0 deletions(-)

test/cases/switch.zig+20
...@@ -205,3 +205,23 @@ fn testSwitchHandleAllCasesRange(x: u8) -> u8 {...@@ -205,3 +205,23 @@ fn testSwitchHandleAllCasesRange(x: u8) -> u8 {
205 }205 }
206}206}
207207
208test "switch all prongs unreachable" {
209 testAllProngsUnreachable();
210 comptime testAllProngsUnreachable();
211}
212
213fn testAllProngsUnreachable() {
214 assert(switchWithUnreachable(1) == 2);
215 assert(switchWithUnreachable(2) == 10);
216}
217
218fn switchWithUnreachable(x: i32) -> i32 {
219 while (true) {
220 switch (x) {
221 1 => return 2,
222 2 => break,
223 else => continue,
224 }
225 }
226 return 10;
227}