From 0ff8e8ee280e46f9f0ff06bf0958e91ff29da52e Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 15:49:27 +0330 Subject: 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 --- tests/conformance/7-compile-time/binop_pow.zc | 10 ++++++++++ tests/conformance/7-compile-time/evals_prints.zc | 7 +++++++ tests/conformance/7-compile-time/evals_returns.zc | 7 +++++++ tests/conformance/7-compile-time/parse_word_five.zc | 8 ++++++++ tests/conformance/7-compile-time/parse_word_reads_nothing.zc | 8 ++++++++ tests/conformance/7-compile-time/quote_count.zc | 7 +++++++ tests/conformance/7-compile-time/run_requires_include.zc | 6 ++++++ tests/conformance/7-compile-time/statement_hook_ticks.zc | 10 ++++++++++ tests/conformance/7-compile-time/syntax_hi.zc | 10 ++++++++++ 9 files changed, 73 insertions(+) create mode 100644 tests/conformance/7-compile-time/binop_pow.zc create mode 100644 tests/conformance/7-compile-time/evals_prints.zc create mode 100644 tests/conformance/7-compile-time/evals_returns.zc create mode 100644 tests/conformance/7-compile-time/parse_word_five.zc create mode 100644 tests/conformance/7-compile-time/parse_word_reads_nothing.zc create mode 100644 tests/conformance/7-compile-time/quote_count.zc create mode 100644 tests/conformance/7-compile-time/run_requires_include.zc create mode 100644 tests/conformance/7-compile-time/statement_hook_ticks.zc create mode 100644 tests/conformance/7-compile-time/syntax_hi.zc (limited to 'tests/conformance/7-compile-time') diff --git a/tests/conformance/7-compile-time/binop_pow.zc b/tests/conformance/7-compile-time/binop_pow.zc new file mode 100644 index 0000000..ea26fb2 --- /dev/null +++ b/tests/conformance/7-compile-time/binop_pow.zc @@ -0,0 +1,10 @@ +// expect: 1024/18/ +// spec 7.5 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +int ipow(int a, int b) { int r = 1; while (b > 0) { r = r * a; b--; } return r; } +immediate fn pow_op() { run.next(); run.add_binop("**", 11, "ipow c"); return 0; } +pow_op +fn main() { pn(2 ** 10); pn(2 * 3 ** 2); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/evals_prints.zc b/tests/conformance/7-compile-time/evals_prints.zc new file mode 100644 index 0000000..66e236d --- /dev/null +++ b/tests/conformance/7-compile-time/evals_prints.zc @@ -0,0 +1,7 @@ +// expect: 42/ +// spec 7.3 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +fn main() { run.evals("rt.put_n(40 + 2); rt.put_c(10); return 7;"); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/evals_returns.zc b/tests/conformance/7-compile-time/evals_returns.zc new file mode 100644 index 0000000..3655612 --- /dev/null +++ b/tests/conformance/7-compile-time/evals_returns.zc @@ -0,0 +1,7 @@ +// expect: 42/ +// spec 7.3 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +fn main() { pn(run.evals("return 6 * 7;")); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/parse_word_five.zc b/tests/conformance/7-compile-time/parse_word_five.zc new file mode 100644 index 0000000..b4da5d9 --- /dev/null +++ b/tests/conformance/7-compile-time/parse_word_five.zc @@ -0,0 +1,8 @@ +// expect: 6/ +// spec 7.2 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +immediate fn five() { run.next(); run.lit(5); return 0; } +fn main() { int x = five + 1; pn(x); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/parse_word_reads_nothing.zc b/tests/conformance/7-compile-time/parse_word_reads_nothing.zc new file mode 100644 index 0000000..e0f7cc1 --- /dev/null +++ b/tests/conformance/7-compile-time/parse_word_reads_nothing.zc @@ -0,0 +1,8 @@ +// expect error: a parse word has to read its own name with next() +// spec 7.2 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +immediate fn bad() { run.lit(5); return 0; } +fn main() { int x = bad; return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/quote_count.zc b/tests/conformance/7-compile-time/quote_count.zc new file mode 100644 index 0000000..a6369a8 --- /dev/null +++ b/tests/conformance/7-compile-time/quote_count.zc @@ -0,0 +1,7 @@ +// expect: 3/ +// spec 7.4 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +fn main() { int* q = quote { a + b }; pn(q[0]); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/run_requires_include.zc b/tests/conformance/7-compile-time/run_requires_include.zc new file mode 100644 index 0000000..16c6101 --- /dev/null +++ b/tests/conformance/7-compile-time/run_requires_include.zc @@ -0,0 +1,6 @@ +// expect error: module access requires `include run;` +// spec 5.12.4 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +fn main() { pn(run.evals("return 1;")); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/statement_hook_ticks.zc b/tests/conformance/7-compile-time/statement_hook_ticks.zc new file mode 100644 index 0000000..7e51085 --- /dev/null +++ b/tests/conformance/7-compile-time/statement_hook_ticks.zc @@ -0,0 +1,10 @@ +// expect: 4/ +// spec 7.6 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +int ticks; +int tick() { ticks++; return 0; } +run.statement_hook(tick); +fn main() { int a = 1; a = a + 1; a = a + 1; pn(ticks); return 0; } +// zc0: skip diff --git a/tests/conformance/7-compile-time/syntax_hi.zc b/tests/conformance/7-compile-time/syntax_hi.zc new file mode 100644 index 0000000..5cd050b --- /dev/null +++ b/tests/conformance/7-compile-time/syntax_hi.zc @@ -0,0 +1,10 @@ +// expect: HH/ +// spec 7.6 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +include run; +void kw_hi() { run.next(); run.expect(run.intern(";")); + run.lit('H'); run.callname(run.intern("rt.put_c")); run.op(run.O_DROP); return; } +run.syntax("hi", kw_hi); +fn main() { hi; hi; rt.put_c(10); return 0; } +// zc0: skip -- cgit v1.2.3