diff options
| author | 2026-10-15 18:29:55 +0330 | |
|---|---|---|
| committer | 2026-10-15 18:29:55 +0330 | |
| commit | e7fe081efaae893ed46548fdbc3bfa39b2879878 (patch) | |
| tree | ad2e3804bcbc6493d7152f68e91f17d4b357c73e /tests/conformance | |
| parent | constant 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')
8 files changed, 43 insertions, 15 deletions
diff --git a/tests/conformance/1-source/string_unterminated.zc b/tests/conformance/1-source/string_unterminated.zc new file mode 100644 index 0000000..aca63d3 --- /dev/null +++ b/tests/conformance/1-source/string_unterminated.zc @@ -0,0 +1,5 @@ +// expect error: zc: line 4: unterminated string literal +// spec 1.4.4 (was appendix b.2.11): a string with no closing quote is reported where it starts +include rt; +fn main() { rt.put_s("never closed); return 0; } +// zc0: skip 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 diff --git a/tests/conformance/6-ownership/drop_gc_cycle.zc b/tests/conformance/6-ownership/drop_gc_cycle.zc index 01db6b8..d31dc6b 100644 --- a/tests/conformance/6-ownership/drop_gc_cycle.zc +++ b/tests/conformance/6-ownership/drop_gc_cycle.zc @@ -1,5 +1,5 @@ -// expect: 0 1 2 2 0/ -// destructors 6.15.3: two unreachable values with drops that reach each other are finalized one per collection (each is in a cycle, so nothing outside it drops first), each exactly once, then freed +// expect: 0 2 2 2 0/ +// destructors 6.15.3: two unreachable values with drops that reach each other are both finalized in one collection (each is in a cycle, so nothing outside it drops first), each exactly once, then freed include rt; int n; word g; diff --git a/tests/conformance/6-ownership/drop_gc_cycle_long.zc b/tests/conformance/6-ownership/drop_gc_cycle_long.zc new file mode 100644 index 0000000..3de3f1e --- /dev/null +++ b/tests/conformance/6-ownership/drop_gc_cycle_long.zc @@ -0,0 +1,24 @@ +// expect: 0 5 15 5 0/ +// destructors 6.15.3: an unreachable cycle of five values with drops is finalized whole by one collection, each value once, then freed +include rt; +int n, sum; +word g; +struct node { node* next; int v; void drop() { n++; sum = sum + this.v; } } +unchecked fn make() { + node* a = rt.new(node); node* p = a; int i; + a.v = 1; + for (i = 2; i <= 5; i++) { node* q = rt.new(node); q.v = i; p.next = q; p = q; } + p.next = a; + g = a; + return 0; +} +fn main() { + make(); + rt.gc(); rt.put_n(n); rt.put_c(32); + g = 0; + rt.gc(); rt.put_n(n); rt.put_c(32); rt.put_n(sum); rt.put_c(32); + rt.gc(); rt.put_n(n); rt.put_c(32); + rt.put_n(rt.dcount); rt.put_c(10); + 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 index 63c30ec..e724c63 100644 --- a/tests/conformance/9-appendix-b/b2_15_duplicate_case.zc +++ b/tests/conformance/9-appendix-b/b2_15_duplicate_case.zc @@ -1,5 +1,5 @@ // expect error: duplicate -// spec appendix b.2.15: duplicate case labels are not diagnosed (4.7.2 says they are allowed) +// spec 4.7.2 (was appendix b.2.15): duplicate case labels are an error 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; } diff --git a/tests/conformance/known.txt b/tests/conformance/known.txt index 25bc3b7..685b089 100644 --- a/tests/conformance/known.txt +++ b/tests/conformance/known.txt @@ -3,7 +3,6 @@ # appendix b.2.8 (a global named in an initializer is its address) is documented behavior per 5.3.2 and 3.14.2: no entry 4-statements/o3_outside_function_ordinary_block.zc zy c top-level o3 { } is rejected; spec 4.10.2 says it is an ordinary block 9-appendix-b/b2_10_recovery_hides_errors.zc zy c appendix b.2.10 confirmed; by design per 8.2 -9-appendix-b/b2_15_duplicate_case.zc zy c appendix b.2.15 confirmed; 4.7.2 says duplicates are allowed 2-types/conv_argument_and_return.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) 2-types/conv_assignment_to_float.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) 2-types/conv_f32_rounds.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) |
