summaryrefslogtreecommitdiffstats
path: root/stacker/test
diff options
context:
space:
mode:
Diffstat (limited to 'stacker/test')
-rw-r--r--stacker/test/Makefile61
-rw-r--r--stacker/test/abs.st6
-rw-r--r--stacker/test/add.st7
-rw-r--r--stacker/test/and.st7
-rw-r--r--stacker/test/decr.st6
-rw-r--r--stacker/test/div.st6
-rw-r--r--stacker/test/drop.st6
-rw-r--r--stacker/test/drop2.st7
-rw-r--r--stacker/test/dup.st8
-rw-r--r--stacker/test/dup2.st7
-rw-r--r--stacker/test/eq.st6
-rw-r--r--stacker/test/false.st6
-rw-r--r--stacker/test/ge.st7
-rw-r--r--stacker/test/gt.st6
-rw-r--r--stacker/test/incr.st6
-rw-r--r--stacker/test/le.st7
-rw-r--r--stacker/test/lt.st7
-rw-r--r--stacker/test/max.st7
-rw-r--r--stacker/test/memory.st10
-rw-r--r--stacker/test/min.st7
-rw-r--r--stacker/test/mod.st6
-rw-r--r--stacker/test/mul.st6
-rw-r--r--stacker/test/ne.st6
-rw-r--r--stacker/test/neg.st6
-rw-r--r--stacker/test/nip.st6
-rw-r--r--stacker/test/nip2.st9
-rw-r--r--stacker/test/or.st7
-rw-r--r--stacker/test/out_chr.st5
-rw-r--r--stacker/test/out_num.st5
-rw-r--r--stacker/test/out_str.st5
-rw-r--r--stacker/test/over.st9
-rw-r--r--stacker/test/over2.st14
-rw-r--r--stacker/test/pick.st9
-rw-r--r--stacker/test/recurse.st7
-rw-r--r--stacker/test/return.st8
-rw-r--r--stacker/test/roll.st5
-rw-r--r--stacker/test/rot.st9
-rw-r--r--stacker/test/rot2.st14
-rw-r--r--stacker/test/rrot.st12
-rw-r--r--stacker/test/rrot2.st14
-rwxr-xr-xstacker/test/runtests19
-rw-r--r--stacker/test/select.st7
-rw-r--r--stacker/test/shl.st7
-rw-r--r--stacker/test/shr.st7
-rw-r--r--stacker/test/space.st5
-rw-r--r--stacker/test/star_slash.st6
-rw-r--r--stacker/test/sub.st6
-rw-r--r--stacker/test/swap.st9
-rw-r--r--stacker/test/swap2.st10
-rw-r--r--stacker/test/tab.st5
-rw-r--r--stacker/test/testing.st5
-rw-r--r--stacker/test/true.st6
-rw-r--r--stacker/test/tuck.st11
-rw-r--r--stacker/test/tuck2.st14
-rw-r--r--stacker/test/while.st8
-rw-r--r--stacker/test/xor.st6
56 files changed, 483 insertions, 0 deletions
diff --git a/stacker/test/Makefile b/stacker/test/Makefile
new file mode 100644
index 00000000000..52112cba200
--- /dev/null
+++ b/stacker/test/Makefile
@@ -0,0 +1,61 @@
+##===- projects/Stacker/test/Makefile ----------------------*- Makefile -*-===##
+#
+# This is the makefile that tests the various facilities of the Stacker language
+#
+##===----------------------------------------------------------------------===##
+
+#
+# Indicates our relative path to the top of the project's root directory.
+#
+LEVEL = ../
+
+#
+# Directories that need to be built.
+#
+DIRS =
+
+#
+# Include the Master Makefile that knows how to build all.
+#
+include $(LEVEL)/Makefile.common
+
+LOGIC_TESTS = eq ne le ge gt lt false true
+BITWISE_TESTS = shl shr xor or and
+ARITHMETIC_TESTS = abs neg add sub mul div mod star_slash incr decr min max
+STACK_TESTS = drop drop2 nip nip2 dup dup2 swap swap2 over over2 rot rot2 \
+ rrot rrot2 tuck tuck2 roll pick select
+MEMORY_TESTS = memory
+CONTROL_TESTS = while return
+IO_TESTS = space tab out_chr out_num out_str
+
+TESTS = $(LOGIC_TESTS) $(ARITHMETIC_TESTS) $(BITWISE_TESTS) $(STACK_TESTS) \
+ $(MEMORY_TESTS) $(CONTROL_TESTS) $(IO_TESTS)
+
+LLVMC = $(LLVMToolDir)/llvmc
+
+all :: test_each
+
+test_each: $(TESTS)
+ $(Echo) "Running Tests..."
+ $(Verb) LD_LIBRARY_PATH=$(PROJ_OBJ_ROOT)/lib/$(CONFIGURATION) \
+ $(PROJ_SRC_DIR)/runtests $(PROJ_OBJ_DIR) $(TESTS)
+
+% : %.st Makefile testing.bc
+ $(Echo) "Building $*"
+ $(Verb)$(LLVMC) -O4 -o $@ $< testing.bc -L$(LibDir)
+
+testing.bc : testing.st Makefile
+ $(Echo) "Compiling $*"
+ $(Verb)$(LLVMC) -O3 -c -o $@ $<
+
+TESTS_LL = $(TESTS:%=%.ll)
+TESTS_BC = $(TESTS:%=%.bc)
+TESTS_S = $(TESTS:%=%.s)
+
+clean ::
+ $(Verb)rm -f gmon.out $(TESTS_LL) $(TESTS_BC) $(TESTS_S) $(TESTS) \
+ testing.bc testing.s testing.ll
+
+.SUFFIXES: .st .s .ll .bc
+.PRECIOUS: %.s %.ll %.bc %.st
+.PHONY: test_each
diff --git a/stacker/test/abs.st b/stacker/test/abs.st
new file mode 100644
index 00000000000..8dde286a8b5
--- /dev/null
+++ b/stacker/test/abs.st
@@ -0,0 +1,6 @@
+#
+# ABS test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN -23 ABS 23 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/add.st b/stacker/test/add.st
new file mode 100644
index 00000000000..89d5a9cb681
--- /dev/null
+++ b/stacker/test/add.st
@@ -0,0 +1,7 @@
+#
+# ADD test
+#
+FORWARD success;
+FORWARD failure;
+: step2 7 93 + 100 = IF success ELSE failure ENDIF ;
+: MAIN 93 7 + 100 = IF step2 ELSE failure ENDIF ;
diff --git a/stacker/test/and.st b/stacker/test/and.st
new file mode 100644
index 00000000000..75b5919d792
--- /dev/null
+++ b/stacker/test/and.st
@@ -0,0 +1,7 @@
+#
+# AND test
+#
+FORWARD success;
+FORWARD failure;
+: step2 7 15 AND 7 = IF success ELSE failure ENDIF ;
+: MAIN 8 16 AND 0 = IF step2 ELSE failure ENDIF ;
diff --git a/stacker/test/decr.st b/stacker/test/decr.st
new file mode 100644
index 00000000000..3244152e58c
--- /dev/null
+++ b/stacker/test/decr.st
@@ -0,0 +1,6 @@
+#
+# DECR test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 8 -- 7 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/div.st b/stacker/test/div.st
new file mode 100644
index 00000000000..dcffa5690f8
--- /dev/null
+++ b/stacker/test/div.st
@@ -0,0 +1,6 @@
+#
+# DIV test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 49 / 7 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/drop.st b/stacker/test/drop.st
new file mode 100644
index 00000000000..4e29ae0d485
--- /dev/null
+++ b/stacker/test/drop.st
@@ -0,0 +1,6 @@
+#
+# DROP test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 1 2 DROP 1 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/drop2.st b/stacker/test/drop2.st
new file mode 100644
index 00000000000..f7e95a48ed4
--- /dev/null
+++ b/stacker/test/drop2.st
@@ -0,0 +1,7 @@
+#
+# DROP2 test
+#
+FORWARD success;
+FORWARD failure;
+: step2 0 = IF success ELSE failure ENDIF ;
+: MAIN 0 1 2 3 DROP2 1 = IF step2 ELSE failure ENDIF ;
diff --git a/stacker/test/dup.st b/stacker/test/dup.st
new file mode 100644
index 00000000000..0ddaa43c45d
--- /dev/null
+++ b/stacker/test/dup.st
@@ -0,0 +1,8 @@
+#
+# DUP test
+#
+FORWARD success;
+FORWARD failure;
+: phase3 1 = IF success ELSE failure ENDIF ;
+: phase2 2 = IF phase3 ELSE failure ENDIF ;
+: MAIN 1 2 DUP 2 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/dup2.st b/stacker/test/dup2.st
new file mode 100644
index 00000000000..aed01328424
--- /dev/null
+++ b/stacker/test/dup2.st
@@ -0,0 +1,7 @@
+#
+# DUP2 test
+#
+FORWARD success;
+FORWARD failure;
+: phase2 1 = IF success ELSE failure ENDIF ;
+: MAIN 1 2 DUP2 2 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/eq.st b/stacker/test/eq.st
new file mode 100644
index 00000000000..59733af3056
--- /dev/null
+++ b/stacker/test/eq.st
@@ -0,0 +1,6 @@
+#
+# EQ test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 17 17 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/false.st b/stacker/test/false.st
new file mode 100644
index 00000000000..08c178362ab
--- /dev/null
+++ b/stacker/test/false.st
@@ -0,0 +1,6 @@
+#
+# FALSE test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN FALSE 0 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/ge.st b/stacker/test/ge.st
new file mode 100644
index 00000000000..d303b773aeb
--- /dev/null
+++ b/stacker/test/ge.st
@@ -0,0 +1,7 @@
+#
+# GE test
+#
+FORWARD success;
+FORWARD failure;
+: phase2 49 49 >= IF success ELSE failure ENDIF ;
+: MAIN 7 49 >= IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/gt.st b/stacker/test/gt.st
new file mode 100644
index 00000000000..e873b4e7cfc
--- /dev/null
+++ b/stacker/test/gt.st
@@ -0,0 +1,6 @@
+#
+# GT test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 49 > IF success ELSE failure ENDIF ;
diff --git a/stacker/test/incr.st b/stacker/test/incr.st
new file mode 100644
index 00000000000..c2f8e345362
--- /dev/null
+++ b/stacker/test/incr.st
@@ -0,0 +1,6 @@
+#
+# INCR test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 ++ 8 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/le.st b/stacker/test/le.st
new file mode 100644
index 00000000000..d218db865f8
--- /dev/null
+++ b/stacker/test/le.st
@@ -0,0 +1,7 @@
+#
+# LE test
+#
+FORWARD success;
+FORWARD failure;
+: phase2 49 49 <= IF success ELSE failure ENDIF ;
+: MAIN 49 7 <= IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/lt.st b/stacker/test/lt.st
new file mode 100644
index 00000000000..9752186160d
--- /dev/null
+++ b/stacker/test/lt.st
@@ -0,0 +1,7 @@
+#
+# LT test
+#
+FORWARD success;
+FORWARD failure;
+: phase2 49 7 < IF success ELSE failure ENDIF ;
+: MAIN 7 49 < IF failure ELSE phase2 ENDIF ;
diff --git a/stacker/test/max.st b/stacker/test/max.st
new file mode 100644
index 00000000000..b3b905d040f
--- /dev/null
+++ b/stacker/test/max.st
@@ -0,0 +1,7 @@
+#
+# MAX test
+#
+FORWARD success;
+FORWARD failure;
+: step2 2 1 MAX 2 = IF success ELSE failure ENDIF ;
+: MAIN 1 2 MAX 2 = IF step2 ELSE failure ENDIF ;
diff --git a/stacker/test/memory.st b/stacker/test/memory.st
new file mode 100644
index 00000000000..8c59956a625
--- /dev/null
+++ b/stacker/test/memory.st
@@ -0,0 +1,10 @@
+#
+# MEMORY test
+#
+FORWARD success;
+FORWARD failure;
+: try_free FREE ;
+: read_space >s ;
+: write_space 0 72 PUT 1 69 PUT 2 76 PUT 3 76 PUT 4 79 PUT ;
+: try_malloc 64 MALLOC ;
+: MAIN try_malloc write_space read_space try_free " - " >s success ;
diff --git a/stacker/test/min.st b/stacker/test/min.st
new file mode 100644
index 00000000000..7f516057d60
--- /dev/null
+++ b/stacker/test/min.st
@@ -0,0 +1,7 @@
+#
+# MIN test
+#
+FORWARD success;
+FORWARD failure;
+: step2 1 2 MIN 1 = IF success ELSE failure ENDIF ;
+: MAIN 2 1 MIN 1 = IF step2 ELSE failure ENDIF ;
diff --git a/stacker/test/mod.st b/stacker/test/mod.st
new file mode 100644
index 00000000000..5bb81dcab89
--- /dev/null
+++ b/stacker/test/mod.st
@@ -0,0 +1,6 @@
+#
+# MOD value test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 13 MOD 6 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/mul.st b/stacker/test/mul.st
new file mode 100644
index 00000000000..58314588183
--- /dev/null
+++ b/stacker/test/mul.st
@@ -0,0 +1,6 @@
+#
+# MUL value test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 14 7 * 98 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/ne.st b/stacker/test/ne.st
new file mode 100644
index 00000000000..dde9d010a5a
--- /dev/null
+++ b/stacker/test/ne.st
@@ -0,0 +1,6 @@
+#
+# NE test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 49 <> IF success ELSE failure ENDIF ;
diff --git a/stacker/test/neg.st b/stacker/test/neg.st
new file mode 100644
index 00000000000..d3d05be3d3a
--- /dev/null
+++ b/stacker/test/neg.st
@@ -0,0 +1,6 @@
+#
+# NEG test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 23 NEG -23 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/nip.st b/stacker/test/nip.st
new file mode 100644
index 00000000000..91da4b4018c
--- /dev/null
+++ b/stacker/test/nip.st
@@ -0,0 +1,6 @@
+#
+# NIP test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 1 2 NIP 2 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/nip2.st b/stacker/test/nip2.st
new file mode 100644
index 00000000000..a171028a805
--- /dev/null
+++ b/stacker/test/nip2.st
@@ -0,0 +1,9 @@
+#
+# NIP2 test
+#
+FORWARD success;
+FORWARD failure;
+: test_0 0 = IF success ELSE failure ENDIF ;
+: test_3 3 = IF test_0 ELSE failure ENDIF ;
+: test_4 4 = IF test_3 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 NIP2 test_4 ;
diff --git a/stacker/test/or.st b/stacker/test/or.st
new file mode 100644
index 00000000000..60359070dee
--- /dev/null
+++ b/stacker/test/or.st
@@ -0,0 +1,7 @@
+#
+# OR test
+#
+FORWARD success;
+FORWARD failure;
+: phase2 0 0 OR 0 = IF success ELSE failure ENDIF ;
+: MAIN 7 8 OR 15 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/out_chr.st b/stacker/test/out_chr.st
new file mode 100644
index 00000000000..54bd95846b5
--- /dev/null
+++ b/stacker/test/out_chr.st
@@ -0,0 +1,5 @@
+#
+# OUT_CH test
+#
+FORWARD success;
+: MAIN 33 >c success ;
diff --git a/stacker/test/out_num.st b/stacker/test/out_num.st
new file mode 100644
index 00000000000..30ec9744b8c
--- /dev/null
+++ b/stacker/test/out_num.st
@@ -0,0 +1,5 @@
+#
+# OUT_NUM test
+#
+FORWARD success;
+: MAIN 33 >d success ;
diff --git a/stacker/test/out_str.st b/stacker/test/out_str.st
new file mode 100644
index 00000000000..27d1659d00c
--- /dev/null
+++ b/stacker/test/out_str.st
@@ -0,0 +1,5 @@
+#
+# OUT_STR test
+#
+FORWARD success;
+: MAIN "!" >s success ;
diff --git a/stacker/test/over.st b/stacker/test/over.st
new file mode 100644
index 00000000000..bec61a571fc
--- /dev/null
+++ b/stacker/test/over.st
@@ -0,0 +1,9 @@
+#
+# OVER test
+#
+FORWARD success;
+FORWARD failure;
+: phase4 0 = IF success ELSE failure ENDIF ;
+: phase3 2 = IF phase4 ELSE failure ENDIF ;
+: phase2 1 = IF phase3 ELSE failure ENDIF ;
+: MAIN 0 2 1 OVER 2 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/over2.st b/stacker/test/over2.st
new file mode 100644
index 00000000000..cd4618aa0d7
--- /dev/null
+++ b/stacker/test/over2.st
@@ -0,0 +1,14 @@
+#
+# OVER2 test
+#
+# Logic: // w1 w2 w3 w4 -- w1 w2 w3 w4 w1 w2
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_1b 1 = IF try_0 ELSE failure ENDIF ;
+: try_2 2 = IF try_1b ELSE failure ENDIF ;
+: try_3 3 = IF try_2 ELSE failure ENDIF ;
+: try_4 4 = IF try_3 ELSE failure ENDIF ;
+: try_1a 1 = IF try_4 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 OVER2 2 = IF try_1a ELSE failure ENDIF ;
diff --git a/stacker/test/pick.st b/stacker/test/pick.st
new file mode 100644
index 00000000000..b9670b13874
--- /dev/null
+++ b/stacker/test/pick.st
@@ -0,0 +1,9 @@
+#
+# PICK test
+#
+# Logic: // x0 ... Xn n -- x0 ... Xn x0
+#
+FORWARD success;
+FORWARD failure;
+: next 10 = IF success ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 5 6 7 8 9 10 5 PICK 5 = IF next ELSE failure ENDIF ;
diff --git a/stacker/test/recurse.st b/stacker/test/recurse.st
new file mode 100644
index 00000000000..310728c0712
--- /dev/null
+++ b/stacker/test/recurse.st
@@ -0,0 +1,7 @@
+#
+# RECURSE test
+#
+FORWARD success;
+FORWARD failure;
+: recurser 100 = IF 1 + RECURSE;
+: MAIN 1 recurser success ;
diff --git a/stacker/test/return.st b/stacker/test/return.st
new file mode 100644
index 00000000000..ab26942dcb2
--- /dev/null
+++ b/stacker/test/return.st
@@ -0,0 +1,8 @@
+
+#
+# RECURSE test
+#
+FORWARD success;
+FORWARD failure;
+: returner 17 RETURN ;
+: MAIN returner 17 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/roll.st b/stacker/test/roll.st
new file mode 100644
index 00000000000..1c203af1b9b
--- /dev/null
+++ b/stacker/test/roll.st
@@ -0,0 +1,5 @@
+#
+# ROLL test
+#
+FORWARD success;
+: MAIN "Not Implemented Yet - Left As An Exercise - " >s success ;
diff --git a/stacker/test/rot.st b/stacker/test/rot.st
new file mode 100644
index 00000000000..75b1422ddc7
--- /dev/null
+++ b/stacker/test/rot.st
@@ -0,0 +1,9 @@
+#
+# DUP test
+#
+FORWARD success;
+FORWARD failure;
+: phase4 0 = IF success ELSE failure ENDIF ;
+: phase3 2 = IF phase4 ELSE failure ENDIF ;
+: phase2 3 = IF phase3 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 ROT 1 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/rot2.st b/stacker/test/rot2.st
new file mode 100644
index 00000000000..16bd1d6fda0
--- /dev/null
+++ b/stacker/test/rot2.st
@@ -0,0 +1,14 @@
+#
+# ROT2 test
+#
+# Logic: // w1 w2 w3 w4 w5 w6 -- w3 w4 w5 w6 w1 w2
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_3 3 = IF try_0 ELSE failure ENDIF ;
+: try_4 4 = IF try_3 ELSE failure ENDIF ;
+: try_5 5 = IF try_4 ELSE failure ENDIF ;
+: try_6 6 = IF try_5 ELSE failure ENDIF ;
+: try_1 1 = IF try_6 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 5 6 ROT2 2 = IF try_1 ELSE failure ENDIF ;
diff --git a/stacker/test/rrot.st b/stacker/test/rrot.st
new file mode 100644
index 00000000000..afbf5565002
--- /dev/null
+++ b/stacker/test/rrot.st
@@ -0,0 +1,12 @@
+#
+# RROT test
+#
+# Logic: w1 w2 w3 -- w3 w1 w2
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_3 3 = IF try_0 ELSE failure ENDIF ;
+: try_1 1 = IF try_3 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 RROT 2 = IF try_1 ELSE failure ENDIF ;
+
diff --git a/stacker/test/rrot2.st b/stacker/test/rrot2.st
new file mode 100644
index 00000000000..fb2ebd1dd7d
--- /dev/null
+++ b/stacker/test/rrot2.st
@@ -0,0 +1,14 @@
+#
+# RROT2 test
+#
+# Logic: // w1 w2 w3 w4 w5 w6 -- w5 w6 w1 w2 w3 w4
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_5 5 = IF try_0 ELSE failure ENDIF ;
+: try_6 6 = IF try_5 ELSE failure ENDIF ;
+: try_1 1 = IF try_6 ELSE failure ENDIF ;
+: try_2 2 = IF try_1 ELSE failure ENDIF ;
+: try_3 3 = IF try_2 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 5 6 RROT2 4 = IF try_3 ELSE failure ENDIF ;
diff --git a/stacker/test/runtests b/stacker/test/runtests
new file mode 100755
index 00000000000..a38058e962d
--- /dev/null
+++ b/stacker/test/runtests
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+path=$1
+shift
+let $((success=0))
+let $((failure=0))
+for tst in $* ; do
+ result=`$path/$tst`
+ status="$?"
+ echo "Test $tst : $result"
+ if [ $status -eq 0 ] ; then
+ let $((success++))
+ else
+ let $((failure++))
+ fi
+done
+
+echo "Failures : $failure"
+echo "Successes: $success"
+echo "Total : $((failure+success))"
diff --git a/stacker/test/select.st b/stacker/test/select.st
new file mode 100644
index 00000000000..8e3dfd0f2f3
--- /dev/null
+++ b/stacker/test/select.st
@@ -0,0 +1,7 @@
+#
+# SELECT test
+#
+FORWARD success;
+FORWARD failure;
+: try_99 99 = IF success ELSE failure ENDIF ;
+: MAIN 99 10 9 8 7 6 5 4 3 2 1 10 5 SELECT 5 = IF try_99 ELSE failure ENDIF ;
diff --git a/stacker/test/shl.st b/stacker/test/shl.st
new file mode 100644
index 00000000000..5919d286be3
--- /dev/null
+++ b/stacker/test/shl.st
@@ -0,0 +1,7 @@
+#
+# SHL test
+#
+FORWARD success;
+FORWARD failure;
+: show_failure >d SPACE failure ;
+: MAIN 64 3 << 512 = IF success ELSE show_failure ENDIF ;
diff --git a/stacker/test/shr.st b/stacker/test/shr.st
new file mode 100644
index 00000000000..3dbc24e3ce7
--- /dev/null
+++ b/stacker/test/shr.st
@@ -0,0 +1,7 @@
+#
+# SHR test
+#
+FORWARD success;
+FORWARD failure;
+: show_failure >d SPACE failure ;
+: MAIN 64 3 >> 8 = IF success ELSE show_failure ENDIF ;
diff --git a/stacker/test/space.st b/stacker/test/space.st
new file mode 100644
index 00000000000..26a068a79d4
--- /dev/null
+++ b/stacker/test/space.st
@@ -0,0 +1,5 @@
+#
+# SPACE test
+#
+FORWARD success;
+: MAIN ">>" >s SPACE "<<" >s success ;
diff --git a/stacker/test/star_slash.st b/stacker/test/star_slash.st
new file mode 100644
index 00000000000..d353a7d5047
--- /dev/null
+++ b/stacker/test/star_slash.st
@@ -0,0 +1,6 @@
+#
+# */ value test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 17 17 17 */ 17 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/sub.st b/stacker/test/sub.st
new file mode 100644
index 00000000000..09438d15e11
--- /dev/null
+++ b/stacker/test/sub.st
@@ -0,0 +1,6 @@
+#
+# SUB test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 23 15 - -8 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/swap.st b/stacker/test/swap.st
new file mode 100644
index 00000000000..14176dbd10a
--- /dev/null
+++ b/stacker/test/swap.st
@@ -0,0 +1,9 @@
+
+#
+# DUP test
+#
+FORWARD success;
+FORWARD failure;
+: phase3 0 = IF success ELSE failure ENDIF ;
+: phase2 2 = IF phase3 ELSE failure ENDIF ;
+: MAIN 0 1 2 SWAP 1 = IF phase2 ELSE failure ENDIF ;
diff --git a/stacker/test/swap2.st b/stacker/test/swap2.st
new file mode 100644
index 00000000000..c4f1bbd37d2
--- /dev/null
+++ b/stacker/test/swap2.st
@@ -0,0 +1,10 @@
+#
+# SWAP2 test
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_3 3 = IF try_0 ELSE failure ENDIF ;
+: try_4 4 = IF try_3 ELSE failure ENDIF ;
+: try_1 1 = IF try_4 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 SWAP2 2 = IF try_1 ELSE failure ENDIF ;
diff --git a/stacker/test/tab.st b/stacker/test/tab.st
new file mode 100644
index 00000000000..b3b9e6e1460
--- /dev/null
+++ b/stacker/test/tab.st
@@ -0,0 +1,5 @@
+#
+# TAB test
+#
+FORWARD success;
+: MAIN ">>" >s TAB "<<" >s success ;
diff --git a/stacker/test/testing.st b/stacker/test/testing.st
new file mode 100644
index 00000000000..a5e32be84cf
--- /dev/null
+++ b/stacker/test/testing.st
@@ -0,0 +1,5 @@
+#
+# Common definitions for testing
+#
+: success "Success" >s CR 0 EXIT ;
+: failure "Failure" >s CR 1 EXIT ;
diff --git a/stacker/test/true.st b/stacker/test/true.st
new file mode 100644
index 00000000000..223e728fd53
--- /dev/null
+++ b/stacker/test/true.st
@@ -0,0 +1,6 @@
+#
+# TRUE test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN TRUE -1 = IF success ELSE failure ENDIF ;
diff --git a/stacker/test/tuck.st b/stacker/test/tuck.st
new file mode 100644
index 00000000000..956333ab4d4
--- /dev/null
+++ b/stacker/test/tuck.st
@@ -0,0 +1,11 @@
+#
+# TUCK test
+#
+# Logic: // w1 w2 -- w2 w1 w2
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_2 2 = IF try_0 ELSE failure ENDIF ;
+: try_1 1 = IF try_2 ELSE failure ENDIF ;
+: MAIN 0 1 2 TUCK 2 = IF try_1 ELSE failure ENDIF ;
diff --git a/stacker/test/tuck2.st b/stacker/test/tuck2.st
new file mode 100644
index 00000000000..e32dcc2798f
--- /dev/null
+++ b/stacker/test/tuck2.st
@@ -0,0 +1,14 @@
+#
+# TUCK2 test
+#
+# Logic: // w1 w2 w3 w4 -- w3 w4 w1 w2 w3 w4
+#
+FORWARD success;
+FORWARD failure;
+: try_0 0 = IF success ELSE failure ENDIF ;
+: try_3b 3 = IF try_0 ELSE failure ENDIF ;
+: try_4 4 = IF try_3b ELSE failure ENDIF ;
+: try_1 1 = IF try_4 ELSE failure ENDIF ;
+: try_2 2 = IF try_1 ELSE failure ENDIF ;
+: try_3a 3 = IF try_2 ELSE failure ENDIF ;
+: MAIN 0 1 2 3 4 TUCK2 4 = IF try_3a ELSE failure ENDIF ;
diff --git a/stacker/test/while.st b/stacker/test/while.st
new file mode 100644
index 00000000000..7798f12e1f2
--- /dev/null
+++ b/stacker/test/while.st
@@ -0,0 +1,8 @@
+#
+# WHILE test
+#
+FORWARD success;
+FORWARD failure;
+: body "." >s DROP -- ;
+: do_while WHILE body END ;
+: MAIN 20 do_while 0 = IF success ELSE failure ENDIF;
diff --git a/stacker/test/xor.st b/stacker/test/xor.st
new file mode 100644
index 00000000000..924d20a9e8e
--- /dev/null
+++ b/stacker/test/xor.st
@@ -0,0 +1,6 @@
+#
+# XOR test
+#
+FORWARD success;
+FORWARD failure;
+: MAIN 7 3 XOR 4 = IF success ELSE failure ENDIF ;
OpenPOWER on IntegriCloud