xref: /titanic_44/usr/src/lib/efcode/fcode_test/stack.fth (revision 2b4a78020b9c38d1b95e2f3fefa6d6e4be382d1f)
1\ #ident	"%Z%%M%	%I%	%E% SMI"
2\ purpose:
3\ copyright: Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
4\ copyright: Use is subject to license terms.
5\ copyright:
6\ copyright: CDDL HEADER START
7\ copyright:
8\ copyright: The contents of this file are subject to the terms of the
9\ copyright: Common Development and Distribution License, Version 1.0 only
10\ copyright: (the "License").  You may not use this file except in compliance
11\ copyright: with the License.
12\ copyright:
13\ copyright: You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14\ copyright: or http://www.opensolaris.org/os/licensing.
15\ copyright: See the License for the specific language governing permissions
16\ copyright: and limitations under the License.
17\ copyright:
18\ copyright: When distributing Covered Code, include this CDDL HEADER in each
19\ copyright: file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20\ copyright: If applicable, add the following below this CDDL HEADER, with the
21\ copyright: fields enclosed by brackets "[]" replaced with your own identifying
22\ copyright: information: Portions Copyright [yyyy] [name of copyright owner]
23\ copyright:
24\ copyright: CDDL HEADER END
25\ copyright:
26
27." Stack Manipulation: "
28	" drop"		1 0 drop		.passed?
29	" swap"		1 2 1 swap drop =	.passed?
30	" nip"		1 0 1 nip - 0=		.passed?
31	" over"		1 2 over 1 = nip nip	.passed?
32	" dup"		1 dup =			.passed?
33	" tuck"		2 1 tuck nip =		.passed?
34	" rot"		3 2 1 rot 3 = nip nip	.passed?
35	" -rot"		3 2 1 -rot 2 = nip nip	.passed?
36	" 2rot"		1 2 3 4 5 6 2rot 2 = swap 1 = and swap 6 = and swap
37			   5 = and swap 4 = and swap 3 = and .passed?
38	" 2dup"		1 -1 2dup + 0= nip nip	.passed?
39	" ?dup"		0 1 ?dup = nip 		.passed?
40	" 2swap"	1 1 0 0 2swap and nip nip .passed?
41	" 2drop"	1 1 0 0 2drop and	.passed?
42	" 2over"	1 2 0 0 2over 2swap 2drop rot = -rot = = .passed?
43	" roll"		1 2 3 4 3 roll 1 = nip nip nip .passed?
44	" depth"	0 0 depth 4 = nip nip .passed?
45cr
46
47." Return Stack: "
48: test-rs
49	" >r"		3 1 >r 2 >r 3 =		.passed?
50	" r@"		3 r@ 2 = nip		.passed?
51	" r>"		3 r> 2 = r> 1 = and nip	.passed?
52;  test-rs
53: bail-test ( -- )	r> drop  ;
54: bail ( -- )		1 bail-test drop 0 ;
55	" Manipulate"	bail			.passed?
56cr
57