forth: WITHIN/ABORT/ABORT"/EXIT/UNLOOP (+7; Hayes 486/638, 76%)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 01:55:38 +00:00
parent b1a7852045
commit 8ca2fe3564
5 changed files with 107 additions and 9 deletions

View File

@@ -226,6 +226,27 @@
": A 100 ; : B S\" A\" EVALUATE ; B"
100)))
(define
forth-p5-misc-tests
(fn
()
(forth-p5-check-top "WITHIN inclusive lower" "3 2 10 WITHIN" -1)
(forth-p5-check-top "WITHIN exclusive upper" "10 2 10 WITHIN" 0)
(forth-p5-check-top "WITHIN below range" "1 2 10 WITHIN" 0)
(forth-p5-check-top "WITHIN at lower" "2 2 10 WITHIN" -1)
(forth-p5-check-top
"EXIT leaves colon-def early"
": F 5 EXIT 99 ; F"
5)
(forth-p5-check-stack
"EXIT in IF branch"
": F 5 0 IF DROP 99 EXIT THEN ; F"
(list 5))
(forth-p5-check-top
"UNLOOP + EXIT in DO"
": SUM 0 10 0 DO I 5 = IF I UNLOOP EXIT THEN LOOP ; SUM"
5)))
(define
forth-p4-check-output-passthrough
(fn
@@ -247,6 +268,7 @@
(forth-p5-format-tests)
(forth-p5-dict-tests)
(forth-p5-state-tests)
(forth-p5-misc-tests)
(dict
"passed"
forth-p5-passed