Added test case for call expression.
[voodoo-lang.git] / test / test
blob8fa82dd0c22909cec334c3730518bd4a0d6ada9a
1 #! /bin/sh
3 ### Run tests
5 errors=0
7 # run_test program expected_output
8 run_test() {
9 printf '%s...' "$1"
10 output=`$2`
11 s=$?
12 if [ $s -ne 0 ]
13 then
14 echo "FAIL: exit status is $s"
15 errors=$((errors + 1))
16 elif [ "$output" != "$3" ]
17 then
18 echo "FAIL: wrong output"
19 errors=$((errors + 1))
20 else
21 echo pass
25 run_test2() {
26 run_test "$1" "./$1" "$2"
29 run_test1() {
30 run_test2 "$1" "`cat $1.out`"
33 run_test2 hello "Hello, world!"
35 run_test1 call
37 run_test1 if
39 run_test1 goto
41 run_test2 fact 479001600
43 run_test1 bitwise
45 run_test1 plusminus
47 run_test1 mul
49 run_test1 div
51 run_test1 mod
53 run_test1 set-byte
55 run_test1 set-word
57 run_test1 vtable
59 run_test2 tail-calls ''
61 if [ $errors -eq 0 ]
62 then
63 echo All tests passed
64 else
65 echo "$errors tests failed"
66 exit 1