3 \ Date: Mon, 27 Nov 95 13:10:09 PST
4 \ john.hayes@jhuapl.edu
5 \ (C) 1995 JOHNS HOPKINS UNIVERSITY / APPLIED PHYSICS LABORATORY
6 \ MAY BE DISTRIBUTED FREELY AS LONG AS THIS COPYRIGHT NOTICE REMAINS.
9 \ jws notes: <> is a core ext word
13 \ SET THE FOLLOWING FLAG TO TRUE FOR MORE VERBOSE OUTPUT; THIS MAY
14 \ ALLOW YOU TO TELL WHICH TEST CAUSED YOUR SYSTEM TO HANG.
18 : EMPTY-STACK \ ( ... -- ) EMPTY STACK: HANDLES UNDERFLOWED STACK TOO.
19 DEPTH ?DUP IF DUP 0< IF NEGATE 0 DO 0 LOOP ELSE 0 DO DROP LOOP THEN THEN ;
21 : ERROR \ ( C-ADDR U -- ) DISPLAY AN ERROR MESSAGE FOLLOWED BY
22 \ THE LINE THAT HAD THE ERROR.
23 TYPE SOURCE TYPE CR \ DISPLAY LINE CORRESPONDING TO ERROR
24 EMPTY-STACK \ THROW AWAY EVERY THING ELSE
28 VARIABLE ACTUAL-DEPTH \ STACK RECORD
30 CREATE ACTUAL-RESULTS 20 CELLS ALLOT
32 : { \ ( -- ) SYNTACTIC SUGAR.
35 : -> \ ( ... -- ) RECORD DEPTH AND CONTENT OF STACK.
36 DEPTH DUP ACTUAL-DEPTH ! \ RECORD DEPTH
37 ?DUP IF \ IF THERE IS SOMETHING ON STACK
38 0 DO ACTUAL-RESULTS I CELLS + ! LOOP \ SAVE THEM
41 : } \ ( ... -- ) COMPARE STACK (EXPECTED) CONTENTS WITH SAVED
43 DEPTH ACTUAL-DEPTH @ = IF \ IF DEPTHS MATCH
44 DEPTH ?DUP IF \ IF THERE IS SOMETHING ON THE STACK
45 0 DO \ FOR EACH STACK ITEM
46 ACTUAL-RESULTS I CELLS + @ \ COMPARE ACTUAL WITH EXPECTED
47 <> IF S" INCORRECT RESULT: " ERROR LEAVE THEN
51 S" WRONG NUMBER OF RESULTS: " ERROR
54 : TESTING \ ( -- ) TALKING COMMENT.
56 IF DUP >R TYPE CR R> >IN !