diff options
| author | 2026-10-14 08:30:01 +0000 | |
|---|---|---|
| committer | 2026-10-14 08:30:01 +0000 | |
| commit | d274751e89f75cc0f0e25c6e5e87ef91b64597ee (patch) | |
| tree | ef76f2cfe9d2a09f3fe5d27278cf775649bc162f /tests/drivers | |
| parent | lsp: quick fixes for hints and bare library names; comment cleanup (diff) | |
zc: untyped local const, c precedence for && and ||, import fixes for every module
const name = value; inside a function declares a local constant that takes
the initializer's type. the let quick fix now writes a bare const.
the self-hosted compiler bound || tighter than &&, unlike zc0 and the
readme. no existing source mixed them without parentheses, so only new
code was affected.
missing-name diagnostics and their quick fixes now search every module:
rt, core, run, loaded files, and std, icon and actor scanned from source,
including static groups (std.Text.itoa). typos suggest module exports
(putc -> rt.put_c) and get a change-to fix.
Diffstat (limited to 'tests/drivers')
| -rw-r--r-- | tests/drivers/hint_fixes_test.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/drivers/hint_fixes_test.js b/tests/drivers/hint_fixes_test.js index 9513a85..fffcbf5 100644 --- a/tests/drivers/hint_fixes_test.js +++ b/tests/drivers/hint_fixes_test.js @@ -48,8 +48,8 @@ fixes('a local that is never read is renamed to _', head + '\tlet unused = rt.ge none('a local written later is not renamed', head + '\tlet later = 1;\n\tlater = 2;\n\treturn 0;\n}\n', 'later', 0); fixes('a typed constant local becomes const', head + '\tint x = 5;\n\trt.put_n(x);\n\treturn 0;\n}\n', 'x = 5', 0, head + '\tconst int x = 5;\n\trt.put_n(x);\n\treturn 0;\n}\n', 'make `x` a const'); -fixes('an untyped constant local becomes const int', head + '\tlet y = 7;\n\trt.put_n(y);\n\treturn 0;\n}\n', 'y = 7', 0, - head + '\tconst int y = 7;\n\trt.put_n(y);\n\treturn 0;\n}\n', 'make `y` a const'); +fixes('an untyped constant local becomes an untyped const', head + '\tlet y = 7;\n\trt.put_n(y);\n\treturn 0;\n}\n', 'y = 7', 0, + head + '\tconst y = 7;\n\trt.put_n(y);\n\treturn 0;\n}\n', 'make `y` a const'); none('one of several declarators is left alone', head + '\tint x = 5, z = rt.get_c();\n\trt.put_n(x + z);\n\treturn 0;\n}\n', 'x = 5', 0); fixes('a power-of-two multiply becomes a parenthesized shift', head + '\tlet y = rt.get_c();\n\tlet q[4];\n\tq[0] = y;\n\trt.put_n(q[0] * 16 + y);\n\treturn 0;\n}\n', '* 16', 0, head + '\tlet y = rt.get_c();\n\tlet q[4];\n\tq[0] = y;\n\trt.put_n((q[0] << 4) + y);\n\treturn 0;\n}\n', 'write << 4'); @@ -62,5 +62,17 @@ fixes('a compiler name is imported from run', 'include rt;\nfn main() {\n\trt.pu 'include rt;\ninclude run;\nfn main() {\n\trt.put_n(run.evals("return 1;"));\n\treturn 0;\n}\n', 'include run and use run.evals'); fixes('an imported module only needs the qualifier', 'include rt;\nfn main() {\n\tput_c(65);\n\treturn 0;\n}\n', 'put_c', 0, 'include rt;\nfn main() {\n\trt.put_c(65);\n\treturn 0;\n}\n', 'use rt.put_c'); +fixes('a library function is found in its static group', 'include rt;\nfn main() {\n\trt.put_s(itoa(5));\n\treturn 0;\n}\n', 'itoa', 0, + 'include rt;\ninclude std;\nfn main() {\n\trt.put_s(std.Text.itoa(5));\n\treturn 0;\n}\n', 'include std and use std.Text.itoa'); +fixes('a group-qualified name gets its module', 'include rt;\nfn main() {\n\trt.put_s(Text.itoa(5));\n\treturn 0;\n}\n', 'Text', 0, + 'include rt;\ninclude std;\nfn main() {\n\trt.put_s(std.Text.itoa(5));\n\treturn 0;\n}\n', 'include std and use std.Text'); +fixes('a top-level library function is imported', 'include rt;\nfn main() {\n\treturn validate(0);\n}\n', 'validate', 0, + 'include rt;\ninclude icon;\nfn main() {\n\treturn icon.validate(0);\n}\n', 'include icon and use icon.validate'); +fixes('a library read from src/lib is imported', 'include rt;\nfn main() {\n\treturn vector();\n}\n', 'vector', 0, + 'include rt;\ninclude actor;\nfn main() {\n\treturn actor.vector();\n}\n', 'include actor and use actor.vector'); +fixes('a misspelled export is corrected and imported', 'fn main() {\n\tputc(65);\n\treturn 0;\n}\n', 'putc', 0, + 'include rt;\nfn main() {\n\trt.put_c(65);\n\treturn 0;\n}\n', 'include rt and use rt.put_c'); +fixes('a misspelled local function is corrected', 'int count_items() { return 1; }\nfn main() {\n\treturn count_item();\n}\n', 'count_item(', 0, + 'int count_items() { return 1; }\nfn main() {\n\treturn count_items();\n}\n', 'change to `count_items`'); console.log(ok + ' hint fix checks passed, ' + bad + ' failed'); process.exit(bad ? 1 : 0); |
