add test case for all prongs unreachable in switch

See #43
master
Andrew Kelley 2017-05-07 13:26:41 -04:00
parent 11d8a8cc7b
commit dc2df15528
1 changed files with 20 additions and 0 deletions

View File

@ -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;
}