Added test case for chained if
[voodoo-lang.git] / test / test
bloba67efc83b3771dde9bfa8893afe74f836ca960c2
1 #! /bin/sh
3 ### Run tests
5 errors=0
7 [ -n "$RUBY" ] || RUBY=ruby
9 # run_test program expected_output
10 run_test() {
11 printf '%s...' "$1"
12 output=`$2`
13 s=$?
14 if [ $s -ne 0 ]
15 then
16 echo "FAIL: exit status is $s"
17 errors=$((errors + 1))
18 elif [ "$output" != "$3" ]
19 then
20 echo "FAIL: wrong output"
21 errors=$((errors + 1))
22 else
23 echo pass
27 run_test2() {
28 run_test "$1" "./$1" "$2"
31 run_test1() {
32 run_test2 "$1" "`cat $1.out`"
35 run_test2 hello "Hello, world!"
37 run_test1 bytes
39 run_test1 call
41 run_test1 at
43 run_test1 block
45 run_test1 else-if
47 run_test1 if
49 run_test1 goto
51 run_test2 fact 479001600
53 run_test1 bitwise
55 run_test1 plusminus
57 run_test1 many-vars
59 run_test1 mul
61 run_test1 div
63 run_test1 mod
65 run_test1 raw
67 run_test1 rotate
69 run_test1 set-byte
71 run_test1 set-word
73 run_test1 shift
75 run_test1 vtable
77 run_test2 tail-calls ''
79 run_test1 99bottles
81 run_test1 gcd
83 printf 'test_output_name...'
84 $RUBY test_output_name.rb
85 [ $? -eq 0 ] || errors=$((errors + 1))
87 if [ $errors -eq 0 ]
88 then
89 echo All tests passed
90 else
91 echo "$errors tests failed"
92 exit 1