xref: /titanic_51/usr/src/lib/efcode/fcode_test/iftest.fth (revision a31148363f598def767ac48c5d82e1572e44b935)
1\ #ident	"%Z%%M%	%I%	%E% SMI"
2\ Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3\ Use is subject to license terms.
4\
5\ CDDL HEADER START
6\
7\ The contents of this file are subject to the terms of the
8\ Common Development and Distribution License, Version 1.0 only
9\ (the "License").  You may not use this file except in compliance
10\ with the License.
11\
12\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13\ or http://www.opensolaris.org/os/licensing.
14\ See the License for the specific language governing permissions
15\ and limitations under the License.
16\
17\ When distributing Covered Code, include this CDDL HEADER in each
18\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19\ If applicable, add the following below this CDDL HEADER, with the
20\ fields enclosed by brackets "[]" replaced with your own identifying
21\ information: Portions Copyright [yyyy] [name of copyright owner]
22\
23\ CDDL HEADER END
24\
25
26cr ." Simple interpreted IF THEN test: "
271 if .passed then space
280 if .failed then space
29cr
30
31." Simple interpreted IF ELSE THEN test: "
320 if .failed else .passed then space
331 if .passed else .failed then space
34cr
35
36." Nested interpreted IF test: "
371 1 1 0 0 1 0 0
38if	if .failed	else .failed	then space
39else	if .failed	else .passed	then space
40then
41if	if .failed	else .passed	then space
42else	if .failed	else .failed	then space
43then
44if	if .failed	else .failed	then space
45else	if .passed	else .failed	then space
46then
47if	if .passed	else .failed	then space
48else	if .failed	else .failed	then space
49then
50cr
51
52." Compiled single IF tests:" space
53: if-true?	if .passed space 0 exit	then .failed space 0 ;	1 if-true?
54: if-false?	if .failed space 1 exit	then .passed space 1 ;	if-false?
55: true?		if .passed else .failed then space 0 ;		true?
56: false?	if .failed else .passed then space ;		false?
57
58cr
59
60." Nested compiled IF test: "
61: if-test1 ( -- )
62   0 1 0 if
63      .failed
64   else
65      if
66         dup if .failed then
67         if .failed else .passed then
68      else
69         .failed
70      then
71   then
72; if-test1 space
73
74: .passed?  ( str,len flag )
75   if if then if then .passed  space else  cr type space .failed cr then
76;
77
78: if-test2 ( x x x -- )
79   if
80      if
81         if
82            7
83         else
84            6
85         then
86      else
87         if
88            5
89         else
90            4
91         then
92      then
93   else
94      if
95         if
96            3
97         else
98            2
99         then
100      else
101         if
102            1
103         else
104            0
105         then
106      then
107   then
108;
109
110 " if-test2.0"   0 0 0 if-test2 0 = .passed?
111 " if-test2.1"   1 0 0 if-test2 1 = .passed?
112 " if-test2.2"   0 1 0 if-test2 2 = .passed?
113 " if-test2.3"   1 1 0 if-test2 3 = .passed?
114 " if-test2.4"   0 0 1 if-test2 4 = .passed?
115 " if-test2.5"   1 0 1 if-test2 5 = .passed?
116 " if-test2.6"   0 1 1 if-test2 6 = .passed?
117 " if-test2.7"   1 1 1 if-test2 7 = .passed?
118cr
119