summary refs log tree commit diff
path: root/lisc/test
diff options
context:
space:
mode:
Diffstat (limited to 'lisc/test')
-rw-r--r--lisc/test/_alt.ssa (renamed from lisc/test/alt.ssa)0
-rw-r--r--lisc/test/_dragon.ssa (renamed from lisc/test/dragon.ssa)0
-rw-r--r--lisc/test/_fix1.ssa (renamed from lisc/test/fix1.ssa)0
-rw-r--r--lisc/test/_fix2.ssa (renamed from lisc/test/fix2.ssa)0
-rw-r--r--lisc/test/_fix3.ssa (renamed from lisc/test/fix3.ssa)0
-rw-r--r--lisc/test/_fix4.ssa (renamed from lisc/test/fix4.ssa)0
-rw-r--r--lisc/test/_live.ssa (renamed from lisc/test/live.ssa)0
-rw-r--r--lisc/test/_rpo.ssa (renamed from lisc/test/rpo.ssa)0
-rw-r--r--lisc/test/_spill1.ssa (renamed from lisc/test/spill.ssa)0
-rw-r--r--lisc/test/_spill2.ssa (renamed from lisc/test/spill1.ssa)0
-rw-r--r--lisc/test/_spill3.ssa (renamed from lisc/test/spill2.ssa)0
-rw-r--r--lisc/test/align.ssa6
-rw-r--r--lisc/test/collatz.ssa6
-rw-r--r--lisc/test/cprime.ssa10
-rw-r--r--lisc/test/cup.ssa2
-rw-r--r--lisc/test/dark.ssa6
-rw-r--r--lisc/test/double.ssa6
-rw-r--r--lisc/test/echo.ssa4
-rw-r--r--lisc/test/eucl.ssa6
-rw-r--r--lisc/test/euclc.ssa4
-rwxr-xr-xlisc/test/go.sh13
-rw-r--r--lisc/test/loop.ssa11
-rw-r--r--lisc/test/max.ssa6
-rw-r--r--lisc/test/prime.ssa6
-rw-r--r--lisc/test/puts10.ssa15
-rw-r--r--lisc/test/sum.ssa11
26 files changed, 94 insertions, 18 deletions
diff --git a/lisc/test/alt.ssa b/lisc/test/_alt.ssa
index 3f89e5e..3f89e5e 100644
--- a/lisc/test/alt.ssa
+++ b/lisc/test/_alt.ssa
diff --git a/lisc/test/dragon.ssa b/lisc/test/_dragon.ssa
index b169e1b..b169e1b 100644
--- a/lisc/test/dragon.ssa
+++ b/lisc/test/_dragon.ssa
diff --git a/lisc/test/fix1.ssa b/lisc/test/_fix1.ssa
index e89307f..e89307f 100644
--- a/lisc/test/fix1.ssa
+++ b/lisc/test/_fix1.ssa
diff --git a/lisc/test/fix2.ssa b/lisc/test/_fix2.ssa
index 89f236d..89f236d 100644
--- a/lisc/test/fix2.ssa
+++ b/lisc/test/_fix2.ssa
diff --git a/lisc/test/fix3.ssa b/lisc/test/_fix3.ssa
index 283e5a1..283e5a1 100644
--- a/lisc/test/fix3.ssa
+++ b/lisc/test/_fix3.ssa
diff --git a/lisc/test/fix4.ssa b/lisc/test/_fix4.ssa
index 181768d..181768d 100644
--- a/lisc/test/fix4.ssa
+++ b/lisc/test/_fix4.ssa
diff --git a/lisc/test/live.ssa b/lisc/test/_live.ssa
index fce4cb9..fce4cb9 100644
--- a/lisc/test/live.ssa
+++ b/lisc/test/_live.ssa
diff --git a/lisc/test/rpo.ssa b/lisc/test/_rpo.ssa
index a10c6b1..a10c6b1 100644
--- a/lisc/test/rpo.ssa
+++ b/lisc/test/_rpo.ssa
diff --git a/lisc/test/spill.ssa b/lisc/test/_spill1.ssa
index df5e4c2..df5e4c2 100644
--- a/lisc/test/spill.ssa
+++ b/lisc/test/_spill1.ssa
diff --git a/lisc/test/spill1.ssa b/lisc/test/_spill2.ssa
index d462d0b..d462d0b 100644
--- a/lisc/test/spill1.ssa
+++ b/lisc/test/_spill2.ssa
diff --git a/lisc/test/spill2.ssa b/lisc/test/_spill3.ssa
index cdfda2d..cdfda2d 100644
--- a/lisc/test/spill2.ssa
+++ b/lisc/test/_spill3.ssa
diff --git a/lisc/test/align.ssa b/lisc/test/align.ssa
index 9ac3f60..84d1fb9 100644
--- a/lisc/test/align.ssa
+++ b/lisc/test/align.ssa
@@ -8,3 +8,9 @@ function $test() {
 	storew %n, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 8 || a == -8); }
+# <<<
diff --git a/lisc/test/collatz.ssa b/lisc/test/collatz.ssa
index 3e9dc41..373ecac 100644
--- a/lisc/test/collatz.ssa
+++ b/lisc/test/collatz.ssa
@@ -53,3 +53,9 @@ function $test() {
 	storew %cmax, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 178); }
+# <<<
diff --git a/lisc/test/cprime.ssa b/lisc/test/cprime.ssa
index adc5e8a..af0f652 100644
--- a/lisc/test/cprime.ssa
+++ b/lisc/test/cprime.ssa
@@ -2,7 +2,7 @@
 # compiler from the C program
 # following in comments
 
-function $test() {
+function w $main() {
 @start
 	%v0 =l alloc8 4
 	%v1 =l alloc8 4
@@ -64,13 +64,11 @@ function $test() {
 	%v26 =w cnew %v25, 104743
 	jnz %v26, @L13, @L7
 @L13
-	storew 1, $a
-	ret
+	ret 1
 @L7
-	storew 0, $a
-	ret
+	ret 0
 @end
-	ret
+	ret 0
 }
 
 # int
diff --git a/lisc/test/cup.ssa b/lisc/test/cup.ssa
index 96649e6..013394f 100644
--- a/lisc/test/cup.ssa
+++ b/lisc/test/cup.ssa
@@ -12,6 +12,6 @@ function $test() {
 }
 
 # >>> driver
-# extern void test();
+# extern void test(void);
 # int main() { test(); return 0; }
 # <<<
diff --git a/lisc/test/dark.ssa b/lisc/test/dark.ssa
index b9ee038..5046af3 100644
--- a/lisc/test/dark.ssa
+++ b/lisc/test/dark.ssa
@@ -22,3 +22,9 @@ function $test(:magic %p) {
 @fin
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a = 2;
+# int main() { test(); return !(a == 5); }
+# <<<
diff --git a/lisc/test/double.ssa b/lisc/test/double.ssa
index 576ed04..d885d28 100644
--- a/lisc/test/double.ssa
+++ b/lisc/test/double.ssa
@@ -16,3 +16,9 @@ function $test() {
 	storew %i2, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 55); }
+# <<<
diff --git a/lisc/test/echo.ssa b/lisc/test/echo.ssa
index c67434f..d3c8a25 100644
--- a/lisc/test/echo.ssa
+++ b/lisc/test/echo.ssa
@@ -26,3 +26,7 @@ function w $main(w %argc, l %argv) {
 @end
 	ret 0
 }
+
+# >>> output
+# a b c
+# <<<
diff --git a/lisc/test/eucl.ssa b/lisc/test/eucl.ssa
index 527cfcf..f50fd2c 100644
--- a/lisc/test/eucl.ssa
+++ b/lisc/test/eucl.ssa
@@ -16,3 +16,9 @@ function $test() {
 	storew %a, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 1); }
+# <<<
diff --git a/lisc/test/euclc.ssa b/lisc/test/euclc.ssa
index b684fe7..c76db2f 100644
--- a/lisc/test/euclc.ssa
+++ b/lisc/test/euclc.ssa
@@ -23,3 +23,7 @@ function w $test() {
 	ret %t13
 }
 
+# >>> driver
+# extern int test(void);
+# int main() { return !(test() == 1); }
+# <<<
diff --git a/lisc/test/go.sh b/lisc/test/go.sh
index 7082db0..7326ecc 100755
--- a/lisc/test/go.sh
+++ b/lisc/test/go.sh
@@ -1,8 +1,5 @@
 #!/bin/sh
 
-QBE=./lisc
-CC=cc
-
 TMP=/tmp/qbe.zzzz
 
 DRV=$TMP.c
@@ -44,7 +41,7 @@ once() {
 
 	printf "$T... "
 
-	if ! $QBE $T -o $ASM 2> /dev/null
+	if ! ./lisc $T -o $ASM 2> /dev/null
 	then
 		echo "[qbe fail]"
 		return 1
@@ -60,7 +57,7 @@ once() {
 		LNK="$ASM"
 	fi
 
-	if ! $CC -o $BIN $LNK
+	if ! cc -o $BIN $LNK
 	then
 		echo "[cc fail]"
 		return 1
@@ -68,11 +65,11 @@ once() {
 
 	if test -s $OUT
 	then
-		$BIN | diff - $OUT > /dev/null
+		$BIN a b c | diff - $OUT > /dev/null
 		RET=$?
 		REASON="output"
 	else
-		$BIN
+		$BIN a b c
 		RET=$?
 		REASON="return"
 	fi
@@ -92,7 +89,7 @@ once() {
 case $1 in
 	"all")
 		F=0
-		for T in test/*
+		for T in test/[!_]*.ssa
 		do
 			once $T
 			F=`expr $F + $?`
diff --git a/lisc/test/loop.ssa b/lisc/test/loop.ssa
index 876b1b0..4877db9 100644
--- a/lisc/test/loop.ssa
+++ b/lisc/test/loop.ssa
@@ -5,12 +5,19 @@ function $test() {
 @start
 
 @loop
-	%s  =w phi @start 100, @loop %s1
-	%n  =w phi @start   0, @loop %n1
+	%s  =w phi @start   0, @loop %s1
+	%n  =w phi @start 100, @loop %n1
 	%n1 =w sub %n, 1
 	%s1 =w add %s, %n
 	jnz %n1, @loop, @end
 
 @end
+	storew %s1, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 5050); }
+# <<<
diff --git a/lisc/test/max.ssa b/lisc/test/max.ssa
index 91d4358..547e9d4 100644
--- a/lisc/test/max.ssa
+++ b/lisc/test/max.ssa
@@ -25,3 +25,9 @@ function $test() {
 	storew %max, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 200); }
+# <<<
diff --git a/lisc/test/prime.ssa b/lisc/test/prime.ssa
index 03580eb..12d0273 100644
--- a/lisc/test/prime.ssa
+++ b/lisc/test/prime.ssa
@@ -24,3 +24,9 @@ function $test() {
 	storew %p, $a
 	ret
 }
+
+# >>> driver
+# extern void test(void);
+# int a;
+# int main() { test(); return !(a == 104743); }
+# <<<
diff --git a/lisc/test/puts10.ssa b/lisc/test/puts10.ssa
index dad4f82..1dcf227 100644
--- a/lisc/test/puts10.ssa
+++ b/lisc/test/puts10.ssa
@@ -1,4 +1,4 @@
-function $test() {
+function $main() {
 @start
 	%y  =l alloc4 4
 	%y1 =l add %y, 1
@@ -14,3 +14,16 @@ function $test() {
 @end
 	ret
 }
+
+# >>> output
+# 0
+# 1
+# 2
+# 3
+# 4
+# 5
+# 6
+# 7
+# 8
+# 9
+# <<<
diff --git a/lisc/test/sum.ssa b/lisc/test/sum.ssa
index aa05da8..266054e 100644
--- a/lisc/test/sum.ssa
+++ b/lisc/test/sum.ssa
@@ -18,3 +18,14 @@ function w $sum(l %arr, w %num) {
 @end
 	ret %s0
 }
+
+# >>> driver
+# extern int sum(int *, int);
+# int arr[] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 };
+# #define N sizeof arr / sizeof arr[0]
+# int main() {
+# 	int i, s;
+# 	for (s=i=0; i<N; i++) s+=arr[i];
+# 	return !(sum(arr, N) == s);
+# }
+# <<<