optimize unit tester to use clear as EMPTY-STACK

This commit is contained in:
mgcaret 2019-12-27 11:05:26 -08:00
parent 513aefa0c4
commit 3bfba53afb
1 changed files with 7 additions and 2 deletions

View File

@ -31,8 +31,11 @@ VARIABLE VERBOSE
FALSE VERBOSE ! FALSE VERBOSE !
\ TRUE VERBOSE ! \ TRUE VERBOSE !
: EMPTY-STACK \ ( ... -- ) EMPTY STACK: HANDLES UNDERFLOWED STACK TOO. \ : EMPTY-STACK \ ( ... -- ) EMPTY STACK: HANDLES UNDERFLOWED STACK TOO.
DEPTH ?DUP IF DUP 0< IF NEGATE 0 DO 0 LOOP ELSE 0 DO DROP LOOP THEN THEN ; \ DEPTH ?DUP IF DUP 0< IF NEGATE 0 DO 0 LOOP ELSE 0 DO DROP LOOP THEN THEN ;
\ THE IEEE-1275 CLEAR word works the same but the standard does not define
\ an FCode for it...
defer EMPTY-STACK s" ' clear" eval to EMPTY-STACK
VARIABLE #ERRORS 0 #ERRORS ! VARIABLE #ERRORS 0 #ERRORS !
@ -50,6 +53,8 @@ CREATE ACTUAL-RESULTS 20 CELLS ALLOT
: T{ \ ( -- ) SYNTACTIC SUGAR. : T{ \ ( -- ) SYNTACTIC SUGAR.
; ;
\ FCode tokenizer will issue a warning for this
\ it can be ignored
: -> \ ( ... -- ) RECORD DEPTH AND CONTENT OF STACK. : -> \ ( ... -- ) RECORD DEPTH AND CONTENT OF STACK.
DEPTH DUP ACTUAL-DEPTH ! \ RECORD DEPTH DEPTH DUP ACTUAL-DEPTH ! \ RECORD DEPTH
?DUP IF \ IF THERE IS SOMETHING ON STACK ?DUP IF \ IF THERE IS SOMETHING ON STACK