Skip to content

Commit df47406

Browse files
committed
add test for lambda in lambda
1 parent 0a38548 commit df47406

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/env.l

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(require :unittest "lib/llib/unittest.l")
2+
3+
(init-unit-test)
4+
5+
;;(defun make-c (a) (let ((x 0)) #'(lambda () (list a x))))
6+
;;(defun make-c () (let ((x 0)) #'(lambda () (list x))))
7+
(defun make-c0 () #'(lambda () (list 0)))
8+
9+
(compile 'make-c0)
10+
(setq f0 (make-c0))
11+
12+
(deftest f0
13+
(format t ";; funcall make-c0 ~A~%" (funcall f0))
14+
(assert (equal (funcall f0) '(0))))
15+
16+
17+
(defun make-c1 () (let () #'(lambda (x) (list x))))
18+
19+
(compile 'make-c1)
20+
(setq f1 (make-c1))
21+
22+
(deftest f1
23+
(format t ";; funcall make-c1 ~A~%" (funcall f1 1))
24+
(assert (equal (funcall f1 1) '(1))))
25+
26+
27+
(defun make-c2 () (let ((x 0)) #'(lambda () (list x))))
28+
29+
(compile 'make-c2)
30+
(setq f2 (make-c2))
31+
32+
(deftest f2
33+
(format t ";; funcall make-c2 ~A~%" (funcall f2))
34+
(assert (equal (funcall f2) '(0))))
35+
36+
(setq *x* 2) (defun make-c3 () #'(lambda () (list *x*)))
37+
38+
(compile 'make-c3)
39+
(setq f3 (make-c3))
40+
41+
(deftest f3
42+
(format t ";; funcall make-c3 ~A~%" (funcall f3))
43+
(assert (equal (funcall f3) '(2))))
44+
45+
(defun make-c4 () #'(lambda (x) (list x)))
46+
47+
(compile 'make-c4)
48+
(setq f4 (make-c4))
49+
50+
(deftest f4
51+
(format t ";; funcall make-c4 ~A~%" (funcall f4 1))
52+
(assert (equal (funcall f4 1) '(1))))
53+
54+
(deftest lambda-in-lambda
55+
(let (r)
56+
(setq r
57+
(mapcar #'(lambda (x)
58+
(mapcar #'(lambda (y) 1)
59+
'(nil nil nil nil nil nil nil nil nil nil nil nil nil
60+
nil nil nil nil nil nil nil nil nil nil nil nil nil)))
61+
'(nil nil nil nil nil nil nil nil nil nil nil nil nil
62+
nil nil nil nil nil nil nil nil nil nil nil nil nil)))
63+
(print r)
64+
(assert (equal
65+
(make-list 26 :initial-element (make-list 26 :initial-element 1))
66+
r))
67+
))
68+
69+
(eval-when (load eval)
70+
(run-all-tests)
71+
(exit))

0 commit comments

Comments
 (0)