aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/drivers')
-rw-r--r--tests/drivers/hint_fixes_test.js16
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);