added a test case for non-local return
This commit is contained in:
parent
e0cadd1ae6
commit
a9ed8220ff
24
t/ret-01.hcl
24
t/ret-01.hcl
@ -1,3 +1,27 @@
|
||||
(defun repeat(n f)
|
||||
(while (> n 0)
|
||||
(f)
|
||||
(set n (- n 1))
|
||||
)
|
||||
)
|
||||
|
||||
(defun test-non-local-ret-1(k)
|
||||
(repeat 10 (lambda()
|
||||
(set k (+ k 2))
|
||||
(if (= k 28) (return-from-home k))
|
||||
))
|
||||
|
||||
(return k)
|
||||
)
|
||||
|
||||
(set a (test-non-local-ret-1 20))
|
||||
(if (/= a 28) (printf "ERROR: a must be 28\n"))
|
||||
(printf "OK %d\n" a)
|
||||
|
||||
(set a (test-non-local-ret-1 21))
|
||||
(if (/= a 41) (printf "ERROR: a must be 41\n"))
|
||||
(printf "OK %d\n" a)
|
||||
|
||||
|
||||
(defun ff() (return 999))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user