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.
26 test-passed @ 4 .r ." passed, "
27 test-failed @ 4 .r ." failed." cr
31 VARIABLE actual-depth \ stack record
32 CREATE actual-results 20 CELLS ALLOT
34 : empty-stack \ ( ... -- ) Empty stack.
40 CREATE the-test 128 CHARS ALLOT
42 : ERROR \ ( c-addr u -- ) Display an error message followed by
43 \ the line that had the error.
44 TYPE the-test COUNT TYPE CR \ display line corresponding to error
45 empty-stack \ throw away every thing else
54 : }T{ \ ( ... -- ) Record depth and content of stack.
55 DEPTH actual-depth ! \ record depth
58 actual-results I CELLS + !
62 : }T \ ( ... -- ) Compare stack (expected) contents with saved
67 1 test-passed +! \ assume will pass
69 ?DO \ for each stack item
70 actual-results I CELLS + @ \ compare actual with expected
75 S" INCORRECT RESULT: " error
81 S" WRONG NUMBER OF RESULTS: " error