1 \ @(#) t_tools.fth 97/12/10 1.1
\r
2 \ Test Tools for pForth
\r
4 \ Based on testing tools from John Hayes
\r
5 \ (c) 1993 Johns Hopkins University / Applied Physics Laboratory
\r
7 \ Syntax was changed to avoid conflict with { -> and } for local variables.
\r
8 \ Also added tracking of #successes and #errors.
\r
10 anew task-t_tools.fth
\r
15 variable TEST-PASSED
\r
16 variable TEST-FAILED
\r
26 test-passed @ 4 .r ." passed, "
\r
27 test-failed @ 4 .r ." failed." cr
\r
31 VARIABLE actual-depth \ stack record
\r
32 CREATE actual-results 20 CELLS ALLOT
\r
34 : empty-stack \ ( ... -- ) Empty stack.
\r
40 CREATE the-test 128 CHARS ALLOT
\r
42 : ERROR \ ( c-addr u -- ) Display an error message followed by
\r
43 \ the line that had the error.
\r
44 TYPE the-test COUNT TYPE CR \ display line corresponding to error
\r
45 empty-stack \ throw away every thing else
\r
50 source the-test place
\r
54 : }T{ \ ( ... -- ) Record depth and content of stack.
\r
55 DEPTH actual-depth ! \ record depth
\r
58 actual-results I CELLS + !
\r
62 : }T \ ( ... -- ) Compare stack (expected) contents with saved
\r
63 \ (actual) contents.
\r
66 IF \ if depths match
\r
67 1 test-passed +! \ assume will pass
\r
69 ?DO \ for each stack item
\r
70 actual-results I CELLS + @ \ compare actual with expected
\r
75 S" INCORRECT RESULT: " error
\r
79 ELSE \ depth mismatch
\r
81 S" WRONG NUMBER OF RESULTS: " error
\r