diff options
Diffstat (limited to 'tests/programs/arrays.zc')
| -rw-r--r-- | tests/programs/arrays.zc | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/programs/arrays.zc b/tests/programs/arrays.zc index a8a12bf..b1fa43b 100644 --- a/tests/programs/arrays.zc +++ b/tests/programs/arrays.zc @@ -1,23 +1,26 @@ +namespace; +include rt; + // growable arrays and fixed ones struct point { int x, y; }; fn main() { - let before = live_objects(); + let before = rt.live_objects(); { - []int a = new([]int); + int[?] a = rt.new(int[?]); for (int i = 0; i < 100; i++) push(a, i * i); - put_n(len(a)); put_c(' '); put_n(cap(a)); put_c(' '); put_n(a[99]); put_c(' '); - put_n(pop(a)); put_c(' '); put_n(len(a)); put_c(' '); - resize(a, 3); put_n(len(a)); put_c(' '); put_n(a[2]); put_c(' '); - fixed []int f = new(fixed []int, 5); - f[4] = 7; put_n(f[4] + len(f)); put_c(' '); - []point ps = new([]point, 2); - ps[1].y = 9; resize(ps, 10); put_n(ps[1].y + len(ps)); put_c(' '); - [8]int st; put_n(len(st)); put_c(' '); - []point* owned = new([]point*); - for (int i = 0; i < 20; i++) { point* p = new(point); p.x = i; push(owned, d*p); } - put_n(owned[19].x); put_c(' '); - put_n(live_objects() - before); put_c(10); + rt.put_n(len(a)); rt.put_c(' '); rt.put_n(cap(a)); rt.put_c(' '); rt.put_n(a[99]); rt.put_c(' '); + rt.put_n(pop(a)); rt.put_c(' '); rt.put_n(len(a)); rt.put_c(' '); + resize(a, 3); rt.put_n(len(a)); rt.put_c(' '); rt.put_n(a[2]); rt.put_c(' '); + fixed int[?] f = rt.new(fixed int[?], 5); + f[4] = 7; rt.put_n(f[4] + len(f)); rt.put_c(' '); + point[?] ps = rt.new(point[?], 2); + ps[1].y = 9; resize(ps, 10); rt.put_n(ps[1].y + len(ps)); rt.put_c(' '); + int[8] st; rt.put_n(len(st)); rt.put_c(' '); + point*[?] owned = rt.new(point*[?]); + for (int i = 0; i < 20; i++) { point* p = rt.new(point); p.x = i; push(owned, d*p); } + rt.put_n(owned[19].x); rt.put_c(' '); + rt.put_n(rt.live_objects() - before); rt.put_c(10); } - put_n(live_objects() - before); put_c(10); + rt.put_n(rt.live_objects() - before); rt.put_c(10); return 0; } |
