aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/drivers/hint_fixes_test.js2
-rw-r--r--tests/icon/accept/step_globals.expected1
-rw-r--r--tests/icon/accept/step_globals.zc19
-rw-r--r--tests/icon/reject/begin_unknown_function.expected1
-rw-r--r--tests/icon/reject/begin_unknown_function.zc11
-rwxr-xr-xtests/test.sh2
6 files changed, 36 insertions, 0 deletions
diff --git a/tests/drivers/hint_fixes_test.js b/tests/drivers/hint_fixes_test.js
index fffcbf5..20d3dd1 100644
--- a/tests/drivers/hint_fixes_test.js
+++ b/tests/drivers/hint_fixes_test.js
@@ -74,5 +74,7 @@ fixes('a misspelled export is corrected and imported', 'fn main() {\n\tputc(65);
'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`');
+fixes('a qualified name from a file library adds its include', 'include rt;\nfn main() {\n\treturn actor.vector();\n}\n', 'actor', 0,
+ 'include rt;\ninclude actor;\nfn main() {\n\treturn actor.vector();\n}\n', 'include actor');
console.log(ok + ' hint fix checks passed, ' + bad + ' failed');
process.exit(bad ? 1 : 0);
diff --git a/tests/icon/accept/step_globals.expected b/tests/icon/accept/step_globals.expected
new file mode 100644
index 0000000..8c5e263
--- /dev/null
+++ b/tests/icon/accept/step_globals.expected
@@ -0,0 +1 @@
+5 10 11 11 11 0 2
diff --git a/tests/icon/accept/step_globals.zc b/tests/icon/accept/step_globals.zc
new file mode 100644
index 0000000..c584772
--- /dev/null
+++ b/tests/icon/accept/step_globals.zc
@@ -0,0 +1,19 @@
+include rt;
+include run;
+include icon;
+int total = 1;
+fn main() {
+ // step a fragment that writes an isolated global and a bound one, reading both after each step
+ let q = run.tokens("int n = 5; scale = scale * n; total = total + scale; return total;");
+ let frame = icon.begin(q);
+ icon.set_global(frame, "scale", 2);
+ icon.bind_global(frame, "total");
+ icon.step(frame); rt.put_n(icon.local(frame, "n")); rt.put_c(' ');
+ icon.step(frame); rt.put_n(icon.global(frame, "scale")); rt.put_c(' ');
+ icon.step(frame); rt.put_n(icon.global(frame, "total")); rt.put_c(' '); rt.put_n(total); rt.put_c(' ');
+ icon.step(frame); rt.put_n(icon.result(frame)); rt.put_c(' ');
+ // a name the frame never bound reads as 0 with error status 2
+ rt.put_n(icon.global(frame, "missing")); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10);
+ icon.close(d*frame);
+ return 0;
+}
diff --git a/tests/icon/reject/begin_unknown_function.expected b/tests/icon/reject/begin_unknown_function.expected
new file mode 100644
index 0000000..1f338fc
--- /dev/null
+++ b/tests/icon/reject/begin_unknown_function.expected
@@ -0,0 +1 @@
+1 4 0
diff --git a/tests/icon/reject/begin_unknown_function.zc b/tests/icon/reject/begin_unknown_function.zc
new file mode 100644
index 0000000..6a8e5b3
--- /dev/null
+++ b/tests/icon/reject/begin_unknown_function.zc
@@ -0,0 +1,11 @@
+include rt;
+include run;
+include icon;
+fn main() {
+ // an address that is no function has no tokens to step: no frame, error status 4
+ let frame = icon.begin_function(12345);
+ rt.put_n(frame == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' ');
+ // stepping or reading a missing frame does nothing
+ rt.put_n(icon.step(0)); rt.put_c(10);
+ return 0;
+}
diff --git a/tests/test.sh b/tests/test.sh
index 031d6d9..46625a6 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -223,6 +223,8 @@ s_interp() {
python3 tests/drivers/array_methods_test.py $T/zy > $T/arrays.out 2>&1; r=$?
grep -v '^ok' $T/arrays.out
chk $r 0 "native array receiver, algorithm and ownership contracts"
+ # actors are a library: nothing the compiler compiles or reads by default mentions them
+ chk "$(grep -il actor src/compiler/compiler.zc src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default"
python3 tests/drivers/actor_test.py $T/zy > $T/actor.out 2>&1; r=$?
grep -v '^ok' $T/actor.out
chk $r 0 "native isolated actor acceptance, rejection and regression fixtures"