From 8582e3520ff487ea71e68a10fa8641fd95e74706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 7 Jul 2009 10:43:01 +0200 Subject: cleanup test code --- compiler | 1 - test/ack.t | 15 +++++++++++++++ test/fib.t | 18 ++++++++++++++++++ test/ggt.t | 30 ++++++++++++++++++++++++++++++ test/test1.t | 18 ------------------ test/test2.t | 9 --------- test/test3.t | 10 ---------- test/test4.t | 9 --------- test/test5.t | 27 --------------------------- test/times2.t | 7 +++++++ 10 files changed, 70 insertions(+), 74 deletions(-) create mode 100644 test/ack.t create mode 100644 test/fib.t create mode 100644 test/ggt.t delete mode 100644 test/test1.t delete mode 100644 test/test2.t delete mode 100644 test/test3.t delete mode 100644 test/test4.t delete mode 100644 test/test5.t create mode 100644 test/times2.t diff --git a/compiler b/compiler index 6500032..15f38bc 100755 --- a/compiler +++ b/compiler @@ -8,7 +8,6 @@ python __init__.py < ${TESTDIR}/$1.t > ${TESTDIR}/$1.S pushd emu >/dev/null make ./riscas ${TESTDIR}/$1.S ${TESTDIR}/$1.bin -./risci ${TESTDIR}/$1.bin ret=$? popd >/dev/null diff --git a/test/ack.t b/test/ack.t new file mode 100644 index 0000000..f9d892c --- /dev/null +++ b/test/ack.t @@ -0,0 +1,15 @@ +fun main[n,m] + print call ack[n,m] +end + +fun ack[n,m] + if n == 0 + @m + 1 + else + if m == 0 + @call ack[n-1, 1] + else + @call ack[n-1, call ack[n, m-1]] + end + end +end diff --git a/test/fib.t b/test/fib.t new file mode 100644 index 0000000..2a24f6d --- /dev/null +++ b/test/fib.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[num] + sum = 0 + i = 0 + while (i < num) + sum = sum + call fib[i] + i = i + 1 + end + print sum + @0 +end diff --git a/test/ggt.t b/test/ggt.t new file mode 100644 index 0000000..2eeb07a --- /dev/null +++ b/test/ggt.t @@ -0,0 +1,30 @@ +fun main[] + x = call ggt1[30,40] + print x + y = call ggt2[30,40] + print y + if x == y + @0 + end + @1 +end + +fun ggt1[x,y] + while x != y + if x > y + x = x - y + else + y = y - x + end + end + @x +end + +fun ggt2[a,b] + while b + x = a + a = b + b = x % b + end + @a +end diff --git a/test/test1.t b/test/test1.t deleted file mode 100644 index 12580bd..0000000 --- a/test/test1.t +++ /dev/null @@ -1,18 +0,0 @@ -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 - print sum - @0 -end diff --git a/test/test2.t b/test/test2.t deleted file mode 100644 index 8a19e95..0000000 --- a/test/test2.t +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 682f707..0000000 --- a/test/test3.t +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7cb19ff..0000000 --- a/test/test4.t +++ /dev/null @@ -1,9 +0,0 @@ -fun times2[n] - @n*2 -end - -fun main[] - n = 10 + 5 - res = call times2[n] - @res -end diff --git a/test/test5.t b/test/test5.t deleted file mode 100644 index c6e786d..0000000 --- a/test/test5.t +++ /dev/null @@ -1,27 +0,0 @@ -fun main[] - x = call ggt1[30,40] - print x - y = call ggt2[30,40] - print y - @x == y -end - -fun ggt1[x,y] - while x != y - if x > y - x = x - y - else - y = y - x - end - end - @x -end - -fun ggt2[a,b] - while b - x = a - a = b - b = x % b - end - @a -end diff --git a/test/times2.t b/test/times2.t new file mode 100644 index 0000000..723bea6 --- /dev/null +++ b/test/times2.t @@ -0,0 +1,7 @@ +fun times2[n] + @n*2 +end + +fun main[n] + @call times2[n] +end -- cgit v1.2.3