From e5e1f10c8795f7bb0e94c40081f1be176dde2a96 Mon Sep 17 00:00:00 2001 From: Robbert Haarman Date: Sat, 10 Jan 2009 17:22:09 +0100 Subject: [PATCH] Added test tail-calls. --- test/Makefile | 2 +- test/tail-calls.voo | 21 +++++++++++++++++++++ test/test | 5 ++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/tail-calls.voo diff --git a/test/Makefile b/test/Makefile index 29c97fd..ab3e65f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ NASM = nasm VOODOOC = env RUBYLIB=../src:$(RUBYLIB) ../src/voodooc -TARGETS = hello fact +TARGETS = hello fact tail-calls all : $(TARGETS) diff --git a/test/tail-calls.voo b/test/tail-calls.voo new file mode 100644 index 0000000..338f5f6 --- /dev/null +++ b/test/tail-calls.voo @@ -0,0 +1,21 @@ +section ".data" + +section ".text" +import puts +export main + +tailtest: +function n + if n + set n sub n 1 + tail-call tailtest n + else + return 0 + end if +end function + +main: +function argc argv + call tailtest -1 + return 0 +end function diff --git a/test/test b/test/test index c50d3f1..c41f41d 100755 --- a/test/test +++ b/test/test @@ -8,7 +8,8 @@ errors=0 run_test() { printf '%s...' "$1" output=`$2` - if [ "$output" = "$3" ] + s=$? + if [ $s -eq 0 -a "$output" = "$3" ] then echo pass else @@ -21,6 +22,8 @@ run_test hello ./hello "Hello, world!" run_test fact ./fact 479001600 +run_test tail-calls ./tail-calls '' + if [ $errors -eq 0 ] then echo All tests passed -- 2.11.4.GIT