summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Böhm <bb@xnull.de>2009-07-07 10:43:01 +0200
committerBenedikt Böhm <bb@xnull.de>2009-07-07 10:43:01 +0200
commit8582e3520ff487ea71e68a10fa8641fd95e74706 (patch)
tree6e8a84141d45b6bd4f1bfa494b1dbe7270627754
parent4ad083bf274a972ed7286b9b52179e30873aa830 (diff)
downloadswppy-8582e3520ff487ea71e68a10fa8641fd95e74706.tar.gz
swppy-8582e3520ff487ea71e68a10fa8641fd95e74706.tar.xz
swppy-8582e3520ff487ea71e68a10fa8641fd95e74706.zip
cleanup test code
-rwxr-xr-xcompiler1
-rw-r--r--test/ack.t15
-rw-r--r--test/fib.t (renamed from test/test1.t)4
-rw-r--r--test/ggt.t (renamed from test/test5.t)5
-rw-r--r--test/test2.t9
-rw-r--r--test/test3.t10
-rw-r--r--test/test4.t9
-rw-r--r--test/times2.t7
8 files changed, 28 insertions, 32 deletions
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/test1.t b/test/fib.t
index 12580bd..2a24f6d 100644
--- a/test/test1.t
+++ b/test/fib.t
@@ -6,10 +6,10 @@ fun fib[a]
end
# main function
-fun main[]
+fun main[num]
sum = 0
i = 0
- while (i < 10)
+ while (i < num)
sum = sum + call fib[i]
i = i + 1
end
diff --git a/test/test5.t b/test/ggt.t
index c6e786d..2eeb07a 100644
--- a/test/test5.t
+++ b/test/ggt.t
@@ -3,7 +3,10 @@ fun main[]
print x
y = call ggt2[30,40]
print y
- @x == y
+ if x == y
+ @0
+ end
+ @1
end
fun ggt1[x,y]
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/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