diff options
-rw-r--r-- | test/test1.t | 18 | ||||
-rw-r--r-- | test/test2.t | 9 | ||||
-rw-r--r-- | test/test3.t | 10 | ||||
-rw-r--r-- | test/test4.t | 9 |
4 files changed, 46 insertions, 0 deletions
diff --git a/test/test1.t b/test/test1.t new file mode 100644 index 0000000..1b48c0d --- /dev/null +++ b/test/test1.t @@ -0,0 +1,18 @@ +fun fib[a] + if a < 2 + @1 + end + @( call fib[a-1] + call fib[a-2] ) +end + +# main function +fun main[] + sum = 0 + i = 0 + while (i < 10) + sum = sum + call fib[i] + i = i + 1 + end + call fib[3] + @sum +end diff --git a/test/test2.t b/test/test2.t new file mode 100644 index 0000000..8a19e95 --- /dev/null +++ b/test/test2.t @@ -0,0 +1,9 @@ +fun main[] + sum = 0 + i = (sum + 10) * 5 + while (i + 3 < 10) + sum = sum + call fib[i] + i = i + 1 + end + @sum +end diff --git a/test/test3.t b/test/test3.t new file mode 100644 index 0000000..682f707 --- /dev/null +++ b/test/test3.t @@ -0,0 +1,10 @@ +fun main[] + a = 3 + b = 5 + if (a > b) + c = 1 + else + c = 0 + end + @c +end diff --git a/test/test4.t b/test/test4.t new file mode 100644 index 0000000..7cb19ff --- /dev/null +++ b/test/test4.t @@ -0,0 +1,9 @@ +fun times2[n] + @n*2 +end + +fun main[] + n = 10 + 5 + res = call times2[n] + @res +end |