43 lines
1.1 KiB
Raku
43 lines
1.1 KiB
Raku
(plan 6)
|
|
|
|
(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)))
|
|
|
|
(defun nop () nil)
|
|
|
|
(expect "dotimes - implicit tagbody"
|
|
(equal 'ok
|
|
(catch 'test
|
|
(dotimes (e 1)
|
|
nil
|
|
(go end)
|
|
middle
|
|
(throw 'test 'fail)
|
|
end)
|
|
'ok)))
|