From 27d66ee625ecbe80a2d24cceea627223c5748791 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 7 Dec 2019 17:16:33 -0500 Subject: fixed a double free bug --- tests/arr/arr.toc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/arr/arr.toc b/tests/arr/arr.toc index a999512..4cabd9e 100644 --- a/tests/arr/arr.toc +++ b/tests/arr/arr.toc @@ -28,6 +28,18 @@ arr_add ::= fn(t :: Type, a : &Arr(t), x : t) { a.len += 1; }; +square ::= fn(t :: Type, x : t) t { + a : Arr(t); + each i := 1,2..2*x-1 { + arr_add(t, &a, i); + }; + sum := 0 as t; + each i := 0..a.len-1 { + sum += a.data[i]; + }; + sum +}; + ArrInt ::= Arr(int); @@ -39,8 +51,8 @@ main ::= fn() { arr : ArrInt; farr : Arr(float); each i := 1..100 { - arr_add(int, &arr, inc(int, i*i)); - arr_add(float, &farr, inc(float, (i*i) as float)); + arr_add(int, &arr, inc(int, square(int, i))); + arr_add(float, &farr, inc(float, square(float, i as float))); } each i := 0..arr.len - 1 { puti(arr.data[i]); -- cgit v1.2.3