Minilisp.pm/t/tagbody.t

29 lines
817 B
Raku

(plan 2)
(defun inc (n) (+ n 1))
(expect "dotimes - sections are evaluated in order"
(equal 'ok
(catch 'test
(let ((i 0))
(tagbody
(set i 's0)
section-a
(unless (equal i 's0) (throw 'test 'fail))
(set i 's1)
section-b
(unless (equal i 's1) (throw 'test 'fail))
(set i 's2))
(unless (equal i 's2) (throw 'test 'fail)))
'ok)))
(expect "dotimes - go works"
(equal 'ok
(catch 'test
(tagbody
(go section-b)
section-a
(throw 'test 'fail)
section-b)
'ok)))