diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-06-21 17:47:55 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-06-21 17:47:55 -0400 |
commit | 692d13cc1a6fda2776d0ad0b34e9fbff0bc2c55c (patch) | |
tree | cf14f8fc4c531a08512050b5bd4f9b3d01b87ad8 /tests | |
parent | a03de99b63cd76edd191de05d85147518842cafc (diff) |
everything now working with blocks not returning values
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arr.toc | 70 | ||||
-rw-r--r-- | tests/arr2.toc | 70 | ||||
-rw-r--r-- | tests/arr3.toc | 62 | ||||
-rw-r--r-- | tests/arrs_slices.toc | 2 | ||||
-rw-r--r-- | tests/defer.toc | 4 | ||||
-rw-r--r-- | tests/misc.toc | 4 | ||||
-rw-r--r-- | tests/new.toc | 2 | ||||
-rw-r--r-- | tests/nms.toc | 2 | ||||
-rw-r--r-- | tests/printf.toc | 2 | ||||
-rw-r--r-- | tests/sizeof.toc | 4 | ||||
-rw-r--r-- | tests/varargs.toc | 4 |
11 files changed, 113 insertions, 113 deletions
diff --git a/tests/arr.toc b/tests/arr.toc index afcf340..d85b06d 100644 --- a/tests/arr.toc +++ b/tests/arr.toc @@ -3,55 +3,55 @@ // it would be nice if Arr.data.len == Arr.len (: but this will require some C code... Arr ::= fn (t :: Type) Type { - struct { - data : []t; - len, cap : int; - } + return struct { + data : []t; + len, cap : int; + }; }; arr_add ::= fn(t :: Type, a : &Arr(t), x : t) { - if a.len >= a.cap { - a.cap = a.cap * 2 + 2; - new_data := news(t, a.cap); - for i := 0..a.len-1 { - new_data[i] = a.data[i]; - } - a.data = new_data; + if a.len >= a.cap { + a.cap = a.cap * 2 + 2; + new_data := news(t, a.cap); + for i := 0..a.len-1 { + new_data[i] = a.data[i]; } - a.data[a.len] = x; - a.len += 1; + a.data = new_data; + } + a.data[a.len] = x; + a.len += 1; }; square ::= fn(t :: Type, x : t) t { - a : Arr(t); - for i := 1,2..2*x-1 { - arr_add(t, &a, i); - }; - sum := 0 as t; - for i := 0..a.len-1 { - sum += a.data[i]; - }; - sum + a : Arr(t); + for i := 1,2..2*x-1 { + arr_add(t, &a, i); + }; + sum := 0 as t; + for i := 0..a.len-1 { + sum += a.data[i]; + }; + return sum; }; ArrInt ::= Arr(int); inc ::= fn(t :: Type, x : t) t { - x + 1 + return x + 1; }; main ::= fn() { - arr : ArrInt; - farr : Arr(float); - for i := 1..100 { - arr_add(int, &arr, inc(int, square(int, i))); - arr_add(float, &farr, inc(float, square(float, i as float))); - } - for i := 0..arr.len - 1 { - puti(arr.data[i]); - } - for i := 0..farr.len - 1 { - putf(farr.data[i]); - } + arr : ArrInt; + farr : Arr(float); + for i := 1..100 { + arr_add(int, &arr, inc(int, square(int, i))); + arr_add(float, &farr, inc(float, square(float, i as float))); + } + for i := 0..arr.len - 1 { + puti(arr.data[i]); + } + for i := 0..farr.len - 1 { + putf(farr.data[i]); + } }; diff --git a/tests/arr2.toc b/tests/arr2.toc index 4d8ca82..7e29a95 100644 --- a/tests/arr2.toc +++ b/tests/arr2.toc @@ -3,55 +3,55 @@ // it would be nice if Arr.data.len == Arr.len (: but this will require some C code... Arr ::= fn (t :: Type) Type { - struct { - data : []t; - len, cap : int; - } + return struct { + data : []t; + len, cap : int; + }; }; arr_add ::= fn(t ::=, a : &Arr(t), x : t) { - if a.len >= a.cap { - a.cap = a.cap * 2 + 2; - new_data := news(t, a.cap); - for i := 0..a.len-1 { - new_data[i] = a.data[i]; - } - a.data = new_data; + if a.len >= a.cap { + a.cap = a.cap * 2 + 2; + new_data := news(t, a.cap); + for i := 0..a.len-1 { + new_data[i] = a.data[i]; } - a.data[a.len] = x; - a.len += 1; + a.data = new_data; + } + a.data[a.len] = x; + a.len += 1; }; square ::= fn(t ::=, x : t) t { - a : Arr(t); - for i := 1,2..2*x-1 { - arr_add(&a, i); - }; - sum := 0 as t; - for i := 0..a.len-1 { - sum += a.data[i]; - }; - sum + a : Arr(t); + for i := 1,2..2*x-1 { + arr_add(&a, i); + }; + sum := 0 as t; + for i := 0..a.len-1 { + sum += a.data[i]; + }; + return sum; }; // ArrInt ::= Arr(int); inc ::= fn(t ::=, x : t) t { - x + 1 + return x + 1; }; main ::= fn() { - arr : Arr(int); - farr : Arr(float); - for i := 1..100 { - arr_add(&arr, inc(square(i))); - arr_add(&farr, inc(square(i as float))); - } - for i := 0..arr.len - 1 { - puti(arr.data[i]); - } - for i := 0..farr.len - 1 { - putf(farr.data[i]); - } + arr : Arr(int); + farr : Arr(float); + for i := 1..100 { + arr_add(&arr, inc(square(i))); + arr_add(&farr, inc(square(i as float))); + } + for i := 0..arr.len - 1 { + puti(arr.data[i]); + } + for i := 0..farr.len - 1 { + putf(farr.data[i]); + } }; diff --git a/tests/arr3.toc b/tests/arr3.toc index 25c5554..246be65 100644 --- a/tests/arr3.toc +++ b/tests/arr3.toc @@ -3,50 +3,50 @@ arr_add ::= fn(t ::=, a : &Arr(t), x : t) { - if a.len >= a.cap { - a.cap = a.cap * 2 + 2; - new_data := news(t, a.cap); - for i := 0..a.len-1 { - new_data[i] = a.data[i]; - } - a.data = new_data; + if a.len >= a.cap { + a.cap = a.cap * 2 + 2; + new_data := news(t, a.cap); + for i := 0..a.len-1 { + new_data[i] = a.data[i]; } - a.data[a.len] = x; - a.len += 1; + a.data = new_data; + } + a.data[a.len] = x; + a.len += 1; }; square ::= fn(t ::=, x : t) t { - a : Arr(t); - for i := 1,2..2*x-1 { - arr_add(&a, i); - }; - sum := 0 as t; - for i := 0..a.len-1 { - sum += a.data[i]; - }; - sum + a : Arr(t); + for i := 1,2..2*x-1 { + arr_add(&a, i); + }; + sum := 0 as t; + for i := 0..a.len-1 { + sum += a.data[i]; + }; + return sum; }; ArrInt ::= Arr(int); inc ::= fn(t ::=, x : t) t { - x + 1 + return x + 1; }; main ::= fn() { - arr : ArrInt; - farr : Arr(float); - for i := 1..100 { - arr_add(&arr, inc(square(i))); - arr_add(&farr, inc(square(i as float))); - } - for i := 0..arr.len - 1 { - puti(arr.data[i]); - } - for i := 0..farr.len - 1 { - puti(farr.data[i] as int); - } + arr : ArrInt; + farr : Arr(float); + for i := 1..100 { + arr_add(&arr, inc(square(i))); + arr_add(&farr, inc(square(i as float))); + } + for i := 0..arr.len - 1 { + puti(arr.data[i]); + } + for i := 0..farr.len - 1 { + puti(farr.data[i] as int); + } }; Arr ::= struct (t :: Type) { diff --git a/tests/arrs_slices.toc b/tests/arrs_slices.toc index dc7526d..fce8816 100644 --- a/tests/arrs_slices.toc +++ b/tests/arrs_slices.toc @@ -36,7 +36,7 @@ thing ::= fn() int { defer dels(bar); fill_slice(&bar); b := sum_slice(&bar); - a+b + return a+b; } main ::= fn() { diff --git a/tests/defer.toc b/tests/defer.toc index 07ef9f7..e1262f0 100644 --- a/tests/defer.toc +++ b/tests/defer.toc @@ -7,14 +7,14 @@ plusone ::= fn(n : int) x := n { same ::= fn(n : int) int { x := n; defer x += 1; - x + return x; } thing1 ::= fn() (int, int) { x := 5; y := 6; defer x += 1; - x, y + return x, y; } thing2 ::= fn() x := 5, y := 6 { diff --git a/tests/misc.toc b/tests/misc.toc index 3673a07..04932e8 100644 --- a/tests/misc.toc +++ b/tests/misc.toc @@ -3,7 +3,7 @@ main ::= fn() { x ::= 3; #if x > 2 { - io.puts("Hello!"); + io.puts("Hello!"); } else { foo("yes"); } @@ -17,7 +17,7 @@ main ::= fn() { for x := a { total += x; } - total + return total; }; mk_arr ::= fn(x:int, y:int, z:int) a:[3]int { diff --git a/tests/new.toc b/tests/new.toc index 790a115..8535a5e 100644 --- a/tests/new.toc +++ b/tests/new.toc @@ -17,7 +17,7 @@ calculation ::= fn() int { total += *i; mem.del(i); mem.dels(ns); - total + return total; } main ::= fn() { diff --git a/tests/nms.toc b/tests/nms.toc index 32c2955..f5aa688 100644 --- a/tests/nms.toc +++ b/tests/nms.toc @@ -4,7 +4,7 @@ io ::= nms { n ::= nms { x := 1; - counter ::= fn() int { x += 1; x }; + counter ::= fn() int { x += 1; return x; }; }; diff --git a/tests/printf.toc b/tests/printf.toc index ede3012..a6ef348 100644 --- a/tests/printf.toc +++ b/tests/printf.toc @@ -18,7 +18,7 @@ tprintf_valid ::= fn(fmt :: []char, nargs: int) bool { } } } - count == nargs + return count == nargs; }; diff --git a/tests/sizeof.toc b/tests/sizeof.toc index 5a97985..a12648e 100644 --- a/tests/sizeof.toc +++ b/tests/sizeof.toc @@ -6,8 +6,8 @@ Point3D ::= struct { calculation ::= fn() int { p: Point3D; - (#sizeof Point3D) * (#sizeof typeof p) * (sizeof Point3D) * (sizeof typeof p) - * (#alignof Point3D) * (#alignof typeof p) * (alignof Point3D) * (alignof typeof p) + return (#sizeof Point3D) * (#sizeof typeof p) * (sizeof Point3D) * (sizeof typeof p) + * (#alignof Point3D) * (#alignof typeof p) * (alignof Point3D) * (alignof typeof p); } main ::= fn() { diff --git a/tests/varargs.toc b/tests/varargs.toc index 0885da4..ff315c6 100644 --- a/tests/varargs.toc +++ b/tests/varargs.toc @@ -9,7 +9,7 @@ sum ::= fn(x: ..) int { for a, i := x { total += a + i - i + 1; } - total - x.len + return total - x.len; }; sumc ::= fn(x:: ..) int { @@ -17,7 +17,7 @@ sumc ::= fn(x:: ..) int { for a, i := x { total += a + i - i + 1; } - total - x.len + return total - x.len; }; do_printing ::= fn(x::..) { |