diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conformance/4-statements/uninit_array_elems_ok.zc | 11 | ||||
| -rw-r--r-- | tests/conformance/4-statements/uninit_array_fill_loop_ok.zc | 9 | ||||
| -rw-r--r-- | tests/conformance/4-statements/uninit_struct_fields_ok.zc | 13 | ||||
| -rw-r--r-- | tests/programs/bench_strings.zc | 2 | ||||
| -rw-r--r-- | tests/programs/bounds_body.zc | 2 |
5 files changed, 35 insertions, 2 deletions
diff --git a/tests/conformance/4-statements/uninit_array_elems_ok.zc b/tests/conformance/4-statements/uninit_array_elems_ok.zc new file mode 100644 index 0000000..00f4d17 --- /dev/null +++ b/tests/conformance/4-statements/uninit_array_elems_ok.zc @@ -0,0 +1,11 @@ +// expect: 6 +// spec 4.1.5: writing every element by constant index sets the array +include rt; +fn main() { + int[3] a; + a[0] = 1; a[1] = 2; a[2] = 3; + int s = 0; + for (int i = 0; i < 3; i++) s = s + a[i]; + rt.put_n(s); + return 0; +} diff --git a/tests/conformance/4-statements/uninit_array_fill_loop_ok.zc b/tests/conformance/4-statements/uninit_array_fill_loop_ok.zc new file mode 100644 index 0000000..3b017b9 --- /dev/null +++ b/tests/conformance/4-statements/uninit_array_fill_loop_ok.zc @@ -0,0 +1,9 @@ +// expect: 30 +// spec 4.1.5: a computed-index fill counts as setting the whole array +include rt; +fn main() { + int[4] a; + for (int i = 0; i < 4; i++) a[i] = i * 5; + rt.put_n(a[0] + a[1] + a[2] + a[3]); + return 0; +} diff --git a/tests/conformance/4-statements/uninit_struct_fields_ok.zc b/tests/conformance/4-statements/uninit_struct_fields_ok.zc new file mode 100644 index 0000000..a12fa71 --- /dev/null +++ b/tests/conformance/4-statements/uninit_struct_fields_ok.zc @@ -0,0 +1,13 @@ +// expect: 3/7/ +// spec 4.1.5: a written field may be read before the rest; writing every field sets the struct +include rt; +struct point { int x; int y; } +fn sum(point* q) { return q.x + q.y; } +fn main() { + point p; + p.x = 3; + rt.put_n(p.x); rt.put_c(10); + p.y = 4; + rt.put_n(sum(&p)); rt.put_c(10); + return 0; +} diff --git a/tests/programs/bench_strings.zc b/tests/programs/bench_strings.zc index 6f224db..c9fcdee 100644 --- a/tests/programs/bench_strings.zc +++ b/tests/programs/bench_strings.zc @@ -5,7 +5,7 @@ fn work() { let s = b"abcdefghijklmnopqrstuvwxyz0123456789"; let i, acc, n, t, part, k, reps, ch; ch = rt.get_c(); - reps = 0; + reps = 0; acc = 0; while (ch >= '0' && ch <= '9') { reps = reps * 10 + ch - '0'; ch = rt.get_c(); } while (reps > 0) { k = 0; acc = 0; n = rt.len_s(s); diff --git a/tests/programs/bounds_body.zc b/tests/programs/bounds_body.zc index ea838ac..d239802 100644 --- a/tests/programs/bounds_body.zc +++ b/tests/programs/bounds_body.zc @@ -4,7 +4,7 @@ include rt; // a loop proof only holds while the body leaves the index alone: here the body // moves i back below 0 once, so t[i] keeps its check and the access faults int main() { - int[4] t; int s = 0, once = 1; + int[4] t = {}; int s = 0, once = 1; for (int i = 0; i < 4; i++) { s = s + t[i]; if (once) { once = 0; i = -3000; } } rt.put_n(s); rt.put_c(10); return 0; |
