aboutsummaryrefslogtreecommitdiff
path: root/tests/icon/regression
diff options
context:
space:
mode:
Diffstat (limited to 'tests/icon/regression')
-rw-r--r--tests/icon/regression/o3_direct_replace.expected1
-rw-r--r--tests/icon/regression/o3_direct_replace.zc17
-rw-r--r--tests/icon/regression/o3_failed_keeps_old.expected1
-rw-r--r--tests/icon/regression/o3_failed_keeps_old.zc19
-rw-r--r--tests/icon/regression/o3_repeated_replace.expected1
-rw-r--r--tests/icon/regression/o3_repeated_replace.zc16
6 files changed, 55 insertions, 0 deletions
diff --git a/tests/icon/regression/o3_direct_replace.expected b/tests/icon/regression/o3_direct_replace.expected
new file mode 100644
index 0000000..5dda402
--- /dev/null
+++ b/tests/icon/regression/o3_direct_replace.expected
@@ -0,0 +1 @@
+100 1 200
diff --git a/tests/icon/regression/o3_direct_replace.zc b/tests/icon/regression/o3_direct_replace.zc
new file mode 100644
index 0000000..efcd0be
--- /dev/null
+++ b/tests/icon/regression/o3_direct_replace.zc
@@ -0,0 +1,17 @@
+include rt;
+include run;
+include icon;
+// replace an o3 function and call it directly (entry via the patched prologue),
+// after warming the compiled region so the store must drop it.
+o3 int target() { return 1; }
+fn main() {
+ int i, s = 0;
+ for (i = 0; i < 100; i++) s += target();
+ rt.put_n(s); rt.put_c(' ');
+ let one = run.tokens("1"), two = run.tokens("2");
+ rt.put_n(icon.find_replace(target, one, two)); rt.put_c(' ');
+ s = 0;
+ for (i = 0; i < 100; i++) s += target();
+ rt.put_n(s); rt.put_c(10);
+ return 0;
+}
diff --git a/tests/icon/regression/o3_failed_keeps_old.expected b/tests/icon/regression/o3_failed_keeps_old.expected
new file mode 100644
index 0000000..68cd311
--- /dev/null
+++ b/tests/icon/regression/o3_failed_keeps_old.expected
@@ -0,0 +1 @@
+8 1 10 0 6 10
diff --git a/tests/icon/regression/o3_failed_keeps_old.zc b/tests/icon/regression/o3_failed_keeps_old.zc
new file mode 100644
index 0000000..f750a84
--- /dev/null
+++ b/tests/icon/regression/o3_failed_keeps_old.zc
@@ -0,0 +1,19 @@
+include rt;
+include run;
+include icon;
+typecheck on;
+// a rejected publication must leave the previous entry (and any o3 caller of it)
+// unchanged: status 6, still returning the last successfully published body.
+o3 int target() { return 4; }
+o3 int caller() { return target() + target(); }
+fn main() {
+ let four = run.tokens("4"), five = run.tokens("5");
+ rt.put_n(caller()); rt.put_c(' ');
+ rt.put_n(icon.find_replace(target, four, five)); rt.put_c(' ');
+ rt.put_n(caller()); rt.put_c(' ');
+ let bad_pat = run.tokens("return $int;"), bad_rep = run.tokens("return \"x\";");
+ rt.put_n(icon.find_replace(target, bad_pat, bad_rep)); rt.put_c(' ');
+ rt.put_n(icon.error()); rt.put_c(' ');
+ rt.put_n(caller()); rt.put_c(10);
+ return 0;
+}
diff --git a/tests/icon/regression/o3_repeated_replace.expected b/tests/icon/regression/o3_repeated_replace.expected
new file mode 100644
index 0000000..970ce07
--- /dev/null
+++ b/tests/icon/regression/o3_repeated_replace.expected
@@ -0,0 +1 @@
+21 1 24 1 27
diff --git a/tests/icon/regression/o3_repeated_replace.zc b/tests/icon/regression/o3_repeated_replace.zc
new file mode 100644
index 0000000..5cad477
--- /dev/null
+++ b/tests/icon/regression/o3_repeated_replace.zc
@@ -0,0 +1,16 @@
+include rt;
+include run;
+include icon;
+// repeated find_replace on an o3 callee must keep the o3 caller's published view
+// current (prologue coverage / generation guard), not a stale compiled stub.
+o3 int target() { return 7; }
+o3 int caller() { int s = 0; for (int i = 0; i < 3; i++) s += target(); return s; }
+fn main() {
+ let seven = run.tokens("7"), eight = run.tokens("8"), nine = run.tokens("9");
+ rt.put_n(caller()); rt.put_c(' ');
+ rt.put_n(icon.find_replace(target, seven, eight)); rt.put_c(' ');
+ rt.put_n(caller()); rt.put_c(' ');
+ rt.put_n(icon.find_replace(target, eight, nine)); rt.put_c(' ');
+ rt.put_n(caller()); rt.put_c(10);
+ return 0;
+}