aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/9-appendix-b
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 15:49:27 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 15:49:27 +0330
commit0ff8e8ee280e46f9f0ff06bf0958e91ff29da52e (patch)
treef0d8b760771ca31c9e15796c06ead330299ab8e6 /tests/conformance/9-appendix-b
parentagent/spec-conformance: unmerged work from previous session (diff)
conformance: port the previous agent's suite, fix six expectations, add sections 5 to 8 and appendix b, known.txt, zc0 skips, wire into test.sh
Diffstat (limited to 'tests/conformance/9-appendix-b')
-rw-r--r--tests/conformance/9-appendix-b/b1_11_zc0_octal.zc5
-rw-r--r--tests/conformance/9-appendix-b/b1_11_zc0_saturation.zc5
-rw-r--r--tests/conformance/9-appendix-b/b2_05_ternary_int_float.zc7
-rw-r--r--tests/conformance/9-appendix-b/b2_06_bool_normalises.zc6
-rw-r--r--tests/conformance/9-appendix-b/b2_10_recovery_hides_errors.zc6
-rw-r--r--tests/conformance/9-appendix-b/b2_11_unterminated_comment.zc7
-rw-r--r--tests/conformance/9-appendix-b/b2_12_as_int_star.zc6
-rw-r--r--tests/conformance/9-appendix-b/b2_14_len_char_ptr_typecheck_off.zc7
-rw-r--r--tests/conformance/9-appendix-b/b2_15_duplicate_case.zc6
-rw-r--r--tests/conformance/9-appendix-b/b2_16_local_const_in_const_expr.zc6
10 files changed, 61 insertions, 0 deletions
diff --git a/tests/conformance/9-appendix-b/b1_11_zc0_octal.zc b/tests/conformance/9-appendix-b/b1_11_zc0_octal.zc
new file mode 100644
index 0000000..747476d
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b1_11_zc0_octal.zc
@@ -0,0 +1,5 @@
+// expect: 10/
+// spec appendix b.1.11: 010 is 10 (the compiler); zc0 reads 8
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { pn(010); return 0; }
diff --git a/tests/conformance/9-appendix-b/b1_11_zc0_saturation.zc b/tests/conformance/9-appendix-b/b1_11_zc0_saturation.zc
new file mode 100644
index 0000000..859761b
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b1_11_zc0_saturation.zc
@@ -0,0 +1,5 @@
+// expect: -1/
+// spec appendix b.1.11: 0xFFFFFFFFFFFFFFFF wraps to -1; zc0 saturates
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { pn(0xFFFFFFFFFFFFFFFF); return 0; }
diff --git a/tests/conformance/9-appendix-b/b2_05_ternary_int_float.zc b/tests/conformance/9-appendix-b/b2_05_ternary_int_float.zc
new file mode 100644
index 0000000..60dd829
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_05_ternary_int_float.zc
@@ -0,0 +1,7 @@
+// expect: 1.000000/2.500000/1.000000/2.500000/
+// spec appendix b.2.5: ?: with one int and one float branch
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn pf(float f) { asm { f @ #1220 } rt.put_c(10); return 0; }
+fn main() { pf(1 ? 1 : 2.5); pf(1 ? 2.5 : 1); pf(0 ? 2.5 : 1); pf(0 ? 1 : 2.5); return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_06_bool_normalises.zc b/tests/conformance/9-appendix-b/b2_06_bool_normalises.zc
new file mode 100644
index 0000000..7fe226c
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_06_bool_normalises.zc
@@ -0,0 +1,6 @@
+// expect: 1/1/0/
+// spec appendix b.2.6: bool as a 0/1 type
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { bool b = 5; pn(b); pn(b == 1); pn(!b); return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_10_recovery_hides_errors.zc b/tests/conformance/9-appendix-b/b2_10_recovery_hides_errors.zc
new file mode 100644
index 0000000..d770fcd
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_10_recovery_hides_errors.zc
@@ -0,0 +1,6 @@
+// expect error: zc: 2 errors
+// spec appendix b.2.10 and 8.2: by design only the first error is reported
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { int a = ; int b = 3 +; return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_11_unterminated_comment.zc b/tests/conformance/9-appendix-b/b2_11_unterminated_comment.zc
new file mode 100644
index 0000000..e6e6bbf
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_11_unterminated_comment.zc
@@ -0,0 +1,7 @@
+// expect error: unterminated
+// spec appendix b.2.11: an unterminated /* is accepted silently
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { pn(1); return 0; }
+/* never closed
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_12_as_int_star.zc b/tests/conformance/9-appendix-b/b2_12_as_int_star.zc
new file mode 100644
index 0000000..fc12792
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_12_as_int_star.zc
@@ -0,0 +1,6 @@
+// expect: 6/
+// spec appendix b.2.12: x as int * y should multiply
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { int x = 2; int y = 3; pn(x as int * y); return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_14_len_char_ptr_typecheck_off.zc b/tests/conformance/9-appendix-b/b2_14_len_char_ptr_typecheck_off.zc
new file mode 100644
index 0000000..b0d0d45
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_14_len_char_ptr_typecheck_off.zc
@@ -0,0 +1,7 @@
+// expect: 3/
+// spec appendix b.2.14: len(char*) with typecheck off returns word 0
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+typecheck off;
+fn main() { char* s = "abc"; pn(len(s)); return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_15_duplicate_case.zc b/tests/conformance/9-appendix-b/b2_15_duplicate_case.zc
new file mode 100644
index 0000000..63c30ec
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_15_duplicate_case.zc
@@ -0,0 +1,6 @@
+// expect error: duplicate
+// spec appendix b.2.15: duplicate case labels are not diagnosed (4.7.2 says they are allowed)
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { int k = 1; switch (k) { case 1: pn(1); case 1: pn(2); } return 0; }
+// zc0: skip
diff --git a/tests/conformance/9-appendix-b/b2_16_local_const_in_const_expr.zc b/tests/conformance/9-appendix-b/b2_16_local_const_in_const_expr.zc
new file mode 100644
index 0000000..70093c9
--- /dev/null
+++ b/tests/conformance/9-appendix-b/b2_16_local_const_in_const_expr.zc
@@ -0,0 +1,6 @@
+// expect: 5/
+// spec appendix b.2.16 and 3.14.2: a local const is not a constant expression
+include rt;
+void pn(int x) { rt.put_n(x); rt.put_c(10); }
+fn main() { const n = 5; int[n] a; pn(5); return 0; }
+// zc0: skip