The code in the files Common\TESTS\MPE\7-1-A.FTH and Common\TESTS\MPE\7-1-B.FTH contains a test harness and tests respectively for MPE kernels. The files for previous v5 and v6 compilers are still present in the directory, but are no longer supported.
Test code may be cross-compiled or used interactively.
This section just describes the mechanics of the test harness. How to use it is covered in the next section.
variable Stack1 \ -- addr
Stack depth marker. Depth at entry to stack check.
variable Stack2 \ -- addr
Stack depth marker. Depth before entry of test word.
variable Stack3 \ -- addr
Stack depth marker. Depth after execution of test word.
variable Test-Line# \ -- addr
Holds line number of word under test
variable Left-Loop \ -- addr
Holds flag for early loop exit
: .decimal ( n -- ) base @ swap decimal . base ! ;
Display in decimal.
: Check-Element \ element# -- t/f
Check a value on the output stack.
: Check-Stack \ sentinel --
Check stack for corruption.
A word is executed surrounded by formal stack definitions containing the test inputs and required outputs. A test is written in the form:
DS( inputs --) <WORD> (-- outputs )DS
for example:
ds( $05555 $0aaaa --) or (-- 0ffff )ds
Note that the input and output expressions can contain executable Forth as well as literals. You are not restricted to a single word under test: you can use a phrase.
: Ds( \ -- sentinel
Start defining the input data.
: --) \ .. -- ..
Finish defining the input data.
: (-- \ .. -- ..
Start defining the correct outputs.
: )Ds \ ... --
Finish defining the correct outputs.
After the ANS Forth process, John Hayes at JHU/APL developed
an ANS test suite. A version slightly modified by MPE for use
with cross compilers can be found in Common\Tests\ANS.
Cross compile Tester.fth, and then INCLUDE
test
files as required.