Minilisp.pm/t/do.t

37 lines
885 B
Perl
Raw Normal View History

2021-04-10 22:14:02 +02:00
(plan 4)
(defun nop () nil)
2021-04-09 00:01:27 +02:00
2021-04-06 22:11:37 +02:00
(expect "do - simple example"
(equal (do ((n 1)) (t n)) 1))
(defun range (start end)
(do ((i (- end 1) (- i 1))
(lst (list) (cons i lst)))
((< i start) lst)))
(expect "do - range function"
(equal (let ((lst (range 1 4)))
(comment lst)
lst)
(list 1 2 3)))
2021-04-08 21:53:21 +02:00
(expect "do - has implicit block nil"
(equal 'ok
(block nil
(do () (t)
(return 'fail))
'ok)))
2021-04-10 22:14:02 +02:00
(expect "do - implicit tagbody"
(equal 'ok
(catch 'test
(do ((n 0 (+ 1 n))) ((> n 0))
(nop)
(nop)
(go end)
middle
(throw 'test 'fail)
end)
'ok)))