Minilisp.pm/t/dotimes.t

44 lines
1.1 KiB
Perl
Raw Normal View History

2021-04-10 22:38:54 +02:00
(plan 6)
2021-04-10 01:16:03 +02:00
(expect "dotimes - executes body n times"
(let ((pings 0))
(dotimes (i 5)
(set pings (+ 1 pings)))
(equal pings 5)))
(expect "dotimes - evaluates result form"
(equal 6
(dotimes (i 6 i))))
(expect "dotimes - implicit block nil"
(equal 'ok
(dotimes (i 6)
(return 'ok))))
(expect "dotimes - body is not evaluated if count is 0"
(equal 'ok
(catch 'test
(dotimes (i 0)
(throw 'test 'fail))
'ok)))
(expect "dotimes - body is not evaluated if count is negative"
(equal 'ok
(catch 'test
(dotimes (i -3)
(throw 'test 'fail))
'ok)))
2021-04-10 22:38:54 +02:00
(defun nop () nil)
(expect "dotimes - implicit tagbody"
(equal 'ok
(catch 'test
(dotimes (e 1)
nil
(go end)
middle
(throw 'test 'fail)
end)
'ok)))