summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-12-07 17:16:33 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2019-12-07 17:16:33 -0500
commit27d66ee625ecbe80a2d24cceea627223c5748791 (patch)
tree2be801a5edeaf8d43d3f8c7a77266b7e99a4bb87 /tests
parent59f89ea233df72faf45147680c1816c48b52e8b9 (diff)
fixed a double free bug
Diffstat (limited to 'tests')
-rw-r--r--tests/arr/arr.toc16
1 files changed, 14 insertions, 2 deletions
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]);