From 56c34c752c9eb2bf6c6f47c17902ac0696273939 Mon Sep 17 00:00:00 2001 From: inglorion Date: Mon, 10 Jan 2011 12:02:15 +0100 Subject: [PATCH] Added test case for chained if --- test/Makefile | 6 +++--- test/else-if.out | 3 +++ test/else-if.voo | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test | 2 ++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 test/else-if.out create mode 100644 test/else-if.voo diff --git a/test/Makefile b/test/Makefile index abf0fc8..d091381 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,9 +3,9 @@ include ../Makefile.cfg NASM ?= nasm VOODOOC ?= env RUBYLIB=$(PWD)/../lib:$(RUBYLIB) ../bin/voodooc -TARGETS = at block bitwise bytes call div fact goto hello if many-vars mod \ - mul plusminus raw rotate set-byte set-word shift tail-calls vtable \ - 99bottles gcd +TARGETS = at block bitwise bytes call div else-if fact goto hello if \ + many-vars mod mul plusminus raw rotate set-byte set-word shift \ + tail-calls vtable 99bottles gcd all : $(TARGETS) diff --git a/test/else-if.out b/test/else-if.out new file mode 100644 index 0000000..047bcc3 --- /dev/null +++ b/test/else-if.out @@ -0,0 +1,3 @@ +-1 is less than 0 +0 is less than 1 +0 is equeal to 0 diff --git a/test/else-if.voo b/test/else-if.voo new file mode 100644 index 0000000..762c853 --- /dev/null +++ b/test/else-if.voo @@ -0,0 +1,57 @@ +#### Test program for chained if statements + + +section data + +align +equal: +string "%d is equeal to %d\n\x00" + +align +greater_than: +string "%d is greater than %d\n\x00" + +align +less_than: +string "%d is less than %d\n\x00" + + +section functions + +import printf +export main + +align +main: +function argc argv + let x -1 + let y 0 + let z 1 + + iflt x y + call printf less_than x y + else ifeq x y + call printf equal x y + else + call printf greater_than x y + end if + + ifgt y z + call printf greater_than y z + else ifeq y z + call printf equal y z + else + call printf less_than y z + end if + + iflt y y + call printf less_than y y + else ifeq y y + call printf equal y y + else + call printf greater_than y y + end if + + return 0 +end function + diff --git a/test/test b/test/test index feb7268..a67efc8 100755 --- a/test/test +++ b/test/test @@ -42,6 +42,8 @@ run_test1 at run_test1 block +run_test1 else-if + run_test1 if run_test1 goto -- 2.11.4.GIT