forth: pictured numeric output <#/#/#S/#>/HOLD/SIGN + U./U.R/.R (Hayes 448/638, 70%)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 00:23:04 +00:00
parent c726a9e0fe
commit 47f66ad1be
5 changed files with 254 additions and 11 deletions

View File

@@ -135,6 +135,53 @@
(forth-p5-check-stack "DMAX" "5 0 7 0 DMAX" (list 7 0))
(forth-p5-check-stack "DMIN" "5 0 7 0 DMIN" (list 5 0))))
(define
forth-p5-format-tests
(fn
()
(forth-p4-check-output-passthrough
"U. prints with trailing space"
"123 U."
"123 ")
(forth-p4-check-output-passthrough
"<# #S #> TYPE — decimal"
"123 0 <# #S #> TYPE"
"123")
(forth-p4-check-output-passthrough
"<# #S #> TYPE — hex"
"255 HEX 0 <# #S #> TYPE"
"FF")
(forth-p4-check-output-passthrough
"<# # # #> partial"
"1234 0 <# # # #> TYPE"
"34")
(forth-p4-check-output-passthrough
"SIGN holds minus"
"<# -1 SIGN -1 SIGN 0 0 #> TYPE"
"--")
(forth-p4-check-output-passthrough
".R right-justifies"
"42 5 .R"
" 42")
(forth-p4-check-output-passthrough
".R negative"
"-42 5 .R"
" -42")
(forth-p4-check-output-passthrough
"U.R"
"42 5 U.R"
" 42")
(forth-p4-check-output-passthrough
"HOLD char"
"<# 0 0 65 HOLD #> TYPE"
"A")))
(define
forth-p4-check-output-passthrough
(fn
(label src expected)
(let ((r (forth-run src))) (forth-p5-assert label expected (nth r 1)))))
(define
forth-p5-run-all
(fn
@@ -147,6 +194,7 @@
(forth-p5-2bang-tests)
(forth-p5-mixed-tests)
(forth-p5-double-tests)
(forth-p5-format-tests)
(dict
"passed"
forth-p5-passed