version 1.5, 2007/08/28 19:26:11

version 1.6, 2007/10/26 12:47:41

Line 1

Line 1

\ for the original tester 
\ FOR THE ORIGINAL TESTER 
\ From: John Hayes S1I 
\ FROM: JOHN HAYES S1I 
\ Subject: tester.fr 
\ SUBJECT: TESTER.FR 
\ Date: Mon, 27 Nov 95 13:10:09 PST 
\ DATE: MON, 27 NOV 95 13:10:09 PST 
\ (C) 1995 JOHNS HOPKINS UNIVERSITY / APPLIED PHYSICS LABORATORY 
\ (C) 1995 JOHNS HOPKINS UNIVERSITY / APPLIED PHYSICS LABORATORY 
\ MAY BE DISTRIBUTED FREELY AS LONG AS THIS COPYRIGHT NOTICE REMAINS. 
\ MAY BE DISTRIBUTED FREELY AS LONG AS THIS COPYRIGHT NOTICE REMAINS. 
\ VERSION 1.1 
\ VERSION 1.1 


\ for the FNEARLY= stuff: 
\ FOR THE FNEARLY= STUFF: 
\ from ftester.fs written by David N. Williams, based on the idea of 
\ FROM FTESTER.FS WRITTEN BY DAVID N. WILLIAMS, BASED ON THE IDEA OF 
\ approximate equality in Dirk Zoller's float.4th 
\ APPROXIMATE EQUALITY IN DIRK ZOLLER'S FLOAT.4TH 
\ public domain 
\ PUBLIC DOMAIN 


\ for the rest: 
\ FOR THE REST: 
\ revised by Anton Ertl 20070812, 20070819, 20070828 
\ REVISED BY ANTON ERTL 20070812, 20070819, 20070828 
\ public domain 
\ PUBLIC DOMAIN 


\ The original has the following shortcomings: 
\ THE ORIGINAL HAS THE FOLLOWING SHORTCOMINGS: 


\  It does not work as expected if the stack is nonempty before the {. 
\  IT DOES NOT WORK AS EXPECTED IF THE STACK IS NONEMPTY BEFORE THE {. 


\  It does not check FP results if the system has a separate FP stack. 
\  IT DOES NOT CHECK FP RESULTS IF THE SYSTEM HAS A SEPARATE FP STACK. 


\  There is a conflict with the use of } for FSL arrays and { for locals. 
\  THERE IS A CONFLICT WITH THE USE OF } FOR FSL ARRAYS AND { FOR LOCALS. 


\ I have revised it to address these shortcomings. You can find the 
\ I HAVE REVISED IT TO ADDRESS THESE SHORTCOMINGS. YOU CAN FIND THE 
\ result at 
\ RESULT AT 


\ http://www.forth200x.org/tests/tester.fs 
\ HTTP://WWW.FORTH200X.ORG/TESTS/TESTER.FS 
\ http://www.forth200x.org/tests/ttester.fs 
\ HTTP://WWW.FORTH200X.ORG/TESTS/TTESTER.FS 


\ tester.fs is intended to be a dropin replacement of the original. 
\ TESTER.FS IS INTENDED TO BE A DROPIN REPLACEMENT OF THE ORIGINAL. 


\ ttester.fs is a version that uses T{ and }T instead of { and } and 
\ TTESTER.FS IS A VERSION THAT USES T{ AND }T INSTEAD OF { AND } AND 
\ keeps the BASE as it was before loading ttester.fs 
\ KEEPS THE BASE AS IT WAS BEFORE LOADING TTESTER.FS 


\ In spirit of the original, I have strived to avoid any potential 
\ IN SPIRIT OF THE ORIGINAL, I HAVE STRIVED TO AVOID ANY POTENTIAL 
\ nonportabilities and stayed as much within the CORE words as 
\ NONPORTABILITIES AND STAYED AS MUCH WITHIN THE CORE WORDS AS 
\ possible; e.g., FLOATING words are used only if the FLOATING wordset 
\ POSSIBLE; E.G., FLOATING WORDS ARE USED ONLY IF THE FLOATING WORDSET 
\ is present 
\ IS PRESENT 


\ There are a few things to be noted: 
\ THERE ARE A FEW THINGS TO BE NOTED: 


\  Loading ttester.fs does not change BASE. Loading tester.fs 
\  LOADING TTESTER.FS DOES NOT CHANGE BASE. LOADING TESTER.FS 
\ changes BASE to HEX (like the original tester). Floatingpoint 
\ CHANGES BASE TO HEX (LIKE THE ORIGINAL TESTER). FLOATINGPOINT 
\ input is ambiguous when the base is not decimal, so you have to set 
\ INPUT IS AMBIGUOUS WHEN THE BASE IS NOT DECIMAL, SO YOU HAVE TO SET 
\ it to decimal yourself when you want to deal with decimal numbers. 
\ IT TO DECIMAL YOURSELF WHEN YOU WANT TO DEAL WITH DECIMAL NUMBERS. 


\  For FP it is often useful to use approximate equality for checking 
\  FOR FP IT IS OFTEN USEFUL TO USE APPROXIMATE EQUALITY FOR CHECKING 
\ the results. You can turn on approximate matching with SETNEAR 
\ THE RESULTS. YOU CAN TURN ON APPROXIMATE MATCHING WITH SETNEAR 
\ (and turn it off (default) with SETEXACT, and you can tune it by 
\ (AND TURN IT OFF (DEFAULT) WITH SETEXACT, AND YOU CAN TUNE IT BY 
\ setting the variables RELNEAR and ABSNEAR. If you want your tests 
\ SETTING THE VARIABLES RELNEAR AND ABSNEAR. IF YOU WANT YOUR TESTS 
\ to work with a shared stack, you have to specify the types of the 
\ TO WORK WITH A SHARED STACK, YOU HAVE TO SPECIFY THE TYPES OF THE 
\ elements on the stack by using one of the closing words that specify 
\ ELEMENTS ON THE STACK BY USING ONE OF THE CLOSING WORDS THAT SPECIFY 
\ types, e.g. RRRX}T for checking the stack picture ( r r r x ). 
\ TYPES, E.G. RRRX}T FOR CHECKING THE STACK PICTURE ( R R R X ). 
\ There are such words for all combination of R and X with up to 4 
\ THERE ARE SUCH WORDS FOR ALL COMBINATION OF R AND X WITH UP TO 4 
\ stack items, and defining more if you need them is straightforward 
\ STACK ITEMS, AND DEFINING MORE IF YOU NEED THEM IS STRAIGHTFORWARD 
\ (see source). If your tests are only intended for a separatestack 
\ (SEE SOURCE). IF YOUR TESTS ARE ONLY INTENDED FOR A SEPARATESTACK 
\ system or if you need only exact matching, you can use the plain }T 
\ SYSTEM OR IF YOU NEED ONLY EXACT MATCHING, YOU CAN USE THE PLAIN }T 
\ instead. 
\ INSTEAD. 


BASE @ 
BASE @ 
HEX 
HEX 
Line 192 HASFLOATINGSTACK [IF]

Line 192 HASFLOATINGSTACK [IF]



: F...}T (  ) 
: F...}T (  ) 
FDEPTH STARTFDEPTH @ = 0= IF 
FDEPTH STARTFDEPTH @ = 0= IF 
S" WRONG NUMBER OF FP RESULTS" ERROR 
S" NUMBER OF FLOAT RESULTS BEFORE AND AFTER '>' DOES NOT MATCH: " ERROR 
THEN 
THEN 
FCURSOR @ ACTUALFDEPTH @ <> IF 
FCURSOR @ STARTFDEPTH @ + ACTUALFDEPTH @ <> IF 
S" WRONG NUMBER OF FP RESULTS" ERROR 
S" NUMBER OF FLOAT RESULTS BEFORE '>' DOES NOT MATCH ...}T SPRECIFICATION: " ERROR 
THEN ; 
THEN ; 


: FTESTER ( R  ) 
: FTESTER ( R  ) 
FDEPTH 0= ACTUALFDEPTH @ FCURSOR @ 1+ < OR IF 
FDEPTH 0= ACTUALFDEPTH @ FCURSOR @ STARTFDEPTH @ + 1+ < OR IF 
S" WRONG NUMBER OF FP RESULTS: " ERROR EXIT 
S" NUMBER OF FLOAT RESULTS AFTER '>' BELOW ...}T SPECIFICATION: " ERROR EXIT 
THEN 
THEN 
ACTUALFRESULTS FCURSOR @ FLOATS + F@ FCONF= 0= IF 
ACTUALFRESULTS FCURSOR @ FLOATS + F@ FCONF= 0= IF 
S" INCORRECT FP RESULT: " ERROR 
S" INCORRECT FP RESULT: " ERROR 
Line 222 HASFLOATINGSTACK [IF]

Line 222 HASFLOATINGSTACK [IF]

COMPUTECELLSPERFP CONSTANT CELLSPERFP 
COMPUTECELLSPERFP CONSTANT CELLSPERFP 


: FTESTER ( R  ) 
: FTESTER ( R  ) 
DEPTH CELLSPERFP < ACTUALDEPTH @ XCURSOR @ CELLSPERFP + < OR IF 
DEPTH CELLSPERFP < ACTUALDEPTH @ XCURSOR @ STARTDEPTH @ + CELLSPERFP + < OR IF 
S" WRONG NUMBER OF RESULTS: " ERROR EXIT 
S" NUMBER OF RESULTS AFTER '>' BELOW ...}T SPECIFICATION: " ERROR EXIT 
THEN 
THEN 
ACTUALRESULTS XCURSOR @ CELLS + F@ FCONF= 0= IF 
ACTUALRESULTS XCURSOR @ CELLS + F@ FCONF= 0= IF 
S" INCORRECT FP RESULT: " ERROR 
S" INCORRECT FP RESULT: " ERROR 
Line 274 HASFLOATINGSTACK [IF]

Line 274 HASFLOATINGSTACK [IF]



: ...}T (  ) 
: ...}T (  ) 
DEPTH STARTDEPTH @ = 0= IF 
DEPTH STARTDEPTH @ = 0= IF 
S" WRONG NUMBER OF RESULTS" ERROR 
S" NUMBER OF CELL RESULTS BEFORE AND AFTER '>' DOES NOT MATCH: " ERROR 
THEN 
THEN 
XCURSOR @ ACTUALDEPTH @ <> IF 
XCURSOR @ STARTDEPTH @ + ACTUALDEPTH @ <> IF 
S" WRONG NUMBER OF RESULTS" ERROR 
S" NUMBER OF CELL RESULTS BEFORE '>' DOES NOT MATCH ...}T SPRECIFICATION: " ERROR 
THEN 
THEN 
F...}T ; 
F...}T ; 


: XTESTER ( X  ) 
: XTESTER ( X  ) 
DEPTH 0= ACTUALDEPTH @ XCURSOR @ 1+ < OR IF 
DEPTH 0= ACTUALDEPTH @ XCURSOR @ STARTDEPTH @ + 1+ < OR IF 
S" WRONG NUMBER OF RESULTS: " ERROR EXIT 
S" NUMBER OF CELL RESULTS AFTER '>' BELOW ...}T SPECIFICATION: " ERROR EXIT 
THEN 
THEN 
ACTUALRESULTS XCURSOR @ CELLS + @ <> IF 
ACTUALRESULTS XCURSOR @ CELLS + @ <> IF 
S" INCORRECT CELL RESULT: " ERROR 
S" INCORRECT CELL RESULT: " ERROR 
Line 327 HASFLOATINGSTACK [IF]

Line 327 HASFLOATINGSTACK [IF]

ELSE >IN ! DROP 
ELSE >IN ! DROP 
THEN ; 
THEN ; 


BASE ! 




BASE ! 