mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-11 07:15:26 +00:00
Checkin tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10187 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7610029346
commit
e44f1db6e6
61
projects/Stacker/test/Makefile
Normal file
61
projects/Stacker/test/Makefile
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
##===- projects/sample/Makefile ----------------------------*- Makefile -*-===##
|
||||||
|
#
|
||||||
|
# This is a sample Makefile for a project that uses LLVM.
|
||||||
|
#
|
||||||
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
#
|
||||||
|
# Indicates our relative path to the top of the project's root directory.
|
||||||
|
#
|
||||||
|
LEVEL = ../../..
|
||||||
|
|
||||||
|
#
|
||||||
|
# Directories that needs 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)
|
||||||
|
|
||||||
|
all :: test_each
|
||||||
|
|
||||||
|
test_each: $(TESTS)
|
||||||
|
$(BUILD_SRC_DIR)/runtests $(BUILD_OBJ_DIR) $(TESTS)
|
||||||
|
|
||||||
|
% : %.s testing.s
|
||||||
|
gcc -ggdb -L$(BUILD_OBJ_ROOT)/lib/Debug testing.s -lstkr_runtime -o $* $*.s
|
||||||
|
|
||||||
|
%.s : %.bc
|
||||||
|
llc -f -o $*.s $<
|
||||||
|
|
||||||
|
ifdef OPTIMIZE
|
||||||
|
%.bc : %.st $(BUILD_OBJ_ROOT)/tools/Debug/stkrc
|
||||||
|
stkrc -e -o - $< | opt -stats -q -f -o $*.bc -adce -branch-combine -cee -constmerge -constprop -dce -die -gcse -globaldce -instcombine -pre
|
||||||
|
else
|
||||||
|
%.bc : %.st $(BUILD_OBJ_ROOT)/tools/Debug/stkrc
|
||||||
|
stkrc -e -f -o $*.bc $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
%.ll : %.bc
|
||||||
|
llvm-dis -o $*.ll $<
|
||||||
|
|
||||||
|
clean ::
|
||||||
|
rm -f $(TESTS)
|
||||||
|
|
||||||
|
.SUFFIXES: .st .s .ll
|
||||||
|
.PRECIOUS: %.s %.ll %.bc %.st
|
||||||
|
.PHONY: test_each test_asm
|
6
projects/Stacker/test/abs.st
Normal file
6
projects/Stacker/test/abs.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# ABS test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN -23 ABS 23 = IF success ELSE failure ENDIF ;
|
7
projects/Stacker/test/add.st
Normal file
7
projects/Stacker/test/add.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/and.st
Normal file
7
projects/Stacker/test/and.st
Normal file
@ -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 ;
|
6
projects/Stacker/test/decr.st
Normal file
6
projects/Stacker/test/decr.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# DECR test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 8 -- 7 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/div.st
Normal file
6
projects/Stacker/test/div.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# DIV test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 49 / 7 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/drop.st
Normal file
6
projects/Stacker/test/drop.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# DROP test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 1 2 DROP 1 = IF success ELSE failure ENDIF ;
|
7
projects/Stacker/test/drop2.st
Normal file
7
projects/Stacker/test/drop2.st
Normal file
@ -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 ;
|
8
projects/Stacker/test/dup.st
Normal file
8
projects/Stacker/test/dup.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/dup2.st
Normal file
7
projects/Stacker/test/dup2.st
Normal file
@ -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 ;
|
6
projects/Stacker/test/eq.st
Normal file
6
projects/Stacker/test/eq.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# EQ test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 17 17 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/false.st
Normal file
6
projects/Stacker/test/false.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# FALSE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN FALSE 0 = IF success ELSE failure ENDIF ;
|
7
projects/Stacker/test/ge.st
Normal file
7
projects/Stacker/test/ge.st
Normal file
@ -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 ;
|
6
projects/Stacker/test/gt.st
Normal file
6
projects/Stacker/test/gt.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# GT test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 49 > IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/incr.st
Normal file
6
projects/Stacker/test/incr.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# INCR test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 ++ 8 = IF success ELSE failure ENDIF ;
|
7
projects/Stacker/test/le.st
Normal file
7
projects/Stacker/test/le.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/lt.st
Normal file
7
projects/Stacker/test/lt.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/max.st
Normal file
7
projects/Stacker/test/max.st
Normal file
@ -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 ;
|
10
projects/Stacker/test/memory.st
Normal file
10
projects/Stacker/test/memory.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/min.st
Normal file
7
projects/Stacker/test/min.st
Normal file
@ -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 ;
|
6
projects/Stacker/test/mod.st
Normal file
6
projects/Stacker/test/mod.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# MOD value test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 13 MOD 6 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/mul.st
Normal file
6
projects/Stacker/test/mul.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# MUL value test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 14 7 * 98 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/ne.st
Normal file
6
projects/Stacker/test/ne.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# NE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 49 <> IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/neg.st
Normal file
6
projects/Stacker/test/neg.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# NEG test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 23 NEG -23 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/nip.st
Normal file
6
projects/Stacker/test/nip.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# NIP test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 1 2 NIP 2 = IF success ELSE failure ENDIF ;
|
9
projects/Stacker/test/nip2.st
Normal file
9
projects/Stacker/test/nip2.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/or.st
Normal file
7
projects/Stacker/test/or.st
Normal file
@ -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 ;
|
5
projects/Stacker/test/out_chr.st
Normal file
5
projects/Stacker/test/out_chr.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# OUT_CH test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN 33 >c success ;
|
5
projects/Stacker/test/out_num.st
Normal file
5
projects/Stacker/test/out_num.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# OUT_NUM test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN 33 >d success ;
|
5
projects/Stacker/test/out_str.st
Normal file
5
projects/Stacker/test/out_str.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# OUT_STR test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN "!" >s success ;
|
9
projects/Stacker/test/over.st
Normal file
9
projects/Stacker/test/over.st
Normal file
@ -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 ;
|
14
projects/Stacker/test/over2.st
Normal file
14
projects/Stacker/test/over2.st
Normal file
@ -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 ;
|
9
projects/Stacker/test/pick.st
Normal file
9
projects/Stacker/test/pick.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/recurse.st
Normal file
7
projects/Stacker/test/recurse.st
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
# RECURSE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: recurser 100 = IF 1 + RECURSE;
|
||||||
|
: MAIN 1 recurser success ;
|
8
projects/Stacker/test/return.st
Normal file
8
projects/Stacker/test/return.st
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#
|
||||||
|
# RECURSE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: returner 17 RETURN ;
|
||||||
|
: MAIN returner 17 = IF success ELSE failure ENDIF ;
|
5
projects/Stacker/test/roll.st
Normal file
5
projects/Stacker/test/roll.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# ROLL test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN "Not Implemented Yet - Left As An Exercise - " >s success ;
|
9
projects/Stacker/test/rot.st
Normal file
9
projects/Stacker/test/rot.st
Normal file
@ -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 ;
|
14
projects/Stacker/test/rot2.st
Normal file
14
projects/Stacker/test/rot2.st
Normal file
@ -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 ;
|
12
projects/Stacker/test/rrot.st
Normal file
12
projects/Stacker/test/rrot.st
Normal file
@ -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 ;
|
||||||
|
|
14
projects/Stacker/test/rrot2.st
Normal file
14
projects/Stacker/test/rrot2.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/select.st
Normal file
7
projects/Stacker/test/select.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/shl.st
Normal file
7
projects/Stacker/test/shl.st
Normal file
@ -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 ;
|
7
projects/Stacker/test/shr.st
Normal file
7
projects/Stacker/test/shr.st
Normal file
@ -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 ;
|
5
projects/Stacker/test/space.st
Normal file
5
projects/Stacker/test/space.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# SPACE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN ">>" >s SPACE "<<" >s success ;
|
6
projects/Stacker/test/star_slash.st
Normal file
6
projects/Stacker/test/star_slash.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# */ value test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 17 17 17 */ 17 = IF success ELSE failure ENDIF ;
|
6
projects/Stacker/test/sub.st
Normal file
6
projects/Stacker/test/sub.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# SUB test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 23 15 - -8 = IF success ELSE failure ENDIF ;
|
9
projects/Stacker/test/swap.st
Normal file
9
projects/Stacker/test/swap.st
Normal file
@ -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 ;
|
10
projects/Stacker/test/swap2.st
Normal file
10
projects/Stacker/test/swap2.st
Normal file
@ -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 ;
|
5
projects/Stacker/test/tab.st
Normal file
5
projects/Stacker/test/tab.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# TAB test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
: MAIN ">>" >s TAB "<<" >s success ;
|
5
projects/Stacker/test/testing.st
Normal file
5
projects/Stacker/test/testing.st
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# Common definitions for testing
|
||||||
|
#
|
||||||
|
: success "Success" >s CR 0 EXIT ;
|
||||||
|
: failure "Failure" >s CR 1 EXIT ;
|
6
projects/Stacker/test/true.st
Normal file
6
projects/Stacker/test/true.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# TRUE test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN TRUE -1 = IF success ELSE failure ENDIF ;
|
11
projects/Stacker/test/tuck.st
Normal file
11
projects/Stacker/test/tuck.st
Normal file
@ -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 ;
|
14
projects/Stacker/test/tuck2.st
Normal file
14
projects/Stacker/test/tuck2.st
Normal file
@ -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 ;
|
8
projects/Stacker/test/while.st
Normal file
8
projects/Stacker/test/while.st
Normal file
@ -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;
|
6
projects/Stacker/test/xor.st
Normal file
6
projects/Stacker/test/xor.st
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# XOR test
|
||||||
|
#
|
||||||
|
FORWARD success;
|
||||||
|
FORWARD failure;
|
||||||
|
: MAIN 7 3 XOR 4 = IF success ELSE failure ENDIF ;
|
Loading…
x
Reference in New Issue
Block a user