summaryrefslogtreecommitdiff
path: root/usr/src/lib/efcode/fcode_test
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/efcode/fcode_test')
-rw-r--r--usr/src/lib/efcode/fcode_test/Makefile56
-rw-r--r--usr/src/lib/efcode/fcode_test/access.fth70
-rw-r--r--usr/src/lib/efcode/fcode_test/arithmetic.fth174
-rw-r--r--usr/src/lib/efcode/fcode_test/bytemanipulate.fth56
-rw-r--r--usr/src/lib/efcode/fcode_test/calling.fth36
-rw-r--r--usr/src/lib/efcode/fcode_test/case.fth42
-rw-r--r--usr/src/lib/efcode/fcode_test/catch.fth33
-rw-r--r--usr/src/lib/efcode/fcode_test/create.fth40
-rw-r--r--usr/src/lib/efcode/fcode_test/find.fth35
-rw-r--r--usr/src/lib/efcode/fcode_test/iftest.fth118
-rw-r--r--usr/src/lib/efcode/fcode_test/instance.fth28
-rw-r--r--usr/src/lib/efcode/fcode_test/loop.fth97
-rw-r--r--usr/src/lib/efcode/fcode_test/misc.fth188
-rw-r--r--usr/src/lib/efcode/fcode_test/parse.fth56
-rw-r--r--usr/src/lib/efcode/fcode_test/stack.fth56
-rw-r--r--usr/src/lib/efcode/fcode_test/storage.fth46
-rw-r--r--usr/src/lib/efcode/fcode_test/test.fth70
-rw-r--r--usr/src/lib/efcode/fcode_test/test64.fth126
-rw-r--r--usr/src/lib/efcode/fcode_test/values.fth29
19 files changed, 1356 insertions, 0 deletions
diff --git a/usr/src/lib/efcode/fcode_test/Makefile b/usr/src/lib/efcode/fcode_test/Makefile
new file mode 100644
index 0000000000..e45ef0b706
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/Makefile
@@ -0,0 +1,56 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+#
+# lib/efcode/fcode_test/Makefile
+#
+
+include ../../../Makefile.master
+
+TESTSRCS = test.fth calling.fth iftest.fth arithmetic.fth create.fth \
+ stack.fth bytemanipulate.fth loop.fth find.fth values.fth \
+ instance.fth catch.fth storage.fth case.fth access.fth misc.fth \
+ parse.fth
+
+PROGS = test.fcode test64.fcode
+
+TOKENIZE = $(ONBLD_TOOLS)/bin/sparc/tokenize
+
+.SUFFIXES: .fcode .fth $(SUFFIXES)
+
+install all: $(PROGS)
+
+.fth.fcode:
+ $(TOKENIZE) $<
+
+test.fcode: $(TESTSRCS)
+
+clean:
+ $(RM) $(PROGS)
+
+clobber: clean
+
+install_h:
diff --git a/usr/src/lib/efcode/fcode_test/access.fth b/usr/src/lib/efcode/fcode_test/access.fth
new file mode 100644
index 0000000000..9f441d83b4
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/access.fth
@@ -0,0 +1,70 @@
+\ #pragma ident "%Z%%M% %I% %E% SMI"
+\ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
+\ CDDL HEADER START
+\
+\ The contents of this file are subject to the terms of the
+\ Common Development and Distribution License, Version 1.0 only
+\ (the "License"). You may not use this file except in compliance
+\ with the License.
+\
+\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ or http://www.opensolaris.org/os/licensing.
+\ See the License for the specific language governing permissions
+\ and limitations under the License.
+\
+\ When distributing Covered Code, include this CDDL HEADER in each
+\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ If applicable, add the following below this CDDL HEADER, with the
+\ fields enclosed by brackets "[]" replaced with your own identifying
+\ information: Portions Copyright [yyyy] [name of copyright owner]
+\
+\ CDDL HEADER END
+\
+
+." Access test: "
+0 value word-test
+0 value char-test
+0 value end-test
+0 value end-test2
+variable var-test
+create access-test
+ h# 80004000 l,
+ here to word-test
+ h# 8000 w, h# 4000 w,
+ here to char-test
+ h# 1 c, h# 2 c, h# 3 c, h# 4 c,
+ here to end-test
+ h# a55aa55a ,
+ here to end-test2
+
+
+ " l,+" access-test la1+ word-test = .passed?
+ " w,+" word-test 2 wa+ char-test = .passed?
+ " c,+" char-test 4 ca+ end-test = .passed?
+ " ,+" end-test cell+ end-test2 = .passed?
+ " c@.1" char-test c@ h# 1 = .passed?
+ " c@.2" char-test char+ c@ h# 2 = .passed?
+ " c@.3" char-test 2 ca+ c@ h# 3 = .passed?
+ " c@.4" char-test 3 ca+ c@ h# 4 = .passed?
+ " w@.1" access-test w@ h# 8000 = .passed?
+ " w@.2" access-test wa1+ w@ h# 4000 = .passed?
+ " w@.3" word-test w@ h# 8000 = .passed?
+ " w@.4" word-test wa1+ w@ h# 4000 = .passed?
+ " w@.5" char-test w@ h# 0102 = .passed?
+ " w@.6" char-test wa1+ w@ h# 0304 = .passed?
+ " <w@" access-test <w@ h# ffff8000 = .passed?
+ " l@.1" access-test l@ h# 80004000 = .passed?
+ " l@.2" word-test l@ h# 80004000 = .passed?
+ " l@.3" char-test l@ h# 01020304 = .passed?
+ " @!.1" h# 5a5aa5a5 var-test ! var-test @ h# 5a5aa5a5 = .passed?
+ " c@c!.1" h# 55 var-test c! var-test c@ h# 55 = .passed?
+ " w@w!.1" h# aa55 var-test w! var-test w@ h# aa55 = .passed?
+ " l@l!.1" h# 5555aaaa var-test l! var-test l@ h# 5555aaaa = .passed?
+ " @!.1" h# aaaa5555 var-test ! var-test @ h# aaaa5555 = .passed?
+ " +!.1" 2 var-test ! 3 var-test +! var-test @ 5 = .passed?
+ " 2!.1" 1 2 access-test 2! access-test @ 2 =
+ access-test cell+ @ 1 = and .passed?
+ " 2@.1" access-test 2@ 2 = swap 1 = and .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/arithmetic.fth b/usr/src/lib/efcode/fcode_test/arithmetic.fth
new file mode 100644
index 0000000000..8a91e7d88d
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/arithmetic.fth
@@ -0,0 +1,174 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Simple 0 Logic Tests: "
+ " 0 invert" 0 invert .passed?
+ " 0 0=" 0 0= .passed?
+ " -1 invert" -1 invert 0= .passed?
+ " 1 0<>" 1 0<> .passed?
+ " 1 0=" 1 0= invert .passed?
+ " 1 0<>" 1 0<> .passed?
+ " 0 0>=" 0 0>= .passed?
+ " 1 0>=" 1 0>= .passed?
+ " -1 0>=" -1 0>= invert .passed?
+ " 1 0>" 1 0> .passed?
+ " 0 0>" 0 0> invert .passed?
+ " -1 0<" -1 0< .passed?
+ " 0 0<" 0 0< invert .passed?
+ " 0 0<=" 0 0<= .passed?
+ " -1 0<=" -1 0<= .passed?
+ " 1 0<=" 1 0<= invert .passed?
+cr
+
+." Positive Arithmetic Comparision Tests: "
+ " 1 0 >" 1 0 > .passed?
+ " 1 1 >=" 1 1 >= .passed?
+ " 1 1 >" 1 1 > invert .passed?
+ " 0 1 <" 0 1 < .passed?
+ " 0 0 <=" 0 0 <= .passed?
+ " 1 0 <" 1 0 < invert .passed?
+ " 0 0 =" 0 0 = .passed?
+ " 0 1 =" 0 1 = invert .passed?
+ " 0 1 <>" 0 1 <> .passed?
+ " 1 1 <>" 1 1 <> invert .passed?
+cr
+
+." Signed Comparison Tests: "
+ " -1 1 >" -1 1 > invert .passed?
+ " -1 -2 >" -1 -2 > .passed?
+ " -1 0 <" -1 0 < .passed?
+ " -2 -1 <" -2 -1 < .passed?
+cr
+
+." Unsigned Comparison Tests: "
+ " -1 0 u>" -1 0 u> .passed?
+ " -1 0 u>=" 1 1 u>= .passed?
+ " 1 -1 <" 2 1 >= .passed?
+ " 0 1 >=" 0 1 >= invert .passed?
+ " 0 -1 u<" 0 -1 u< .passed?
+ " 0 -1 u<=" 0 -1 u<= .passed?
+ " 2 -2 u<=" 2 -2 u<= .passed?
+cr
+
+." Arithmetic Tests: "
+ " 1 1 +" 1 1 + 2 = .passed?
+ " 1 1 -" 1 1 - 0 = .passed?
+ " 1 negate " 1 negate 1+ 0= .passed?
+ " 0 1 -" 0 1 - -1 = .passed?
+ " -1 abs" -1 abs 1 = .passed?
+ " -1 2 min" -1 2 min 1+ 0= .passed?
+ " 2 -1 min" 2 -1 min 1+ 0= .passed?
+ " 3 2 max" 3 2 max 3 = .passed?
+ " 2 3 max" 2 3 max 3 = .passed?
+cr
+
+." Binary Logic: "
+ " 3 1 and" 3 1 and 1 = .passed?
+ " 2 1 and" 2 1 and 0= .passed?
+ " 1 1 or" 1 1 or 1 = .passed?
+ " 3 1 xor" 3 1 xor 2 = .passed?
+cr
+
+." Shifting: "
+ " (short) lshift" h# 11 8 lshift h# 1100 = .passed?
+ " (short) rshift" h# 1122 8 rshift h# 11 = .passed?
+ " (long) lshift" h# 1 d# 31 lshift 1- h# 7fffffff = .passed?
+ " (long) rshift" h# 80 d# 24 lshift d# 31 rshift 1 = .passed?
+ " >>a" -4 1 >>a -2 = .passed?
+cr
+
+." Sized Arithmetic Tests: "
+ " u2/" 0 0 0 h# 80 bljoin u2/ h# 4000.0000 = .passed?
+ " 2/" -4 2/ -2 = .passed?
+ " 2*" h# 4000.0000 dup 1 lshift swap 2* = .passed?
+ " /c" 1 /c = .passed?
+ " /w" 2 /w = .passed?
+ " /l" 4 /l = .passed?
+ " /n" 4 /n = 8 /n = or .passed?
+ " ca+" h# 4000 3 ca+ h# 4003 = .passed?
+ " wa+" h# 4000 3 wa+ h# 4006 = .passed?
+ " la+" h# 4000 3 la+ h# 400c = .passed?
+ " na+" h# 4000 3 na+ h# 4000 3 /n * + = .passed?
+ " char+" h# 4000 char+ h# 4001 = .passed?
+ " wa1+" h# 4000 wa1+ h# 4002 = .passed?
+ " la1+" h# 4000 la1+ h# 4004 = .passed?
+ " cell+" h# 4000 cell+ h# 4000 /n + = .passed?
+ " chars" 4 chars 4 = .passed?
+ " /w*" 8 /w* h# 10 = .passed?
+ " /l*" 4 /l* h# 10 = .passed?
+ " cells" 4 cells 4 /n * = .passed?
+cr
+
+." Division related Tests: "
+ " /mod (+ +)" 5 2 /mod 2 = swap 1 = and .passed?
+ " /mod (- -)" -5 -2 /mod 2 = swap -1 = and .passed?
+ " /mod (+ -)" 5 -2 /mod -3 = swap -1 = and .passed?
+ " /mod (- +)" -5 2 /mod -3 = swap 1 = and .passed?
+ " / (+ +)" 5 2 / 2 = .passed?
+ " / (- -)" -5 -2 / 2 = .passed?
+ " / (+ -)" 5 -2 / -3 = .passed?
+ " / (- +)" -5 2 / -3 = .passed?
+ " mod (+ +)" 5 2 mod 1 = .passed?
+ " mod (- -)" -5 -2 mod -1 = .passed?
+ " mod (+ -)" 5 -2 mod -1 = .passed?
+ " mod (- +)" -5 2 mod 1 = .passed?
+cr
+
+." Signed Multiply/Divide Tests:"
+ " * (+ +)" 2 3 * 6 = .passed?
+ " * (- +)" -3 3 * -9 = .passed?
+ " * (+ -)" 4 -2 * -8 = .passed?
+ " * (- -)" -4 -3 * 12 = .passed?
+cr
+
+." Unsigned Multiply/Divide Tests: "
+ " um*" 1 2 um* 0= swap 2 = and .passed?
+ " um/mod" 5 0 2 um/mod 2 = swap 1 = and .passed?
+ " u/mod" 5 2 u/mod 2 = swap 1 = and .passed?
+cr
+
+." Ranged Tests: "
+ " within (!0)" 2 1 3 within .passed?
+ " within (0 hi)" 3 1 3 within 0= .passed?
+ " within (!0 lo)" 1 1 3 within .passed?
+ " within (0 >)" 0 1 3 within 0= .passed?
+ " within (0 <)" 4 1 3 within 0= .passed?
+ " within (-ve)" 0 -5 5 within .passed?
+ " within (- -)" -7 -10 -5 within .passed?
+ " between (!0)" 2 1 3 between .passed?
+ " between (!0 lo)" 1 1 3 between .passed?
+ " between (!0 hi)" 3 1 3 between .passed?
+ " between (0 >)" 4 1 3 between 0= .passed?
+ " between (0 <)" 0 1 3 between 0= .passed?
+ " between (-ve)" 0 -5 5 between .passed?
+ " between (- -)" -7 -10 -5 between .passed?
+ " bounds" -1 3 bounds -1 = swap 2 = and .passed?
+cr
+
+." Double Arithmetic: "
+ " d+" 1 2 3 4 d+ 6 = swap 4 = and .passed?
+ " d-" 3 4 2 1 d- 3 = swap 1 = and .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/bytemanipulate.fth b/usr/src/lib/efcode/fcode_test/bytemanipulate.fth
new file mode 100644
index 0000000000..772e07f6f1
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/bytemanipulate.fth
@@ -0,0 +1,56 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Byte Split tests: "
+ " lbsplit" h# 11223344 lbsplit
+ h# 11 = swap h# 22 = and swap
+ h# 33 = and swap h# 44 = and .passed?
+ " lwsplit" h# 11223344 lwsplit
+ h# 1122 = swap h# 3344 = and .passed?
+ " wbsplit" h# 31122 wbsplit
+ h# 11 = swap h# 22 = and .passed?
+ " wljoin" h# beef h# dead wljoin h# deadbeef = .passed?
+ " bljoin" h# 111 h# 222 h# 333 h# 444 bljoin
+ h# 44332211 = .passed?
+ " bwjoin" h# 111 h# 222 bwjoin h# 2211 = .passed?
+ " lbflip" h# 11223344 lbflip h# 44332211 = .passed?
+ " lwflip" h# 11223344 lwflip h# 33441122 = .passed?
+ " wbflip" h# 31122 wbflip h# 2211 = .passed?
+create flip-area
+ h# 01020304 l,
+ " wbflips" flip-area /l wbflips flip-area l@ h# 02010403 = .passed?
+ " lwflips" flip-area /l lwflips flip-area l@ h# 04030201 = .passed?
+ " lbflips" flip-area /l lbflips flip-area l@ h# 01020304 = .passed?
+cr
+
+." Memory ops: "
+ " comp +" " abcde" drop " abcd" drop 5 comp 1 = .passed?
+ " comp -" " abcd" drop " abcde" comp -1 = .passed?
+ " comp =" " abcdef" drop " abcdef" comp 0= .passed?
+ " alloc-mem" h# 100 dup alloc-mem ?dup
+ if 2swap -1 else drop false then .passed?
+ " free-mem" 2swap swap free-mem 1 .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/calling.fth b/usr/src/lib/efcode/fcode_test/calling.fth
new file mode 100644
index 0000000000..85eedc7f8b
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/calling.fth
@@ -0,0 +1,36 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+: t1 ascii W emit ;
+: t2 ascii L emit ;
+: t3 t2 ascii D emit ;
+: t4 t1 ascii O emit ;
+: t5 t4 ascii R emit ;
+: t6 t5 t3 space ;
+: t7 ." hello " t6 ;
+: t8 t7 ." and everyone" ;
+
+cr ." > " t8 cr
diff --git a/usr/src/lib/efcode/fcode_test/case.fth b/usr/src/lib/efcode/fcode_test/case.fth
new file mode 100644
index 0000000000..58b7dcbc52
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/case.fth
@@ -0,0 +1,42 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Case: "
+: case1 ( n -- str )
+ case
+ 0 of " zero" >r >r endof
+ 1 of " one" >r >r endof
+ 2 of " two" >r >r endof
+ dup <# u#s u#> >r >r
+ endcase
+ r> r>
+;
+ " case.1" 0 case1 drop " zero" comp invert .passed?
+ " case.2" 1 case1 drop " one" comp invert .passed?
+ " case.3" 2 case1 drop " two" comp invert .passed?
+ " case.4" 3 case1 drop " 3" comp invert .passed?
+ " case.5" 4 case1 drop " 4" comp invert .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/catch.fth b/usr/src/lib/efcode/fcode_test/catch.fth
new file mode 100644
index 0000000000..c3493bcf41
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/catch.fth
@@ -0,0 +1,33 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." catch/throw: "
+ : ttest ( n -- ) throw 0 ;
+ : ttest1 ( -- ) 0 ['] ttest catch 0= swap 0= and ;
+ : ttest2 ( -- ) 1 1 ['] ttest catch nip 1 = swap 1 = and ;
+ " 0 throw" ttest1 .passed?
+ " 1 throw" ttest2 .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/create.fth b/usr/src/lib/efcode/fcode_test/create.fth
new file mode 100644
index 0000000000..be83cd7d5a
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/create.fth
@@ -0,0 +1,40 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Create Test: "
+create table
+ ascii p c,
+ ascii a c,
+ ascii s c,
+ ascii s c,
+ ascii e c,
+ ascii d c,
+
+here table - create table-len c,
+
+: table-test ( -- ) table table-len c@ ;
+ " create.1" " passed" drop table-test comp invert .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/find.fth b/usr/src/lib/efcode/fcode_test/find.fth
new file mode 100644
index 0000000000..443bb60fa3
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/find.fth
@@ -0,0 +1,35 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
+\ CDDL HEADER START
+\
+\ The contents of this file are subject to the terms of the
+\ Common Development and Distribution License, Version 1.0 only
+\ (the "License"). You may not use this file except in compliance
+\ with the License.
+\
+\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ or http://www.opensolaris.org/os/licensing.
+\ See the License for the specific language governing permissions
+\ and limitations under the License.
+\
+\ When distributing Covered Code, include this CDDL HEADER in each
+\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ If applicable, add the following below this CDDL HEADER, with the
+\ fields enclosed by brackets "[]" replaced with your own identifying
+\ information: Portions Copyright [yyyy] [name of copyright owner]
+\
+\ CDDL HEADER END
+\
+
+." Execute test: "
+ : etest ['] 1 dup dup execute swap execute + swap execute + ;
+ " " etest 3 = .passed?
+ " evaluate.1" " 1 2 +" evaluate 3 = .passed?
+cr
+
+." $find testing: "
+" $find.1" 0 1 " drop" $find if execute then 0= .passed?
+" $find.2" " qwerty" $find if false else " qwerty" $= then .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/iftest.fth b/usr/src/lib/efcode/fcode_test/iftest.fth
new file mode 100644
index 0000000000..b087cff1d1
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/iftest.fth
@@ -0,0 +1,118 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
+\ CDDL HEADER START
+\
+\ The contents of this file are subject to the terms of the
+\ Common Development and Distribution License, Version 1.0 only
+\ (the "License"). You may not use this file except in compliance
+\ with the License.
+\
+\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ or http://www.opensolaris.org/os/licensing.
+\ See the License for the specific language governing permissions
+\ and limitations under the License.
+\
+\ When distributing Covered Code, include this CDDL HEADER in each
+\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ If applicable, add the following below this CDDL HEADER, with the
+\ fields enclosed by brackets "[]" replaced with your own identifying
+\ information: Portions Copyright [yyyy] [name of copyright owner]
+\
+\ CDDL HEADER END
+\
+
+cr ." Simple interpreted IF THEN test: "
+1 if .passed then space
+0 if .failed then space
+cr
+
+." Simple interpreted IF ELSE THEN test: "
+0 if .failed else .passed then space
+1 if .passed else .failed then space
+cr
+
+." Nested interpreted IF test: "
+1 1 1 0 0 1 0 0
+if if .failed else .failed then space
+else if .failed else .passed then space
+then
+if if .failed else .passed then space
+else if .failed else .failed then space
+then
+if if .failed else .failed then space
+else if .passed else .failed then space
+then
+if if .passed else .failed then space
+else if .failed else .failed then space
+then
+cr
+
+." Compiled single IF tests:" space
+: if-true? if .passed space 0 exit then .failed space 0 ; 1 if-true?
+: if-false? if .failed space 1 exit then .passed space 1 ; if-false?
+: true? if .passed else .failed then space 0 ; true?
+: false? if .failed else .passed then space ; false?
+
+cr
+
+." Nested compiled IF test: "
+: if-test1 ( -- )
+ 0 1 0 if
+ .failed
+ else
+ if
+ dup if .failed then
+ if .failed else .passed then
+ else
+ .failed
+ then
+ then
+; if-test1 space
+
+: .passed? ( str,len flag )
+ if if then if then .passed space else cr type space .failed cr then
+;
+
+: if-test2 ( x x x -- )
+ if
+ if
+ if
+ 7
+ else
+ 6
+ then
+ else
+ if
+ 5
+ else
+ 4
+ then
+ then
+ else
+ if
+ if
+ 3
+ else
+ 2
+ then
+ else
+ if
+ 1
+ else
+ 0
+ then
+ then
+ then
+;
+
+ " if-test2.0" 0 0 0 if-test2 0 = .passed?
+ " if-test2.1" 1 0 0 if-test2 1 = .passed?
+ " if-test2.2" 0 1 0 if-test2 2 = .passed?
+ " if-test2.3" 1 1 0 if-test2 3 = .passed?
+ " if-test2.4" 0 0 1 if-test2 4 = .passed?
+ " if-test2.5" 1 0 1 if-test2 5 = .passed?
+ " if-test2.6" 0 1 1 if-test2 6 = .passed?
+ " if-test2.7" 1 1 1 if-test2 7 = .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/instance.fth b/usr/src/lib/efcode/fcode_test/instance.fth
new file mode 100644
index 0000000000..c37f08a5a1
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/instance.fth
@@ -0,0 +1,28 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+3 instance value ivar-foo
+4 instance value ivar-bar
diff --git a/usr/src/lib/efcode/fcode_test/loop.fth b/usr/src/lib/efcode/fcode_test/loop.fth
new file mode 100644
index 0000000000..72f860ea9e
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/loop.fth
@@ -0,0 +1,97 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
+\ CDDL HEADER START
+\
+\ The contents of this file are subject to the terms of the
+\ Common Development and Distribution License, Version 1.0 only
+\ (the "License"). You may not use this file except in compliance
+\ with the License.
+\
+\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ or http://www.opensolaris.org/os/licensing.
+\ See the License for the specific language governing permissions
+\ and limitations under the License.
+\
+\ When distributing Covered Code, include this CDDL HEADER in each
+\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ If applicable, add the following below this CDDL HEADER, with the
+\ fields enclosed by brackets "[]" replaced with your own identifying
+\ information: Portions Copyright [yyyy] [name of copyright owner]
+\
+\ CDDL HEADER END
+\
+
+." Interactive begin .. while .. repeat: "
+ " no loop (1) " 1 begin 0 while 1- repeat .passed?
+ " loop to 0 (1)" 9 begin dup while 1- repeat 0= .passed?
+cr
+." Compiled begin .. while .. repeat: "
+ : btest1 1 begin 0 while 1- repeat .passed? ;
+ : btest2 9 begin dup while 1- repeat 0= .passed? ;
+ " no loop (2) " btest1
+ " loop to 0 (2)" btest2
+cr
+." Interactive begin..until: "
+ " no loop (3)" 1 begin dup until .passed?
+ " loop to 0 (3)" 9 begin 1- dup 0= until 0= .passed?
+cr
+." Compiled begin..until: "
+ : btest3 1 begin dup until .passed? ;
+ : btest4 9 begin 1- dup 0= until 0= .passed? ;
+ " no loop (4)" btest3
+ " loop to 0 (4)" btest4
+cr
+." Interactive do .. loop: "
+ " loop (1)" 0 h# 10 0 do drop i loop h# f = .passed?
+ " no loop (1)" 1 0 0 ?do 1- loop .passed?
+ " leave (1)" h# 10 0 do i 5 = if 1 leave drop 0 then loop .passed?
+cr
+." Compiled do .. loop: "
+ : loop1 do drop i loop h# f = .passed? ;
+ : loop2 ?do 1- loop .passed? ;
+ : loop3 do i 3 = if drop i leave 0 then loop ;
+ : loop7 do i 4 = if drop i unloop exit then loop ;
+ " loop (2)" 0 h# 10 0 loop1
+ " no loop (2)" 1 0 0 loop2
+ " leave (2)" 3 4 0 loop3 3 = .passed?
+ " unloop" 5 6 0 loop7 4 = .passed?
+cr
+." Interactive do .. +loop: "
+ " loop by 2" 0 h# 10 0 do drop i 2 +loop h# e = .passed?
+ " loop down by 2" 0 -2 h# 10 do drop i -2 +loop h# -2 = .passed?
+cr
+." Compiled do .. +loop: "
+ : loop4 0 h# 10 0 do drop i 2 +loop h# e = .passed? ;
+ : loop5 0 -2 h# 10 do drop i -2 +loop -2 = .passed? ;
+ " loop (4)" loop4
+ " loop (5)" loop5
+cr
+." Nested loops: "
+ : loop6 0 h# 4 0 do 8 0 do 1 j 3 lshift i + lshift xor loop loop ;
+ " i,j sum" loop6 lwsplit over = swap h# ffff = and .passed?
+cr
+." Negative Limit Loops: "
+ " loop.7" h# 10 -37 8 bounds do drop i loop -30 = .passed?
+ " loop.8" h# 10 -37 -30 do drop i -1 +loop -37 = .passed?
+cr
+." Compiled begin...again: "
+ : loop9 begin true exit again false ; loop9 " loop9" rot .passed?
+ 0 value in-count
+ 0 value out-count
+ : loop10
+ begin
+ out-count 1+ to out-count
+ begin
+ in-count 10 >= if
+ exit
+ then in-count 1+ to in-count
+ again
+ -1 to in-count
+ exit
+ again
+ -2 to in-count
+ ;
+ " loop.10" loop10 in-count 10 = out-count 1 = and .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/misc.fth b/usr/src/lib/efcode/fcode_test/misc.fth
new file mode 100644
index 0000000000..20dee7aabd
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/misc.fth
@@ -0,0 +1,188 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Buffer: "
+ h# 20 buffer: my-unit-str
+ " abcd" my-unit-str pack drop
+ " pack.1" my-unit-str c@ 4 = .passed?
+ " pack.2" my-unit-str 1 + c@ ascii a = .passed?
+ " pack.3" my-unit-str 2 + c@ ascii b = .passed?
+ " pack.4" my-unit-str 3 + c@ ascii c = .passed?
+ " pack.5" my-unit-str 4 + c@ ascii d = .passed?
+ " count.1" my-unit-str count " abcd" $= .passed?
+cr
+
+." Formatting: "
+ " fmt.1" 1 h# 23 <# #s #> " 2300000001" $= .passed?
+ " fmt.2" 1 h# 23 <# # # #> " 01" $= .passed?
+ " fmt.3" h# 123 <# u#s u#> " 123" $= .passed?
+ " fmt.4" h# 123 <# u# ascii X hold u# u#> " 2X3" $= .passed?
+ d# 10 base !
+ " fmt.5" d# -123 <# dup abs u#s swap sign u#> " -123" $= .passed?
+ " fmt.6" d# 123 <# dup abs u#s swap sign u#> " 123" $= .passed?
+ " fmt.7" " -123" $number invert swap d# -123 = and .passed?
+ d# 16 base !
+ " fmt.8" " 32a" $number invert swap h# 32a = and .passed?
+ " fmt.9" " xyzzy" $number .passed?
+ : dnumber ( n -- str len )
+ base @ >r d# 10 base !
+ <# dup abs u#s swap sign u#>
+ r> base !
+ ;
+ " fmt.10" d# 12345678 dnumber " 12345678" $= .passed?
+ " fmt.11" d# -87654321 dnumber " -87654321" $= .passed?
+ " fmt.12" #out @ space #out @ 1 - = .passed?
+ " fmt.13" #line @ cr #out @ #line @ rot 1 + = swap 0= and .passed?
+ " fmt.14" #line @ (cr #out @ #line @ rot = swap 0= and .passed?
+ " fmt.15" bs h# 8 = .passed?
+ " fmt.16" bell h# 7 = .passed?
+ " fmt.17" bl h# 20 = .passed?
+ " fmt.18" ascii 5 d# 10 digit swap 5 = and .passed?
+ " fmt.19" ascii x d# 16 digit invert swap ascii x = and .passed?
+cr
+
+." (is-user-word): "
+ : xyzzy 1 2 3 ;
+ " xx" ' xyzzy (is-user-word)
+ " xx" $find if .passed space execute else .failed then
+ " iuw.1" 2 pick 3 = .passed?
+ " iuw.2" 3 pick 2 = .passed?
+ " iuw.3" 4 pick 1 = .passed?
+ drop drop drop
+cr
+
+." Move/Fill/Upper/Lower:"
+ " xyzzy" my-unit-str swap move
+ " move.1" my-unit-str " xyzzy" comp 0= .passed?
+ my-unit-str 9 ascii A fill
+ my-unit-str 6 ascii X fill
+ " fill.1" my-unit-str " XXXXXXAAA" comp 0= .passed?
+ 9 0 do my-unit-str i + dup c@ lcc swap c! loop
+ " lcc.1" my-unit-str " xxxxxxaaa" comp 0= .passed?
+ 9 0 do my-unit-str i + dup c@ upc swap c! loop
+ " upc.1" my-unit-str " XXXXXXAAA" comp 0= .passed?
+cr
+
+." >body/body>: "
+external
+ : xx 1 2 3 ;
+headers
+ " >body" ' xx >body ' xx /n + = .passed?
+ " body>" ' xx dup >body body> = .passed?
+cr
+
+." Fcode-revision: "
+ " Fcode-revision" fcode-revision h# 30000 = .passed?
+cr
+
+." Defer/Behavior: "
+ defer defer-word
+ ' xx to defer-word
+ " defer.1" defer-word 3 = swap 2 = and swap 1 = and .passed?
+ " behavior.1" ' defer-word behavior ' xx = .passed?
+cr
+
+." Aligned: "
+ variable alvar
+ " align.1" alvar aligned alvar = .passed?
+ " align.2" alvar /c - aligned alvar = .passed?
+ " align.3" alvar char+ aligned alvar la1+ = .passed?
+cr
+
+." Field: "
+struct
+ /n field >x1
+ /l field >x2
+ /w field >x3
+ /c field >x4
+constant /field-test
+ " field.1" /field-test /n /l /w /c + + + = .passed?
+ " field.2" 0 >x1 0 = .passed?
+ " field.3" 0 >x2 /n = .passed?
+ " field.4" 0 >x3 /n /l + = .passed?
+ " field.5" 0 >x4 /n /l /w + + = .passed?
+cr
+
+
+." Properties: "
+ 0 value root-phandle
+ " use-fake-handles" $find if execute else 2drop then
+ " /" " (cd)" $find if execute else 2drop then
+ " /" find-package if to root-phandle then
+ 1 encode-int " int-prop" property
+ 1 2 encode-phys " phys-prop" property
+ 1 2 3 reg
+ " XYZZY" model
+ 1 encode-int 2 encode-int encode+ " 2int-prop" property
+ " abcd" encode-string " string-prop" property
+ " wxyz" encode-bytes " bytes-prop" property
+ " prop.1" " bytes-prop" root-phandle get-package-property if
+ .failed
+ else
+ " wxyz" $= .passed?
+ then
+ " prop.2" " string-prop" root-phandle get-package-property if
+ .failed
+ else
+ decode-string " abcd" $= nip nip .passed?
+ then
+ " prop.3" " int-prop" root-phandle get-package-property if
+ .failed
+ else
+ decode-int 1 = nip nip .passed?
+ then
+ " prop.4" " phys-prop" root-phandle get-package-property if
+ .failed
+ else
+ decode-phys 2 = swap 1 = and nip nip .passed?
+ then
+ " prop.5" 0 0 root-phandle next-property if
+ " bytes-prop" $= .passed?
+ else
+ .failed
+ then
+ " prop.6" " string-prop" root-phandle next-property if
+ " 2int-prop" $= .passed?
+ else
+ .failed
+ then
+cr
+ " .properties" $find if execute else 2drop then
+cr
+
+." Timing/Alarm: "
+ " ms.1" get-msecs h# 100 ms get-msecs swap - h# 80 h# 150 between .passed?
+\ 0 value alarm-happened
+\ : alarm-word 1 to alarm-happened ." OK " ;
+\ ' alarm-word 10 alarm
+\ 0
+\ begin
+\ 1 + dup 1000000 > alarm-happened 0<> or
+\ until
+\ drop
+\ 0 0 alarm
+\ " alarm.1" alarm-happened .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/parse.fth b/usr/src/lib/efcode/fcode_test/parse.fth
new file mode 100644
index 0000000000..121cfdb3a1
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/parse.fth
@@ -0,0 +1,56 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+ ." parse:"
+ : $= ( str1 len1 str2 len2 -- true/false )
+ 2 pick <> if
+ 3drop false
+ else
+ swap dup 0= if
+ 3drop true
+ else
+ true swap 0 do
+ 2 pick i + c@
+ 2 pick i + c@
+ = and
+ loop nip nip
+ then
+ then
+ ;
+ : parse-test
+ " $= test.1" " abcd" " abcd" $= .passed?
+ " $= test.2" " abdc" " abcd" $= invert .passed?
+ " $= test.3" " abc" " abcd" $= invert .passed?
+ " 9600,8,n,1,-"
+ ascii , left-parse-string " 9600" $= " left-parse.1" rot .passed?
+ ascii , left-parse-string " 8" $= " left-parse.2" rot .passed?
+ ascii , left-parse-string " n" $= " left-parse.3" rot .passed?
+ ascii , left-parse-string " 1" $= " left-parse.4" rot .passed?
+ ascii , left-parse-string " -" $= " left-parse.5" rot .passed?
+ 2drop
+ ;
+ parse-test
+ cr
diff --git a/usr/src/lib/efcode/fcode_test/stack.fth b/usr/src/lib/efcode/fcode_test/stack.fth
new file mode 100644
index 0000000000..b0f4c2eb07
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/stack.fth
@@ -0,0 +1,56 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Stack Manipulation: "
+ " drop" 1 0 drop .passed?
+ " swap" 1 2 1 swap drop = .passed?
+ " nip" 1 0 1 nip - 0= .passed?
+ " over" 1 2 over 1 = nip nip .passed?
+ " dup" 1 dup = .passed?
+ " tuck" 2 1 tuck nip = .passed?
+ " rot" 3 2 1 rot 3 = nip nip .passed?
+ " -rot" 3 2 1 -rot 2 = nip nip .passed?
+ " 2rot" 1 2 3 4 5 6 2rot 2 = swap 1 = and swap 6 = and swap
+ 5 = and swap 4 = and swap 3 = and .passed?
+ " 2dup" 1 -1 2dup + 0= nip nip .passed?
+ " ?dup" 0 1 ?dup = nip .passed?
+ " 2swap" 1 1 0 0 2swap and nip nip .passed?
+ " 2drop" 1 1 0 0 2drop and .passed?
+ " 2over" 1 2 0 0 2over 2swap 2drop rot = -rot = = .passed?
+ " roll" 1 2 3 4 3 roll 1 = nip nip nip .passed?
+ " depth" 0 0 depth 4 = nip nip .passed?
+cr
+
+." Return Stack: "
+: test-rs
+ " >r" 3 1 >r 2 >r 3 = .passed?
+ " r@" 3 r@ 2 = nip .passed?
+ " r>" 3 r> 2 = r> 1 = and nip .passed?
+; test-rs
+: bail-test ( -- ) r> drop ;
+: bail ( -- ) 1 bail-test drop 0 ;
+ " Manipulate" bail .passed?
+cr
diff --git a/usr/src/lib/efcode/fcode_test/storage.fth b/usr/src/lib/efcode/fcode_test/storage.fth
new file mode 100644
index 0000000000..1ffa4f79fb
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/storage.fth
@@ -0,0 +1,46 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+." Runtime storage access: "
+ variable var-1 var-1 off
+ 4 constant const-1
+ 5 value val-1
+ " variable (off) (get)" var-1 @ 0= .passed?
+ " variable (on) (set)" var-1 on var-1 @ -1 = .passed?
+ " variable (set)" 2 var-1 ! var-1 @ 2 = .passed?
+ " constant.1" const-1 4 = .passed?
+ " value (get)" val-1 5 = .passed?
+ " value (set)" 2 to val-1 val-1 2 = .passed?
+cr
+
+." Compile time storage access: "
+ " variable (get)" : vtest1 var-1 @ = .passed? ; 2 vtest1
+ " variable (set)" : vtest2 1 var-1 ! 1 vtest1 ; vtest2
+ " constant.2" : ctest const-1 const-1 + 8 = .passed? ; ctest
+ " value (get)" : vtest3 val-1 = .passed? ; 2 vtest3
+ " value (set)" : vtest4 1 to val-1 1 vtest3 ; vtest4
+cr
+
diff --git a/usr/src/lib/efcode/fcode_test/test.fth b/usr/src/lib/efcode/fcode_test/test.fth
new file mode 100644
index 0000000000..86e27b33f7
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/test.fth
@@ -0,0 +1,70 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ Use is subject to license terms.
+\
+\ CDDL HEADER START
+\
+\ The contents of this file are subject to the terms of the
+\ Common Development and Distribution License, Version 1.0 only
+\ (the "License"). You may not use this file except in compliance
+\ with the License.
+\
+\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ or http://www.opensolaris.org/os/licensing.
+\ See the License for the specific language governing permissions
+\ and limitations under the License.
+\
+\ When distributing Covered Code, include this CDDL HEADER in each
+\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ If applicable, add the following below this CDDL HEADER, with the
+\ fields enclosed by brackets "[]" replaced with your own identifying
+\ information: Portions Copyright [yyyy] [name of copyright owner]
+\
+\ CDDL HEADER END
+\
+
+fcode-version1
+
+alias headerless headers
+
+ fload calling.fth
+ noop
+ : .noop noop noop ;
+
+ : .failed ." failed!" ;
+
+ : .passed ." OK" ;
+
+ fload iftest.fth
+
+ : .chkstk depth if ." Stack Changed: " .s cr then ;
+
+ .chkstk
+ fload arithmetic.fth
+ .chkstk
+ fload stack.fth
+ .chkstk
+ fload create.fth
+ .chkstk
+ fload bytemanipulate.fth
+ .chkstk
+ fload loop.fth
+ .chkstk
+ fload storage.fth
+ .chkstk
+ fload access.fth
+ .chkstk
+ fload case.fth
+ .chkstk
+ fload catch.fth
+ .chkstk
+ fload parse.fth
+ .chkstk
+ fload find.fth
+ .chkstk
+ fload misc.fth
+ .chkstk
+ cr ." End of Tests" cr
+
+end0
+
diff --git a/usr/src/lib/efcode/fcode_test/test64.fth b/usr/src/lib/efcode/fcode_test/test64.fth
new file mode 100644
index 0000000000..56088018a5
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/test64.fth
@@ -0,0 +1,126 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+fcode-version1
+." 64-bit Fcode operation tests" cr
+
+ : .failed ." failed!" ;
+
+ : .passed ." OK" ;
+
+ : .chkstk depth if ." Stack Changed: " .s cr then ;
+
+ : .passed? ( str,len flag )
+ if if then if then .passed space else cr type space .failed cr then
+ ;
+
+\ comparisons only 32-bit...
+: xl= ( xv lh ll -- flag )
+ swap rot xlsplit rot = -rot = and
+;
+
+: x= ( xv1 xv2 -- flag )
+ xlsplit rot xlsplit rot = -rot = and
+;
+create test-64
+ h# 01020304 l,
+ h# 05060708 l,
+ h# 81121314 l,
+ h# 85161718 l,
+ h# ffffffff l,
+ h# 80000000 l,
+
+." 64-bit access tests: "
+ " /x.1" /x 8 = .passed?
+ " xa1+.1" test-64 xa1+ test-64 /x + = .passed?
+ " xa+.1" test-64 2 xa+ test-64 /x 2 * + = .passed?
+ " x@.1" test-64 x@ h# 01020304 h# 05060708 xl= .passed?
+ " x@.2" test-64 xa1+ x@ h# 81121314 h# 85161718 xl= .passed?
+ " <l@.1" test-64 2 xa+ dup la1+ <l@ swap x@ x= .passed?
+ " bxjoin.1" 8 7 6 5 4 3 2 1 bxjoin test-64 x@ x= .passed?
+ " wxjoin.1" h# 0708 h# 0506 h# 0304 h# 0102 wxjoin test-64 x@ x= .passed?
+ " lxjoin.1" h# 05060708 h# 01020304 lxjoin test-64 x@ x= .passed?
+ " x!.1" h# 85161718 h# 81121314 lxjoin test-64 x!
+ test-64 x@ h# 81121314 h# 85161718 xl= .passed?
+ " x!.2" h# 05060708 h# 01020304 lxjoin test-64 x!
+ test-64 x@ h# 01020304 h# 05060708 xl= .passed?
+cr
+." 64-bit flips: "
+ " xbflip.1" test-64 x@ xbflip h# 08070605 h# 04030201 xl= .passed?
+ " xwflip.1" test-64 x@ xwflip h# 07080506 h# 03040102 xl= .passed?
+ " xlflip.1" test-64 x@ xlflip h# 05060708 h# 01020304 xl= .passed?
+ " xbsplit.1" test-64 x@ xbsplit bxjoin test-64 x@ x= .passed?
+ " xwsplit.1" test-64 x@ xwsplit wxjoin test-64 x@ x= .passed?
+ " xlsplit.1" test-64 x@ xlsplit lxjoin test-64 x@ x= .passed?
+ " xbflips.1" test-64 /x xbflips test-64 x@
+ h# 08070605 h# 04030201 xl= .passed?
+ " xbflips.2" test-64 /x xbflips test-64 x@
+ h# 01020304 h# 05060708 xl= .passed?
+ " xwflips.1" test-64 /x xwflips test-64 x@
+ h# 07080506 h# 03040102 xl= .passed?
+ " xwflips.2" test-64 /x xwflips test-64 x@
+ h# 01020304 h# 05060708 xl= .passed?
+ " xlflips.1" test-64 /x xlflips test-64 x@
+ h# 05060708 h# 01020304 xl= .passed?
+ " xlflips.2" test-64 /x xlflips test-64 x@
+ h# 01020304 h# 05060708 xl= .passed?
+cr
+
+
+0 value commatest-64-end
+create commatest-64
+ h# 01020304 h# 05060708 swap lxjoin x,
+ h# 81121314 h# 85161718 swap lxjoin x,
+ h# ffffffff h# 80000000 swap lxjoin x,
+ here to commatest-64-end
+
+." 64-bit xcomma: "
+ " x,.1" commatest-64 3 xa+ commatest-64-end = .passed?
+ " x,.2" test-64 x@ commatest-64 x@ x= .passed?
+ " x,.3" test-64 xa1+ x@ commatest-64 xa1+ x@ x= .passed?
+ " x,.4" test-64 2 xa+ x@ commatest-64 2 xa+ x@ x= .passed?
+cr
+
+." 64-bit constant/value/variable: "
+1 2 lxjoin constant const-64
+1 2 lxjoin value value-64
+variable var-64
+ " const.1" const-64 2 1 xl= .passed?
+ " value.1" value-64 2 1 xl= .passed?
+ " value.2" 3 4 lxjoin to value-64 value-64 4 3 xl= .passed?
+ " var.1" const-64 var-64 ! var-64 @ 2 1 xl= .passed?
+cr
+
+." 64-bit comparisions: "
+ \ FCode comparators are 32-bit only, upper 32-bits are ignored.
+ " 64comp.1" 1 2 lxjoin 1 = .passed?
+ " 64comp.2" 1 2 lxjoin 2 < .passed?
+ " 64comp.3" 2 1 2 lxjoin > .passed?
+ " 64comp.4" 0 2 lxjoin 0= .passed?
+ " 64comp.5" 1 2 lxjoin 0> .passed?
+cr
+
+end0
diff --git a/usr/src/lib/efcode/fcode_test/values.fth b/usr/src/lib/efcode/fcode_test/values.fth
new file mode 100644
index 0000000000..296f0e0387
--- /dev/null
+++ b/usr/src/lib/efcode/fcode_test/values.fth
@@ -0,0 +1,29 @@
+\ #ident "%Z%%M% %I% %E% SMI"
+\ purpose:
+\ copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+\ copyright: Use is subject to license terms.
+\ copyright:
+\ copyright: CDDL HEADER START
+\ copyright:
+\ copyright: The contents of this file are subject to the terms of the
+\ copyright: Common Development and Distribution License, Version 1.0 only
+\ copyright: (the "License"). You may not use this file except in compliance
+\ copyright: with the License.
+\ copyright:
+\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+\ copyright: or http://www.opensolaris.org/os/licensing.
+\ copyright: See the License for the specific language governing permissions
+\ copyright: and limitations under the License.
+\ copyright:
+\ copyright: When distributing Covered Code, include this CDDL HEADER in each
+\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+\ copyright: If applicable, add the following below this CDDL HEADER, with the
+\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
+\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
+\ copyright:
+\ copyright: CDDL HEADER END
+\ copyright:
+
+external
+1 value var-foo
+2 value var-bar