forth: SP@ / SP! (+4; 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 21:07:10 +00:00
parent acf9c273a2
commit 387a6e7f5d
5 changed files with 42 additions and 3 deletions

View File

@@ -171,6 +171,24 @@
((r (forth-run "1000 2 ACCEPT")))
(let ((stk (nth r 2))) (forth-p4-assert "ACCEPT empty buf -> 0" (list 0) stk)))))
(define
forth-p4-sp-tests
(fn
()
(forth-p4-check-top "SP@ returns depth (0)" "SP@" 0)
(forth-p4-check-top
"SP@ after pushes"
"1 2 3 SP@ SWAP DROP SWAP DROP SWAP DROP"
3)
(forth-p4-check-stack-size
"SP! truncates"
"1 2 3 4 5 2 SP!"
2)
(forth-p4-check-top
"SP! leaves base items intact"
"1 2 3 4 5 2 SP!"
2)))
(define
forth-p4-base-tests
(fn
@@ -227,6 +245,7 @@
(forth-p4-char-tests)
(forth-p4-key-accept-tests)
(forth-p4-base-tests)
(forth-p4-sp-tests)
(dict
"passed"
forth-p4-passed