aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/4-statements
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-15 18:29:55 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-15 18:29:55 +0330
commite7fe081efaae893ed46548fdbc3bfa39b2879878 (patch)
treead2e3804bcbc6493d7152f68e91f17d4b357c73e /tests/conformance/4-statements
parentconstant expressions: c precedence and / % ^ (b.1.3); local const usable in c... (diff)
duplicate case labels are an error (b.2.15); unterminated string literal reported where it starts (b.2.11); an unreachable droppable cycle drops whole in one collection (6.15.3)
Diffstat (limited to 'tests/conformance/4-statements')
-rw-r--r--tests/conformance/4-statements/switch_duplicate_label_rejected.zc6
-rw-r--r--tests/conformance/4-statements/switch_duplicate_labels_first_wins.zc11
-rw-r--r--tests/conformance/4-statements/switch_same_label_other_switch.zc5
3 files changed, 11 insertions, 11 deletions
diff --git a/tests/conformance/4-statements/switch_duplicate_label_rejected.zc b/tests/conformance/4-statements/switch_duplicate_label_rejected.zc
new file mode 100644
index 0000000..54f3b56
--- /dev/null
+++ b/tests/conformance/4-statements/switch_duplicate_label_rejected.zc
@@ -0,0 +1,6 @@
+// expect error: duplicate case label
+// spec 4.7.2: a label seen twice in one switch is an error
+include rt;
+enum color { RED, GREEN };
+fn main() { int k = 1; switch (k) { case RED, GREEN: k = 2; case 2 - 1: k = 3; } return 0; }
+// zc0: skip
diff --git a/tests/conformance/4-statements/switch_duplicate_labels_first_wins.zc b/tests/conformance/4-statements/switch_duplicate_labels_first_wins.zc
deleted file mode 100644
index 67a0204..0000000
--- a/tests/conformance/4-statements/switch_duplicate_labels_first_wins.zc
+++ /dev/null
@@ -1,11 +0,0 @@
-// expect: first/
-// spec 4.7.2: duplicate labels are not an error, the first matching case in source order runs
-include rt;
-void pn(int x) { rt.put_n(x); rt.put_c(10); }
-void ps(char* s) { rt.put_s(s); rt.put_c(10); }
-fn main() {
- int k = 4;
- switch (k) { case 4: ps("first"); case 4: ps("second"); }
- return 0;
-}
-// zc0: skip
diff --git a/tests/conformance/4-statements/switch_same_label_other_switch.zc b/tests/conformance/4-statements/switch_same_label_other_switch.zc
new file mode 100644
index 0000000..bb52a94
--- /dev/null
+++ b/tests/conformance/4-statements/switch_same_label_other_switch.zc
@@ -0,0 +1,5 @@
+// expect: 2/
+// spec 4.7.2: equal labels in two different switches are fine
+include rt;
+fn main() { int k = 1; switch (k) { case 1: k = 2; } switch (k) { case 1: k = 9; case 2: rt.put_n(k); } rt.put_c(10); return 0; }
+// zc0: skip