Commit dc2df15528

Andrew Kelley <superjoe30@gmail.com>
2017-05-07 19:26:41
add test case for all prongs unreachable in switch
See #43
1 parent 11d8a8c
Changed files (1)
test
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;
+}