From 8f5269fffcc4a9226459e82abfaff434c27f97e9 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 14 Feb 2010 23:12:38 -0800 Subject: [PATCH] add tests for boolean and bitwise ops --- test/Makefile | 12 +++++++++++- test/test_and.code | 5 +++++ test/test_bit_ops.code | 5 +++++ test/test_or.code | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/test_and.code create mode 100644 test/test_bit_ops.code create mode 100644 test/test_or.code diff --git a/test/Makefile b/test/Makefile index a140f8e..7125a92 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ ifeq ($(BINFORMAT), bin) @echo " Your platform, " $(PLATFORM) ", is unsupported." endif -all: lt gt ge le eq neq if while until repeat for do break print big huge +all: lt gt ge le eq neq or and if while until repeat for do break print big huge @true lt: test.rb test_lt.code @@ -62,10 +62,20 @@ big: test.rb test_big.code huge: test.rb test_huge.code @./test.rb huge $(BINFORMAT) +or: test.rb test_or.code + @./test.rb or $(BINFORMAT) + +and: test.rb test_and.code + @./test.rb and $(BINFORMAT) + +bit_ops: test.rb test_bit_ops.code + @./test.rb bit_ops $(BINFORMAT) + clean: @rm -f test*.asm test*.o @rm -f test_big test_lt test_gt test_ge test_le test_eq test_neq @rm -f test_while test_if test_until test_repeat test_do @rm -f test_for test_break test_print test_huge + @rm -f test_and test_or test_bit_ops .PHONY: clean \ No newline at end of file diff --git a/test/test_and.code b/test/test_and.code new file mode 100644 index 0000000..ead2c97 --- /dev/null +++ b/test/test_and.code @@ -0,0 +1,5 @@ +a = 0 && 0 +b = 0 && 1 +c = 1 && 0 +d = 1 && 1 +exit_code = !(a == 0 && b == 0 && c == 0 && d) diff --git a/test/test_bit_ops.code b/test/test_bit_ops.code new file mode 100644 index 0000000..6317965 --- /dev/null +++ b/test/test_bit_ops.code @@ -0,0 +1,5 @@ +a = 4 | 7 # 7 +b = 4 ^ 7 # 3 +c = 4 & 7 # 4 +exitcode = a - b - c + diff --git a/test/test_or.code b/test/test_or.code new file mode 100644 index 0000000..bbfb4ed --- /dev/null +++ b/test/test_or.code @@ -0,0 +1,5 @@ +a = 0 || 0 +b = 0 || 1 +c = 1 || 0 +d = 1 || 1 +exit_code = !(a ==0 && b && c && d)