aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-02-11 16:15:08 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-02-11 16:15:08 -0700
commit08eb19456b319cc5b0c287773d52850f12f2bcb5 (patch)
tree99188572c1ba6c53b9cc8fbd92bb007f3f85cfb6 /test/run_tests.cpp
parenta180168871b6e32a8c0825b1eb309587c3e0d179 (diff)
downloadzig-08eb19456b319cc5b0c287773d52850f12f2bcb5.tar.gz
zig-08eb19456b319cc5b0c287773d52850f12f2bcb5.zip
add compile error for missing enumeration value in switch
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 3338134196..b372473eec 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1760,6 +1760,23 @@ const float_x = f32(1.0) / f32(0.0);
".tmp_source.zig:3:25: error: division by zero is undefined",
".tmp_source.zig:4:22: error: division by zero is undefined",
".tmp_source.zig:5:26: error: division by zero is undefined");
+
+
+ add_compile_fail_case("missing switch prong", R"SOURCE(
+enum Number {
+ One,
+ Two,
+ Three,
+ Four,
+}
+fn f(n: Number) -> i32 {
+ switch (n) {
+ One => 1,
+ Two => 2,
+ Three => 3,
+ }
+}
+ )SOURCE", 1, ".tmp_source.zig:9:5: error: enumeration value 'Four' not handled in switch");
}
//////////////////////////////////////////////////////////////////////////////