d4228230e64b9161b467ea66b189313884209133
[jscl.git] / tests / list.lisp
1 ;; Tests for list functions
2
3 ;; TODO: EQUAL doesn't compare lists correctly at the moment.
4 ;; Once it does the lists can be compared directly in many of these tests
5
6 ; COPY-TREE
7 (test (let* ((foo (list '(1 2) '(3 4)))
8              (bar (copy-tree foo)))
9         ;; (SETF (CAR (CAR FOO)) 0) doesn't work in the test for some reason,
10         ;; despite working fine in the REPL
11         (rplaca (car foo) 0)
12         (not (= (car (car foo))
13                 (car (car bar))))))
14
15 ; TREE-EQUAL
16 (test (tree-equal '(1 2 3) '(1 2 3)))
17 (test (tree-equal '(1 (2 (3 4) 5) 6) '(1 (2 (3 4) 5) 6)))
18 (test (tree-equal (cons 1 2) (cons 2 3)
19                   :test (lambda (a b) (not (= a b)))))
20
21 ; SUBST
22 ; Can't really test this until EQUAL works properly on lists
23
24 ; POP
25 (test (let* ((foo '(1 2 3))
26              (bar (pop foo)))
27         (and (= bar 1)
28              (= (car foo) 2))))