webForth icon indicating copy to clipboard operation
webForth copied to clipboard

Hayes test suite - currently passes Core and CoreExt - working through CorePlus

Open mitra42 opened this issue 4 years ago • 12 comments

There is a test suite "forth2012-test-suite" .

Its a little complex to run - and appears to be failing. Will address each fail and fix below

This comment is the META - updated frequently - you can ignore comments xx-yy below But pay attention to CLEANUP comment which may require other issues to be opened.

Current test process ...

cd forth2012-test-suite-master/src $> node ../../scripts/forth_2012.js webFORTH V0.01.00 INCLUDE ../../scripts/forth2012_runtests.fth

And be patient ...

As implement extensions - can uncomment test files in runtests.fth

  • [x] prelimtest
  • [x] core
  • [x] coreplus
  • [x] coreext
  • [x] Move {T etc into index.js }
  • [x] Retest for CELL_MEM variations - confirm 16 bit 24 bit and 32 bit all work
  • [x] Do a pass through of the code - see comment below
  • [x] Pass thru forth2012 words - look for any not checked off
  • [ ] Needs ENVIRONMENT? which isnt in Hayes test (note - dont find where this applies)
  • [ ] blocktest - not implemented so not expected to work see #80
  • [ ] doubletest - see #93
  • [ ] exceptiontest - see #106 - fails test of ABORT" but standard definition looks very iffy as loses the error code
  • [ ] facilitytest - fails see #107
  • [ ] filetest - see #97
  • [ ] localstest - not implemented yet see #50
  • [ ] memorytest - see #96
  • [ ] toolstest - see #95
  • [ ] searchordertest - needs vocabularies - see #35
  • [ ] stringtest - see #94

[ ] Also See "CLEANUP" comment below

mitra42 avatar Jan 19 '21 09:01 mitra42

REQUIRE prelimtest.fth

( Pass #1: testing 0 >IN +! ) 0 >IN +! SOURCE TYPE CR ( Pass #2: testing 1 >IN +! ) 1 >IN +! xSOURCE TYPE CR ( Pass #3: testing 1+ ) 1 1+ >IN +! xxSOURCE TYPE CR ( Pass #4: testing @ ! BASE ) 0 1+ 1+ BASE ! BASE @ >IN +! xxSOURCE TYPE CR ( Pass #5: testing decimal BASE ) BASE @ >IN +! xxxxxxxxxxSOURCE TYPE CR ( Pass #6: testing : ; ) : .SRC SOURCE TYPE CR ; 6 >IN +! xxxxxx.SRC ( Pass #7: testing number input ) 19 >IN +! xxxxxxxxxxxxxxxxxxx.SRC ( Pass #8: testing VARIABLE ) VARIABLE Y 2 Y ! Y @ >IN +! xx.SRC ( Pass #9: testing WORD COUNT ) 5 MSG abcdef) Y ! Y ! >IN +! xxxxx.SRC ( Pass #10: testing WORD COUNT ) MSG ab) >IN +! xxY ! .SRC Pass #11: testing WORD COUNT .MSG Pass #12: testing = returns all 1's for true Pass #13: testing = returns 0 for false Pass #14: testing -1 interpreted correctly

1 2* >IN +! xx.MSG( Pass #15: testing 2*) CR ^^^^^ 2* ? (node:38867) UnhandledPromiseRejectionWarning: RangeError: Invalid typed array length: 1024 at new Uint8Array () at Flash16_16.buff8 (file:///Users/mitra/git/webforth/index.js:1704:12) at Forth_with_fs.f (file:///Users/mitra/git/webforth/forth_with_fs.js:119:26) at Forth_with_fs.threadtoken (file:///Users/mitra/git/webforth/index.js:2644:34) at Forth_with_fs.runXT (file:///Users/mitra/git/webforth/index.js:2660:33) at async Forth_with_fs.dINTERPRET (file:///Users/mitra/git/webforth/index.js:2967:7) at async Forth_with_fs.EVAL (file:///Users/mitra/git/webforth/index.js:2988:9) at async Forth_with_fs.interpret (file:///Users/mitra/git/webforth/index.js:3018:7) (node:38867) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Three issues

  • [x] : A Promise rejection should be handled and result in a "THROW"
  • [x] : Need to dig into how that error occurred.
  • [x] : May need to define 2*
  • [x] : Need to confirm remaining output is as expected.

mitra42 avatar Jan 19 '21 09:01 mitra42

CLEANUP

  • [ ] Merge code from forth_2012 into index.js
  • [x] Move 2* into index.js ,
  • [ ] make 2* a shift rather than 2 * and find potential users
  • [x] Figure out why cant put REQUIRE prelimtest.fth in the preTest string
  • [x] Fix so a syntax error or unknown word doesnt crash
  • [x] Missing ['] https://forth-standard.org/standard/core/BracketTick - immediate, and compile word into dic
    • [x] Need to find use cases to replace - esp in FILE, HAND, QUIT, quit1,
  • [x] [CHAR]
    • [x] find uses of e.g. [ CHAR $ ] LITERAL and replace with [CHAR]
  • [x] Move {T --> }T into index.js from Hayes and replace \?test ...TEST
  • [ ] Look for TODO-83

mitra42 avatar Jan 19 '21 10:01 mitra42

Pass #20: testing ?F~ ?~~ Pass Error Pass #21: testing ?~

: TST4 ( -- n ) 0 5 0 DO 1+ LOOP ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DO ?

  • [x] needs DO LOOP - see #47

mitra42 avatar Jan 19 '21 10:01 mitra42

prelimtest.fth now works - on to rest of runtests.fth

mitra42 avatar Jan 26 '21 09:01 mitra42

  • [x] INCORRECT RESULT: T{ -1 0 > -> FALSE }T
  • [x] INCORRECT RESULT: T{ -1 1 > -> FALSE }T
  • [x] INCORRECT RESULT: T{ MIN-INT 0 > -> FALSE }T
  • [x] INCORRECT RESULT: T{ MIN-INT MAX-INT > -> FALSE }T
  • [x] INCORRECT RESULT: T{ 0 -1 > -> TRUE }T
  • [x] INCORRECT RESULT: T{ 1 -1 > -> TRUE }T
  • [x] INCORRECT RESULT: T{ 0 MIN-INT > -> TRUE }T
  • [x] INCORRECT RESULT: T{ MAX-INT MIN-INT > -> TRUE }T*

mitra42 avatar Jan 26 '21 09:01 mitra42

  • [x] Missing S>D

mitra42 avatar Jan 26 '21 09:01 mitra42

  • [x] INCORRECT RESULT: T{ 2 MAX-INT M* 2 SM/REM -> 0 MAX-INT }T
  • [x] INCORRECT RESULT: T{ 2 MAX-INT M* MAX-INT SM/REM -> 0 2 }T*
  • [x] Missing ALIGN

mitra42 avatar Jan 29 '21 03:01 mitra42

  • [x] INCORRECT RESULT: T{ HERE 1 ALLOT ALIGN HERE SWAP - ALMNT = -> <TRUE> }T
  • [x] INCORRECT RESULT: T{ 1ST CELL+ -> 2ND }T \ ... BY ONE CELL
  • [x] INCORRECT RESULT: T{ 1ST 1 CELLS + -> 2ND }T
  • [x] INCORRECT RESULT: T{ 1ST @ 2ND @ -> 1 2 }T
  • [x] INCORRECT RESULT: T{ 1ST 2@ -> 6 5 }T

mitra42 avatar Jan 29 '21 23:01 mitra42

  • [x] CONSTANT 1STC says CONSTANT ?

mitra42 avatar Jan 30 '21 09:01 mitra42

Needs definitions of .. (this will be edited)

  • [x] TUCK
  • [x] NONAME

mitra42 avatar Feb 01 '21 07:02 mitra42

  • check Forth2012 definition and check off if matches
    • check naming if non alpha - see #86
    • check naming and order of functions XXX (a b -- c ) becomes SPpush(_XXX(b, a))
    • lower case if not standard
    • add {T tests where possible (including for JS words)
    • If its a JS word then check port to Arduino

List of words from forth2012: ABORT ABORT" ABS ACCEPT ACTION-OF AGAIN ALIGN ALIGNED ALLOT AND BASE BEGIN BL BUFFER: [ [CHAR] [COMPILE] ['] CASE C, CELL+ CELLS C@ CHAR CHAR+ CHARS COMPILE, CONSTANT COUNT CR CREATE C! : :NONAME , C" DECIMAL DEFER DEFER@ DEFER! DEPTH DO DOES> DROP DUP / /MOD .R .( ." ELSE EMIT ENDCASE ENDOF ENVIRONMENT? ERASE EVALUATE EXECUTE EXIT = FALSE FILL FIND FM/MOD @ HERE HEX HOLD HOLDS I IF IMMEDIATE INVERT IS J KEY LEAVE LITERAL LOOP LSHIFT MARKER MAX MIN MOD MOVE M* - NEGATE NIP OF OR OVER 1- 1+ PAD PARSE-NAME PARSE PICK POSTPONE + +LOOP +! QUIT RECURSE REFILL REPEAT RESTORE-INPUT R@ ROLL ROT RSHIFT R> SAVE-INPUT SIGN SM/REM SOURCE-ID SOURCE SPACE SPACES STATE SWAP ; S" S" S>D ! THEN TO TRUE TUCK TYPE ' * / /MOD 2DROP 2DUP 2/ 2@ 2OVER 2R@ 2R> 2SWAP 2! 2 2>R U.R UM/MOD UM UNLOOP UNTIL UNUSED U. U< U> VALUE VARIABLE WHILE WITHIN WORD XOR 0= 0< 0> 0<> \ . < > <> #> <# # #S ( ?DO ?DUP >BODY >IN >NUMBER >R ]

mitra42 avatar Feb 23 '21 08:02 mitra42

Words From proposals to Forth2012: }T -> FIND-NAME-IN FIND-NAME T{

From eForth and possibly other Forths: ?branch ?CSP ?KEY ?RX ?STACK ?UNIQUE 'BOOT 'ECHO 'EMIT 'TAP #TIB !IO $,n $" $," $COMPILE $INTERPRET !CSP .$ .BASE .FREE .ID .OK ^H >CHAR >NAME branch CSP COLD COMPILE COMPILE-ONLY CONSOLE CONTEXT CP CURRENT CTRL DIGIT DIGIT? EMPTY EVAL EXTRACT FILE HAND hi HLD HANDLER I/O kTAP LAST M/MOD NAME? NEXT NP NUF? NULL$ NUMBER? OVERT PACE PACK$ PRESET PROMPT QUERY RP@ RP! RP0 SAME? SPAN SP@ SP0 SP! TAP TIB TIB0 TOKEN TX! UM+ VER version WARM WHEN XIO

Words from Exceptions word set ABORT ABORT" CATCH THROW

Words that are part of other words - API may change: <MARK <RESOLVE >MARK >RESOLVE (?do) (charbase) (loop) (+loop) ($,n) ."| $"| '>BODY! AFT (abort") accumulate AHEAD bu+@ c+! cmove\ create crlf? dm+ do$ doLit FOR isspace? isnotspace? leave, leave-ptr (next) (of) pack\$ que quit1 quitError set-header-bits skipCRLF skipToCRLF skip-till some-loop source-id sourcePush sourcePop stringBuffer S"| unreadFile xt-skip

Other: _USER 2RDrop >RESOLVES >MARKSTART >BODY! >MARKTHREAD >RESOLVETHREAD ?\ ?negate ?safe ?test ++ -- -ROT @EXECUTE BYTEMASK CELL- COMP debugNA emits Fbreak I-MAX IMED immediate? J-MAX ms stack spop spush spushes sempty str testFlags testDepth ud< userAreaInit userAreaSave vHERE v, vALIGN vALLOT vCREATE VP

mitra42 avatar Feb 27 '21 01:02 mitra42