changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > demo / annotate fig/tests/tester.fr

changeset 10: 79737134254d
author: ellis <ellis@rwest.io>
date: Fri, 12 May 2023 22:58:05 -0400
permissions: -rw-r--r--
description: messing with UI and rust codegen
10
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
1
 \ From: John Hayes S1I
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
2
 \ Subject: tester.fr
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
3
 \ Date: Mon, 27 Nov 95 13:10:09 PST  
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
4
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
5
 \ (C) 1995 JOHNS HOPKINS UNIVERSITY / APPLIED PHYSICS LABORATORY
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
6
 \ MAY BE DISTRIBUTED FREELY AS LONG AS THIS COPYRIGHT NOTICE REMAINS.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
7
 \ VERSION 1.2
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
8
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
9
 \ 24/11/2015 Replaced Core Ext word <> with = 0=
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
10
 \ 31/3/2015 Variable #ERRORS added and incremented for each error reported.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
11
 \ 22/1/09 The words { and } have been changed to T{ and }T respectively to
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
12
 \ agree with the Forth 200X file ttester.fs. This avoids clashes with
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
13
 \ locals using { ... } and the FSL use of } 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
14
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
15
 HEX
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
16
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
17
 \ SET THE FOLLOWING FLAG TO TRUE FOR MORE VERBOSE OUTPUT; THIS MAY
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
18
 \ ALLOW YOU TO TELL WHICH TEST CAUSED YOUR SYSTEM TO HANG.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
19
 VARIABLE VERBOSE
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
20
    FALSE VERBOSE !
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
21
 \   TRUE VERBOSE !
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
22
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
23
 : EMPTY-STACK   \ ( ... -- ) EMPTY STACK: HANDLES UNDERFLOWED STACK TOO.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
24
    DEPTH ?DUP IF DUP 0< IF NEGATE 0 DO 0 LOOP ELSE 0 DO DROP LOOP THEN THEN ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
25
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
26
 VARIABLE #ERRORS 0 #ERRORS !
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
27
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
28
 : ERROR      \ ( C-ADDR U -- ) DISPLAY AN ERROR MESSAGE FOLLOWED BY
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
29
       \ THE LINE THAT HAD THE ERROR.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
30
    CR TYPE SOURCE TYPE       \ DISPLAY LINE CORRESPONDING TO ERROR
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
31
    EMPTY-STACK               \ THROW AWAY EVERY THING ELSE
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
32
    #ERRORS @ 1 + #ERRORS !
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
33
 \   QUIT  \ *** Uncomment this line to QUIT on an error
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
34
 ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
35
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
36
 VARIABLE ACTUAL-DEPTH         \ STACK RECORD
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
37
 CREATE ACTUAL-RESULTS 20 CELLS ALLOT
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
38
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
39
 : T{      \ ( -- ) SYNTACTIC SUGAR.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
40
    ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
41
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
42
 : ->      \ ( ... -- ) RECORD DEPTH AND CONTENT OF STACK.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
43
    DEPTH DUP ACTUAL-DEPTH !      \ RECORD DEPTH
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
44
    ?DUP IF            \ IF THERE IS SOMETHING ON STACK
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
45
       0 DO ACTUAL-RESULTS I CELLS + ! LOOP \ SAVE THEM
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
46
    THEN ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
47
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
48
 : }T      \ ( ... -- ) COMPARE STACK (EXPECTED) CONTENTS WITH SAVED
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
49
       \ (ACTUAL) CONTENTS.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
50
    DEPTH ACTUAL-DEPTH @ = IF      \ IF DEPTHS MATCH
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
51
       DEPTH ?DUP IF         \ IF THERE IS SOMETHING ON THE STACK
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
52
          0  DO            \ FOR EACH STACK ITEM
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
53
            ACTUAL-RESULTS I CELLS + @   \ COMPARE ACTUAL WITH EXPECTED
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
54
            = 0= IF S" INCORRECT RESULT: " ERROR LEAVE THEN
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
55
          LOOP
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
56
       THEN
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
57
    ELSE               \ DEPTH MISMATCH
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
58
       S" WRONG NUMBER OF RESULTS: " ERROR
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
59
    THEN ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
60
 
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
61
 : TESTING   \ ( -- ) TALKING COMMENT.
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
62
   SOURCE VERBOSE @
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
63
    IF DUP >R TYPE CR R> >IN !
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
64
    ELSE >IN ! DROP [CHAR] * EMIT
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
65
    THEN ;
79737134254d messing with UI and rust codegen
ellis <ellis@rwest.io>
parents:
diff changeset
66