1 \ @(#) t_tools.fth 97/12/10 1.1
2 \ Test Tools for pForth
4 \ Based on testing tools from John Hayes
5 \ (c) 1993 Johns Hopkins University / Applied Physics Laboratory
7 \ Syntax was changed to avoid conflict with { -> and } for local variables.
8 \ Also added tracking of #successes and #errors.
17 40 constant TEST_EXIT_FAILURE \ returned form pForth to shell
27 test-passed @ 4 .r ." passed, "
28 test-failed @ 4 .r ." failed." cr
30 TEST_EXIT_FAILURE bye-code !
35 VARIABLE actual-depth \ stack record
36 CREATE actual-results 20 CELLS ALLOT
38 : empty-stack \ ( ... -- ) Empty stack.
44 CREATE the-test 128 CHARS ALLOT
46 : ERROR \ ( c-addr u -- ) Display an error message followed by
47 \ the line that had the error.
48 TYPE the-test COUNT TYPE CR \ display line corresponding to error
49 empty-stack \ throw away every thing else
58 : }T{ \ ( ... -- ) Record depth and content of stack.
59 DEPTH actual-depth ! \ record depth
62 actual-results I CELLS + !
66 : }T \ ( ... -- ) Compare stack (expected) contents with saved
71 1 test-passed +! \ assume will pass
73 ?DO \ for each stack item
74 actual-results I CELLS + @ \ compare actual with expected
79 S" INCORRECT RESULT: " error
85 S" WRONG NUMBER OF RESULTS: " error