-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.frt
43 lines (38 loc) · 785 Bytes
/
test.frt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
\ a portion of the Forth core test suite
\ (C) 1995 JOHNS HOPKINS UNIVERSITY / APPLIED PHYSICS LABORATORY
\ MAY BE DISTRIBUTED FREELY AS LONG AS THIS COPYRIGHT NOTICE REMAINS.
CREATE ACTUAL-RESULTS $20 CELLS ALLOT
VARIABLE ACTUAL-DEPTH
VARIABLE START-DEPTH
: EMPTY-STACK S0 SP! ;
: ERROR TYPE CR EMPTY-STACK ABORT ;
: T{ DEPTH START-DEPTH ! ;
: ->
DEPTH DUP ACTUAL-DEPTH !
START-DEPTH @ - 0 ?DO
ACTUAL-RESULTS I CELLS + !
LOOP
;
: }T
DEPTH ACTUAL-DEPTH @ = IF
DEPTH START-DEPTH @ - 0 ?DO
ACTUAL-RESULTS I CELLS + @
<> IF
S" INCORRECT RESULT" ERROR LEAVE
THEN
LOOP
ELSE
S" WRONG NUMBER OF RESULTS" ERROR
THEN
;
: TESTING
." TESTING "
BEGIN
KEY DUP #CR <>
WHILE
EMIT
REPEAT
DROP
CR
;
CONCLUDE" CORETEST.FRT"