\ @(#) t_tools.fth 97/12/10 1.1
\ Based on testing tools from John Hayes
\ (c) 1993 Johns Hopkins University / Applied Physics Laboratory
\ Syntax was changed to avoid conflict with { -> and } for local variables.
\ Also added tracking of #successes and #errors.
test-passed @ 4 .r ." passed, "
test-failed @ 4 .r ." failed." cr
VARIABLE actual-depth \ stack record
CREATE actual-results 20 CELLS ALLOT
: empty-stack \ ( ... -- ) Empty stack.
CREATE the-test 128 CHARS ALLOT
: ERROR \ ( c-addr u -- ) Display an error message followed by
\ the line that had the error.
TYPE the-test COUNT TYPE CR \ display line corresponding to error
empty-stack \ throw away every thing else
: }T{ \ ( ... -- ) Record depth and content of stack.
DEPTH actual-depth ! \ record depth
actual-results I CELLS + !
: }T \ ( ... -- ) Compare stack (expected) contents with saved
1 test-passed +! \ assume will pass
?DO \ for each stack item
actual-results I CELLS + @ \ compare actual with expected
S" INCORRECT RESULT: " error
S" WRONG NUMBER OF RESULTS: " error