Added test cases for functions with many locals and/or many arguments.
[voodoo-lang.git] / test / test
bloba95f87d930d164bcbe7f063cc04ae6991977ef9a
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 call
39 run_test1 if
41 run_test1 goto
43 run_test2 fact 479001600
45 run_test1 bitwise
47 run_test1 plusminus
49 run_test1 many-vars
51 run_test1 mul
53 run_test1 div
55 run_test1 mod
57 run_test1 set-byte
59 run_test1 set-word
61 run_test1 vtable
63 run_test2 tail-calls ''
65 run_test1 99bottles
67 run_test1 gcd
69 printf 'test_output_name...'
70 $RUBY test_output_name.rb
71 [ $? -eq 0 ] || errors=$((errors + 1))
73 if [ $errors -eq 0 ]
74 then
75 echo All tests passed
76 else
77 echo "$errors tests failed"
78 exit 1