forth: BASE/DECIMAL/HEX/BIN/OCTAL (+9; Hayes 174/590)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 20:40:11 +00:00
parent 35ce18eb97
commit acf9c273a2
8 changed files with 76 additions and 9 deletions

View File

@@ -171,6 +171,47 @@
((r (forth-run "1000 2 ACCEPT")))
(let ((stk (nth r 2))) (forth-p4-assert "ACCEPT empty buf -> 0" (list 0) stk)))))
(define
forth-p4-base-tests
(fn
()
(forth-p4-check-top
"BASE default is 10"
"BASE @"
10)
(forth-p4-check-top
"HEX switches base to 16"
"HEX BASE @"
16)
(forth-p4-check-top
"DECIMAL resets to 10"
"HEX DECIMAL BASE @"
10)
(forth-p4-check-top
"HEX parses 10 as 16"
"HEX 10"
16)
(forth-p4-check-top
"HEX parses FF as 255"
"HEX FF"
255)
(forth-p4-check-top
"DECIMAL parses 10 as 10"
"HEX DECIMAL 10"
10)
(forth-p4-check-top
"BIN parses 1010 as 10"
"BIN 1010"
10)
(forth-p4-check-top
"OCTAL parses 17 as 15"
"OCTAL 17"
15)
(forth-p4-check-top
"BASE @ ; 16 BASE ! ; BASE @"
"BASE @ 16 BASE ! BASE @ SWAP DROP"
16)))
(define
forth-p4-run-all
(fn
@@ -185,6 +226,7 @@
(forth-p4-charplus-tests)
(forth-p4-char-tests)
(forth-p4-key-accept-tests)
(forth-p4-base-tests)
(dict
"passed"
forth-p4-passed