diff options
| author | 2026-10-14 08:29:46 +0330 | |
|---|---|---|
| committer | 2026-10-14 08:29:46 +0330 | |
| commit | 1c53304d03414890af0da7432d1aea87e754a14a (patch) | |
| tree | 97190d86cf548c9bc63f68c86a4d2a4f09809713 /tests/icon | |
| parent | a (diff) | |
feat: grow memory limits, add icon/actor libraries, overhaul LSP diagnostics
Compiler and VM
- make every memory map limit dynamic and adjustable at both build time and
runtime, including compiler tables, stacks, and every execution region
- reserve and grow tables, operand and return stacks, frame segments, and
image-building output without relocating live code or globals
- rename i/o and string helpers consistently (puts -> put_s, putn -> put_n,
scat -> cat_s) across compiler, runtime, examples, tests, and docs
- recast and consume values assigned to globals from inside functions
- allow fixed and const together, add typed closure returns (fn:t(...)),
multi-include syntax (include rt, run, core;), and recurse type inference
- never infer string literals as word, anywhere, as argument, variable, or
return type
- draft docs/BORROW.md: a borrow checker less intrusive than Rust's but more
intelligent
LSP and editor integration
- require explicit includes and give every toolchain area its own namespace
(rt, lsp, run, core)
- hover for built-in types, inferred types, values known at hover time, array
and pointer lifetime/size, library names in include statements, and inferred
lifetimes with explanations
- honor /* */ comments as documentation for variables and arguments, and stop
misattributing section headers or trailing comments as variable hints
- stream diagnostics and cancel stale requests on change
- jump to definition and references, including cross-file
- quick fixes with automatic library import, and namespace completion
Hints and diagnostics
- render hints as blue squigglies by default, with hints on/small/off per file
- suppress magic-number hints via a preceding /* */ comment, and say so
- warn on unused arguments; allow multiple _ discards in parameters, pattern
matching, and tagged enums, warning if a _ is actually used
- rewrite hint and comment prose in professional compiler-doc register
Libraries
- add icon.zc: run-time self-modification, find/replace syntax, type and block
edits, and step-through inspection of locals and globals
- add actor.zc: async actors with Actor<I,O>, implicit this, spawn/recv/send,
injected into the compiler machinery at include time rather than built in
Tooling and docs
- reorganize sources, tests, and designs into subdirectories
- unify windows entry points in tinyvm.bat and add a matching tinyvm.sh
- add --help across the toolchain
- polish the learning guide, stdlib docs, and design notes
Tests
- add accept, reject, and regression coverage across the compiler, LSP,
- runtime, icon, actors, threads, formatting, and the toolchain contracts,
plus fuzzers and property tests
Diffstat (limited to 'tests/icon')
90 files changed, 520 insertions, 0 deletions
diff --git a/tests/icon/accept/bound_global.expected b/tests/icon/accept/bound_global.expected new file mode 100644 index 0000000..938d790 --- /dev/null +++ b/tests/icon/accept/bound_global.expected @@ -0,0 +1 @@ +1 10 10 diff --git a/tests/icon/accept/bound_global.zc b/tests/icon/accept/bound_global.zc new file mode 100644 index 0000000..f49a76b --- /dev/null +++ b/tests/icon/accept/bound_global.zc @@ -0,0 +1,13 @@ +include rt; +include run; +include icon; +int counter = 6; +fn main() { + let q = run.tokens("counter += 4; return counter;"); + let frame = icon.begin(q); + rt.put_n(icon.bind_global(frame, "counter")); rt.put_c(' '); + icon.resume(frame, 3); + rt.put_n(counter); rt.put_c(' '); rt.put_n(icon.result(frame)); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/accept/branch_edit.expected b/tests/icon/accept/branch_edit.expected new file mode 100644 index 0000000..9c1b765 --- /dev/null +++ b/tests/icon/accept/branch_edit.expected @@ -0,0 +1 @@ +9 7 diff --git a/tests/icon/accept/branch_edit.zc b/tests/icon/accept/branch_edit.zc new file mode 100644 index 0000000..b360a6a --- /dev/null +++ b/tests/icon/accept/branch_edit.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("if (1) { return 7; } else { return 9; }"); + let pattern = run.tokens("if ($expr:condition) { $stmt:yes } else { $stmt:no }"); + let replacement = run.tokens("if ($condition) { $no } else { $yes }"); + let edited = icon.rewrite(q, pattern, replacement); + rt.put_n(run.eval(edited)); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/calculate.expected b/tests/icon/accept/calculate.expected new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/tests/icon/accept/calculate.expected @@ -0,0 +1 @@ +42 diff --git a/tests/icon/accept/calculate.zc b/tests/icon/accept/calculate.zc new file mode 100644 index 0000000..77ba7ea --- /dev/null +++ b/tests/icon/accept/calculate.zc @@ -0,0 +1,8 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("(3 + 4) * (8 - 2)"); + rt.put_n(icon.calculate(q, 0, q[0])); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/edit_declaration.expected b/tests/icon/accept/edit_declaration.expected new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/tests/icon/accept/edit_declaration.expected @@ -0,0 +1 @@ +10 diff --git a/tests/icon/accept/edit_declaration.zc b/tests/icon/accept/edit_declaration.zc new file mode 100644 index 0000000..59b7eb8 --- /dev/null +++ b/tests/icon/accept/edit_declaration.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int discarded = 8; int n = 5; return n * 2;"); + let a = icon.undeclare(q, "discarded"); + let type = run.tokens("i32"), block = run.tokens("int extra = 2;"); + let b = icon.change_type(a, "n", type); + let c = icon.insert_block(b, 0, block); + rt.put_n(run.eval(c)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/function_step.expected b/tests/icon/accept/function_step.expected new file mode 100644 index 0000000..c2096ed --- /dev/null +++ b/tests/icon/accept/function_step.expected @@ -0,0 +1 @@ +13 5 diff --git a/tests/icon/accept/function_step.zc b/tests/icon/accept/function_step.zc new file mode 100644 index 0000000..6bdf344 --- /dev/null +++ b/tests/icon/accept/function_step.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +int target(int value) { int n = value * 2; return n + 1; } +fn main() { + let frame = icon.begin_function(target); + icon.set_local(frame, "value", 6); + icon.resume(frame, 8); + rt.put_n(icon.result(frame)); rt.put_c(' '); rt.put_n(target(2)); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/accept/literal_replace.expected b/tests/icon/accept/literal_replace.expected new file mode 100644 index 0000000..9c67935 --- /dev/null +++ b/tests/icon/accept/literal_replace.expected @@ -0,0 +1 @@ +1 4 diff --git a/tests/icon/accept/literal_replace.zc b/tests/icon/accept/literal_replace.zc new file mode 100644 index 0000000..70f7527 --- /dev/null +++ b/tests/icon/accept/literal_replace.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +int addition() { return 7 + 3; } +fn main() { + let changed = icon.find_replace(addition, ${ $int + $int }, ${ $int - $int }); + rt.put_n(changed); rt.put_c(' '); rt.put_n(addition()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/loop_step.expected b/tests/icon/accept/loop_step.expected new file mode 100644 index 0000000..15d5109 --- /dev/null +++ b/tests/icon/accept/loop_step.expected @@ -0,0 +1 @@ +1 8 1 diff --git a/tests/icon/accept/loop_step.zc b/tests/icon/accept/loop_step.zc new file mode 100644 index 0000000..7a0368e --- /dev/null +++ b/tests/icon/accept/loop_step.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 0; while (n < limit) { n += 1; } if (n == 4) { n *= 2; } else { n = 99; } return n;"); + let frame = icon.begin(q); + icon.set_global(frame, "limit", 4); + icon.resume(frame, 3); rt.put_n(icon.local(frame, "n")); rt.put_c(' '); + icon.resume(frame, 30); rt.put_n(icon.result(frame)); rt.put_c(' '); rt.put_n(icon.state(frame)); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/accept/named_capture.expected b/tests/icon/accept/named_capture.expected new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/tests/icon/accept/named_capture.expected @@ -0,0 +1 @@ +8 diff --git a/tests/icon/accept/named_capture.zc b/tests/icon/accept/named_capture.zc new file mode 100644 index 0000000..258004d --- /dev/null +++ b/tests/icon/accept/named_capture.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return (2 + 5) * (2 + 5);"); + let p = run.tokens("$expr:x * $expr:x"), r = run.tokens("$x + 1"); + let changed = icon.rewrite(q, p, r); + rt.put_n(run.eval(changed)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/nested_declaration.expected b/tests/icon/accept/nested_declaration.expected new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/tests/icon/accept/nested_declaration.expected @@ -0,0 +1 @@ +5 diff --git a/tests/icon/accept/nested_declaration.zc b/tests/icon/accept/nested_declaration.zc new file mode 100644 index 0000000..9b360e8 --- /dev/null +++ b/tests/icon/accept/nested_declaration.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 2; { int unused = 9; int added = 3; n += added; } return n;"); + let type = run.tokens("i32"); + let a = icon.undeclare(q, "unused"); + let b = icon.change_type(a, "added", type); + rt.put_n(run.eval(b)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/step.expected b/tests/icon/accept/step.expected new file mode 100644 index 0000000..a370d71 --- /dev/null +++ b/tests/icon/accept/step.expected @@ -0,0 +1 @@ +4 12 14 diff --git a/tests/icon/accept/step.zc b/tests/icon/accept/step.zc new file mode 100644 index 0000000..d394e1e --- /dev/null +++ b/tests/icon/accept/step.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 4; n = n * 3; return n + bias;"); + let frame = icon.begin(q); + icon.set_global(frame, "bias", 2); + icon.step(frame); rt.put_n(icon.local(frame, "n")); rt.put_c(' '); + icon.step(frame); rt.put_n(icon.local(frame, "n")); rt.put_c(' '); + icon.step(frame); rt.put_n(icon.result(frame)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/accept/token_replace.expected b/tests/icon/accept/token_replace.expected new file mode 100644 index 0000000..8351c19 --- /dev/null +++ b/tests/icon/accept/token_replace.expected @@ -0,0 +1 @@ +14 diff --git a/tests/icon/accept/token_replace.zc b/tests/icon/accept/token_replace.zc new file mode 100644 index 0000000..bf80548 --- /dev/null +++ b/tests/icon/accept/token_replace.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let source = run.tokens("return (9 + 2) * 3;"); + let pattern = run.tokens("$expr:left * $int:right"); + let replacement = run.tokens("$left + $right"); + let edited = icon.rewrite(source, pattern, replacement); + rt.put_n(run.eval(edited)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/block_capture_boundary.expected b/tests/icon/regression/block_capture_boundary.expected new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/icon/regression/block_capture_boundary.expected @@ -0,0 +1 @@ +7 diff --git a/tests/icon/regression/block_capture_boundary.zc b/tests/icon/regression/block_capture_boundary.zc new file mode 100644 index 0000000..29925c4 --- /dev/null +++ b/tests/icon/regression/block_capture_boundary.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("{ return 1; } { return 2; } ;"); + let p = run.tokens("$block:x ;"), replacement = run.tokens("{}"); + let r = icon.rewrite(q, p, replacement); + rt.put_n(r[0]); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/frame_cleanup.expected b/tests/icon/regression/frame_cleanup.expected new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/icon/regression/frame_cleanup.expected @@ -0,0 +1 @@ +1 diff --git a/tests/icon/regression/frame_cleanup.zc b/tests/icon/regression/frame_cleanup.zc new file mode 100644 index 0000000..b55c27e --- /dev/null +++ b/tests/icon/regression/frame_cleanup.zc @@ -0,0 +1,16 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens(""); + int before = rt.live_objects(), i = 0; + while (i < 100) { + let frame = icon.begin(q); + icon.set_local(frame, "local", i); + icon.set_global(frame, "global", i + 1); + icon.close(d*frame); + i++; + } + rt.put_n(rt.live_objects() == before); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/inspect_modify_resume.expected b/tests/icon/regression/inspect_modify_resume.expected new file mode 100644 index 0000000..90619d0 --- /dev/null +++ b/tests/icon/regression/inspect_modify_resume.expected @@ -0,0 +1 @@ +8 3 diff --git a/tests/icon/regression/inspect_modify_resume.zc b/tests/icon/regression/inspect_modify_resume.zc new file mode 100644 index 0000000..b9bfad1 --- /dev/null +++ b/tests/icon/regression/inspect_modify_resume.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 1; while (n < 3) { n++; } return n;"); + let frame = icon.begin(q); + icon.step(frame); icon.set_local(frame, "n", 8); + icon.resume(frame, 5); + rt.put_n(icon.result(frame)); rt.put_c(' '); rt.put_n(icon.steps(frame)); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/regression/literal_capture.expected b/tests/icon/regression/literal_capture.expected new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/tests/icon/regression/literal_capture.expected @@ -0,0 +1 @@ +42 diff --git a/tests/icon/regression/literal_capture.zc b/tests/icon/regression/literal_capture.zc new file mode 100644 index 0000000..baf0385 --- /dev/null +++ b/tests/icon/regression/literal_capture.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return \"return\";"); + let p = run.tokens("return $expr:x;"); + let replacement = run.tokens("return 42;"); + let r = icon.rewrite(q, p, replacement); + rt.put_n(run.eval(r)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/mismatch_capture.expected b/tests/icon/regression/mismatch_capture.expected new file mode 100644 index 0000000..f6b91e0 --- /dev/null +++ b/tests/icon/regression/mismatch_capture.expected @@ -0,0 +1 @@ +56 diff --git a/tests/icon/regression/mismatch_capture.zc b/tests/icon/regression/mismatch_capture.zc new file mode 100644 index 0000000..53fb3c6 --- /dev/null +++ b/tests/icon/regression/mismatch_capture.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return (2 + 5) * (2 + 6);"); + let pattern = run.tokens("$expr:x * $expr:x"), replacement = run.tokens("$x + 1"); + let edited = icon.rewrite(q, pattern, replacement); + rt.put_n(run.eval(edited)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/no_match.expected b/tests/icon/regression/no_match.expected new file mode 100644 index 0000000..cfe9b7e --- /dev/null +++ b/tests/icon/regression/no_match.expected @@ -0,0 +1,2 @@ +12 +1 diff --git a/tests/icon/regression/no_match.zc b/tests/icon/regression/no_match.zc new file mode 100644 index 0000000..5686c4a --- /dev/null +++ b/tests/icon/regression/no_match.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 12;"); + let pattern = run.tokens("1 + 2"), replacement = run.tokens("5"); + let r = icon.rewrite(q, pattern, replacement); + rt.put_n(run.eval(r)); rt.put_c(10); + rt.put_n(q[0] == r[0]); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/preserve_const.expected b/tests/icon/regression/preserve_const.expected new file mode 100644 index 0000000..2fb73a0 --- /dev/null +++ b/tests/icon/regression/preserve_const.expected @@ -0,0 +1 @@ +1 1 diff --git a/tests/icon/regression/preserve_const.zc b/tests/icon/regression/preserve_const.zc new file mode 100644 index 0000000..4824413 --- /dev/null +++ b/tests/icon/regression/preserve_const.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("const int total = 3;"), type = run.tokens("i32"); + let edited = icon.change_type(q, "total", type); + rt.put_n(edited[2] == run.intern("const")); rt.put_c(' '); rt.put_n(edited[5] == run.intern("i32")); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/repeated_publication.expected b/tests/icon/regression/repeated_publication.expected new file mode 100644 index 0000000..f847703 --- /dev/null +++ b/tests/icon/regression/repeated_publication.expected @@ -0,0 +1 @@ +1 8 1 9 diff --git a/tests/icon/regression/repeated_publication.zc b/tests/icon/regression/repeated_publication.zc new file mode 100644 index 0000000..b8f4268 --- /dev/null +++ b/tests/icon/regression/repeated_publication.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +int target() { return 7; } +fn main() { + let first = run.tokens("7"), second = run.tokens("8"), third = run.tokens("9"); + rt.put_n(icon.find_replace(target, first, second)); rt.put_c(' '); rt.put_n(target()); rt.put_c(' '); + rt.put_n(icon.find_replace(target, second, third)); rt.put_c(' '); rt.put_n(target()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/replace_all.expected b/tests/icon/regression/replace_all.expected new file mode 100644 index 0000000..d0f5ee9 --- /dev/null +++ b/tests/icon/regression/replace_all.expected @@ -0,0 +1 @@ +-2 24 diff --git a/tests/icon/regression/replace_all.zc b/tests/icon/regression/replace_all.zc new file mode 100644 index 0000000..acb4458 --- /dev/null +++ b/tests/icon/regression/replace_all.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return (1 + 2) * (5 + 3);"); + let pattern = run.tokens("$int + $int"), replacement = run.tokens("$int - $int"); + let edited = icon.rewrite(q, pattern, replacement); + rt.put_n(run.eval(edited)); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/shadow.expected b/tests/icon/regression/shadow.expected new file mode 100644 index 0000000..606c19a --- /dev/null +++ b/tests/icon/regression/shadow.expected @@ -0,0 +1 @@ +3 1 diff --git a/tests/icon/regression/shadow.zc b/tests/icon/regression/shadow.zc new file mode 100644 index 0000000..ca4220d --- /dev/null +++ b/tests/icon/regression/shadow.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 3; { int n = 8; n++; } return n;"); + let frame = icon.begin(q); + icon.resume(frame, 10); rt.put_n(icon.result(frame)); rt.put_c(' '); rt.put_n(icon.local_count(frame)); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/regression/statement_capture_boundary.expected b/tests/icon/regression/statement_capture_boundary.expected new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/tests/icon/regression/statement_capture_boundary.expected @@ -0,0 +1 @@ +6 diff --git a/tests/icon/regression/statement_capture_boundary.zc b/tests/icon/regression/statement_capture_boundary.zc new file mode 100644 index 0000000..8316eb9 --- /dev/null +++ b/tests/icon/regression/statement_capture_boundary.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 1; return 2; tail;"); + let p = run.tokens("$stmt:x tail;"), replacement = run.tokens("return 9;"); + let r = icon.rewrite(q, p, replacement); + rt.put_n(r[0]); rt.put_c(10); + return 0; +} diff --git a/tests/icon/regression/status_clear.expected b/tests/icon/regression/status_clear.expected new file mode 100644 index 0000000..87bde8e --- /dev/null +++ b/tests/icon/regression/status_clear.expected @@ -0,0 +1 @@ +0 3 0 diff --git a/tests/icon/regression/status_clear.zc b/tests/icon/regression/status_clear.zc new file mode 100644 index 0000000..89e8535 --- /dev/null +++ b/tests/icon/regression/status_clear.zc @@ -0,0 +1,14 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens(""); + let f = icon.begin(q); + icon.local(f, "missing"); + icon.set_local(f, "n", 3); + rt.put_n(icon.error()); rt.put_c(' '); + icon.local(f, "missing"); + rt.put_n(icon.local(f, "n")); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*f); + return 0; +} diff --git a/tests/icon/regression/strings.expected b/tests/icon/regression/strings.expected new file mode 100644 index 0000000..c1eac1e --- /dev/null +++ b/tests/icon/regression/strings.expected @@ -0,0 +1,2 @@ +5 5 11 +1 diff --git a/tests/icon/regression/strings.zc b/tests/icon/regression/strings.zc new file mode 100644 index 0000000..051a29d --- /dev/null +++ b/tests/icon/regression/strings.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 8 + 3;"), p = run.tokens("$int + $int"), r = run.tokens("$int - $int"); + let a = icon.rewrite(q, p, r), b = icon.rewrite(q, p, r); + rt.put_n(run.eval(a)); rt.put_c(' '); rt.put_n(run.eval(b)); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + let text = run.tokens("return \"{} 8 + 3\";"); + let same = icon.rewrite(text, p, r); + rt.put_n(text[0] == same[0]); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/bad_delimiter_replacement.expected b/tests/icon/reject/bad_delimiter_replacement.expected new file mode 100644 index 0000000..363c912 --- /dev/null +++ b/tests/icon/reject/bad_delimiter_replacement.expected @@ -0,0 +1 @@ +1 1 3 diff --git a/tests/icon/reject/bad_delimiter_replacement.zc b/tests/icon/reject/bad_delimiter_replacement.zc new file mode 100644 index 0000000..faffd90 --- /dev/null +++ b/tests/icon/reject/bad_delimiter_replacement.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 3;"), pattern = run.tokens("$int"), replacement = run.tokens("("); + let edited = icon.rewrite(q, pattern, replacement); + rt.put_n(edited == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/bind_function.expected b/tests/icon/reject/bind_function.expected new file mode 100644 index 0000000..65cd68b --- /dev/null +++ b/tests/icon/reject/bind_function.expected @@ -0,0 +1 @@ +0 2 diff --git a/tests/icon/reject/bind_function.zc b/tests/icon/reject/bind_function.zc new file mode 100644 index 0000000..1348c90 --- /dev/null +++ b/tests/icon/reject/bind_function.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +int target() { return 1; } +fn main() { + let q = run.tokens("return 0;"), frame = icon.begin(q); + rt.put_n(icon.bind_global(frame, "target")); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/reject/bind_pointer.expected b/tests/icon/reject/bind_pointer.expected new file mode 100644 index 0000000..6517ee9 --- /dev/null +++ b/tests/icon/reject/bind_pointer.expected @@ -0,0 +1 @@ +0 2 preserved diff --git a/tests/icon/reject/bind_pointer.zc b/tests/icon/reject/bind_pointer.zc new file mode 100644 index 0000000..4834dde --- /dev/null +++ b/tests/icon/reject/bind_pointer.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +char* message = "preserved"; +fn main() { + let q = run.tokens("return 0;"), frame = icon.begin(q); + rt.put_n(icon.bind_global(frame, "message")); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); rt.put_s(message); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/reject/expression_boundary.expected b/tests/icon/reject/expression_boundary.expected new file mode 100644 index 0000000..65cd68b --- /dev/null +++ b/tests/icon/reject/expression_boundary.expected @@ -0,0 +1 @@ +0 2 diff --git a/tests/icon/reject/expression_boundary.zc b/tests/icon/reject/expression_boundary.zc new file mode 100644 index 0000000..5c84dbd --- /dev/null +++ b/tests/icon/reject/expression_boundary.zc @@ -0,0 +1,8 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("(7)"); + rt.put_n(icon.calculate(q, 0, 2)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/implicit_global.expected b/tests/icon/reject/implicit_global.expected new file mode 100644 index 0000000..3ff996e --- /dev/null +++ b/tests/icon/reject/implicit_global.expected @@ -0,0 +1 @@ +0 2 5 diff --git a/tests/icon/reject/implicit_global.zc b/tests/icon/reject/implicit_global.zc new file mode 100644 index 0000000..ce8e25d --- /dev/null +++ b/tests/icon/reject/implicit_global.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +int hidden = 41; +fn main() { + let q = run.tokens("return hidden;"); + let f = icon.begin(q); + rt.put_n(icon.step(f)); rt.put_c(' '); rt.put_n(icon.state(f)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*f); + return 0; +} diff --git a/tests/icon/reject/incomplete_expression.expected b/tests/icon/reject/incomplete_expression.expected new file mode 100644 index 0000000..65cd68b --- /dev/null +++ b/tests/icon/reject/incomplete_expression.expected @@ -0,0 +1 @@ +0 2 diff --git a/tests/icon/reject/incomplete_expression.zc b/tests/icon/reject/incomplete_expression.zc new file mode 100644 index 0000000..8a0366c --- /dev/null +++ b/tests/icon/reject/incomplete_expression.zc @@ -0,0 +1,8 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("1 +"); + rt.put_n(icon.calculate(q, 0, q[0])); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/multiple_bindings.expected b/tests/icon/reject/multiple_bindings.expected new file mode 100644 index 0000000..43cebf1 --- /dev/null +++ b/tests/icon/reject/multiple_bindings.expected @@ -0,0 +1 @@ +1 2 2 diff --git a/tests/icon/reject/multiple_bindings.zc b/tests/icon/reject/multiple_bindings.zc new file mode 100644 index 0000000..2b7b5e0 --- /dev/null +++ b/tests/icon/reject/multiple_bindings.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int a = 1, b = 2; return b;"); + let changed = icon.undeclare(q, "a"); + rt.put_n(changed == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/non_declaration.expected b/tests/icon/reject/non_declaration.expected new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/tests/icon/reject/non_declaration.expected @@ -0,0 +1 @@ +1 2 diff --git a/tests/icon/reject/non_declaration.zc b/tests/icon/reject/non_declaration.zc new file mode 100644 index 0000000..b4233f9 --- /dev/null +++ b/tests/icon/reject/non_declaration.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("rt.put_n(n); return 0;"); + let changed = icon.undeclare(q, "n"); + rt.put_n(changed == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/null_inputs.expected b/tests/icon/reject/null_inputs.expected new file mode 100644 index 0000000..75f3fe4 --- /dev/null +++ b/tests/icon/reject/null_inputs.expected @@ -0,0 +1,4 @@ +0 2 +1 2 +1 2 +1 2 diff --git a/tests/icon/reject/null_inputs.zc b/tests/icon/reject/null_inputs.zc new file mode 100644 index 0000000..41a7c4e --- /dev/null +++ b/tests/icon/reject/null_inputs.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + rt.put_n(icon.calculate(0, 0, 1)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + let a = icon.undeclare(0, "n"); rt.put_n(a == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + let b = icon.change_type(0, "n", 0); rt.put_n(b == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + let c = icon.insert_block(0, 0, 0); rt.put_n(c == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/publication_return_type.expected b/tests/icon/reject/publication_return_type.expected new file mode 100644 index 0000000..3f070c0 --- /dev/null +++ b/tests/icon/reject/publication_return_type.expected @@ -0,0 +1 @@ +0 4 diff --git a/tests/icon/reject/publication_return_type.zc b/tests/icon/reject/publication_return_type.zc new file mode 100644 index 0000000..03822c5 --- /dev/null +++ b/tests/icon/reject/publication_return_type.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +typecheck on; +int target() { return 4; } +fn main() { + let pattern = run.tokens("return $int;"), replacement = run.tokens("return \"invalid\";"); + rt.put_n(icon.find_replace(target, pattern, replacement)); rt.put_c(' '); + rt.put_n(target()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/publication_signature.expected b/tests/icon/reject/publication_signature.expected new file mode 100644 index 0000000..3f070c0 --- /dev/null +++ b/tests/icon/reject/publication_signature.expected @@ -0,0 +1 @@ +0 4 diff --git a/tests/icon/reject/publication_signature.zc b/tests/icon/reject/publication_signature.zc new file mode 100644 index 0000000..01646e0 --- /dev/null +++ b/tests/icon/reject/publication_signature.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +typecheck on; +int target(int value) { return value + 1; } +fn main() { + let replacement = run.tokens("int target(char* value) { return 9; }"); + rt.put_n(run.replace_function(target, replacement)); rt.put_c(' '); + rt.put_n(target(3)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/range.expected b/tests/icon/reject/range.expected new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/tests/icon/reject/range.expected @@ -0,0 +1 @@ +1 2 diff --git a/tests/icon/reject/range.zc b/tests/icon/reject/range.zc new file mode 100644 index 0000000..42bc0f4 --- /dev/null +++ b/tests/icon/reject/range.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 1;"), r = run.tokens("2"); + let changed = icon.splice(q, -1, 1, r); + rt.put_n(changed == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/sized_frame.expected b/tests/icon/reject/sized_frame.expected new file mode 100644 index 0000000..a57b07e --- /dev/null +++ b/tests/icon/reject/sized_frame.expected @@ -0,0 +1 @@ +2 5 diff --git a/tests/icon/reject/sized_frame.zc b/tests/icon/reject/sized_frame.zc new file mode 100644 index 0000000..43e44fa --- /dev/null +++ b/tests/icon/reject/sized_frame.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("i8 n = 300; return n;"); + let frame = icon.begin(q); + icon.step(frame); + rt.put_n(icon.state(frame)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/reject/step_else_side_effect.expected b/tests/icon/reject/step_else_side_effect.expected new file mode 100644 index 0000000..c24938b --- /dev/null +++ b/tests/icon/reject/step_else_side_effect.expected @@ -0,0 +1 @@ +0 2 0 diff --git a/tests/icon/reject/step_else_side_effect.zc b/tests/icon/reject/step_else_side_effect.zc new file mode 100644 index 0000000..43c0d5d --- /dev/null +++ b/tests/icon/reject/step_else_side_effect.zc @@ -0,0 +1,12 @@ +include rt; +include run; +include icon; +int calls; +int condition() { calls++; return 1; } +fn main() { + let q = run.tokens("if (condition()) { return 1; } else return 2;"); + let f = icon.begin(q); + rt.put_n(icon.step(f)); rt.put_c(' '); rt.put_n(icon.state(f)); rt.put_c(' '); rt.put_n(calls); rt.put_c(10); + icon.close(d*f); + return 0; +} diff --git a/tests/icon/reject/step_local_mutation.expected b/tests/icon/reject/step_local_mutation.expected new file mode 100644 index 0000000..f8c518e --- /dev/null +++ b/tests/icon/reject/step_local_mutation.expected @@ -0,0 +1 @@ +0 2 1 diff --git a/tests/icon/reject/step_local_mutation.zc b/tests/icon/reject/step_local_mutation.zc new file mode 100644 index 0000000..6ef0a51 --- /dev/null +++ b/tests/icon/reject/step_local_mutation.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 1; return n++;"); + let f = icon.begin(q); + icon.step(f); + rt.put_n(icon.step(f)); rt.put_c(' '); rt.put_n(icon.state(f)); rt.put_c(' '); rt.put_n(icon.local(f, "n")); rt.put_c(10); + icon.close(d*f); + return 0; +} diff --git a/tests/icon/reject/step_multiple_bindings.expected b/tests/icon/reject/step_multiple_bindings.expected new file mode 100644 index 0000000..057d934 --- /dev/null +++ b/tests/icon/reject/step_multiple_bindings.expected @@ -0,0 +1 @@ +0 2 5 0 diff --git a/tests/icon/reject/step_multiple_bindings.zc b/tests/icon/reject/step_multiple_bindings.zc new file mode 100644 index 0000000..d1dba73 --- /dev/null +++ b/tests/icon/reject/step_multiple_bindings.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int n = 1, m = 2;"); + let f = icon.begin(q); + rt.put_n(icon.step(f)); rt.put_c(' '); rt.put_n(icon.state(f)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); rt.put_n(icon.local_count(f)); rt.put_c(10); + icon.close(d*f); + return 0; +} diff --git a/tests/icon/reject/type_name_binding.expected b/tests/icon/reject/type_name_binding.expected new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/tests/icon/reject/type_name_binding.expected @@ -0,0 +1 @@ +1 2 diff --git a/tests/icon/reject/type_name_binding.zc b/tests/icon/reject/type_name_binding.zc new file mode 100644 index 0000000..7ee62a9 --- /dev/null +++ b/tests/icon/reject/type_name_binding.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("int* pointer;"); + let r = icon.undeclare(q, "int"); + rt.put_n(r == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/unbalanced.expected b/tests/icon/reject/unbalanced.expected new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/icon/reject/unbalanced.expected @@ -0,0 +1 @@ +0 diff --git a/tests/icon/reject/unbalanced.zc b/tests/icon/reject/unbalanced.zc new file mode 100644 index 0000000..d6ab110 --- /dev/null +++ b/tests/icon/reject/unbalanced.zc @@ -0,0 +1,8 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return (1 + 2;"); + rt.put_n(icon.validate(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/unknown_pattern.expected b/tests/icon/reject/unknown_pattern.expected new file mode 100644 index 0000000..2fb73a0 --- /dev/null +++ b/tests/icon/reject/unknown_pattern.expected @@ -0,0 +1 @@ +1 1 diff --git a/tests/icon/reject/unknown_pattern.zc b/tests/icon/reject/unknown_pattern.zc new file mode 100644 index 0000000..74850c3 --- /dev/null +++ b/tests/icon/reject/unknown_pattern.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 1;"), pattern = run.tokens("$unknown"), replacement = run.tokens("2"); + let changed = icon.rewrite(q, pattern, replacement); + rt.put_n(changed == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/unresolved_capture.expected b/tests/icon/reject/unresolved_capture.expected new file mode 100644 index 0000000..4ef63d7 --- /dev/null +++ b/tests/icon/reject/unresolved_capture.expected @@ -0,0 +1 @@ +1 3 3 diff --git a/tests/icon/reject/unresolved_capture.zc b/tests/icon/reject/unresolved_capture.zc new file mode 100644 index 0000000..71584e3 --- /dev/null +++ b/tests/icon/reject/unresolved_capture.zc @@ -0,0 +1,9 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("return 1 + 2;"), p = run.tokens("$int + $int"), r = run.tokens("$missing"); + let changed = icon.rewrite(q, p, r); + rt.put_n(changed == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); rt.put_n(run.eval(q)); rt.put_c(10); + return 0; +} diff --git a/tests/icon/reject/unsupported_step.expected b/tests/icon/reject/unsupported_step.expected new file mode 100644 index 0000000..a57b07e --- /dev/null +++ b/tests/icon/reject/unsupported_step.expected @@ -0,0 +1 @@ +2 5 diff --git a/tests/icon/reject/unsupported_step.zc b/tests/icon/reject/unsupported_step.zc new file mode 100644 index 0000000..944c5b6 --- /dev/null +++ b/tests/icon/reject/unsupported_step.zc @@ -0,0 +1,10 @@ +include rt; +include run; +include icon; +fn main() { + let q = run.tokens("for (int i = 0; i < 2; i++) {}"); + let frame = icon.begin(q); + icon.step(frame); rt.put_n(icon.state(frame)); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*frame); + return 0; +} |
