copy-alist.lsp 1.22 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Apr 20 07:29:07 2003
;;;; Contains: Tests of COPY-ALIST

6

7

8

9

10 11
(deftest copy-alist.1
    (let* ((x (copy-tree '((a . b) (c . d) nil (e f) ((x) ((y z)) w)
sds's avatar
sds committed
12 13 14 15
                           ("foo" . "bar") (#\w . 1.234)
                           (1/3 . 4123.4d5))))
           (xcopy (make-scaffold-copy x))
           (result (copy-alist x)))
16 17 18 19
      (and
       (check-scaffold-copy x xcopy)
       (= (length x) (length result))
       (every #'(lambda (p1 p2)
sds's avatar
sds committed
20 21 22 23 24
                  (or (and (null p1) (null p2))
                      (and (not (eqt p1 p2))
                           (eqlt (car p1) (car p2))
                           (eqlt (cdr p1) (cdr p2)))))
              x result)
25 26 27
       t))
  t)

28 29 30
(def-fold-test copy-alist.2 (copy-alist '((a . b) nil (c . d))))
(def-fold-test copy-alist.3 (car (copy-alist '((a . b) nil (c . d)))))
(def-fold-test copy-alist.4 (caddr (copy-alist '((a . b) nil (c . d)))))
pfdietz's avatar
pfdietz committed
31

32 33
;;; Error tests

34
(deftest copy-alist.error.1
35 36
  (signals-error (copy-alist) program-error)
  t)
37 38

(deftest copy-alist.error.2
39 40
  (signals-error (copy-alist nil nil) program-error)
  t)
41 42

(deftest copy-alist.error.3
43 44
  (signals-error (copy-alist '((a . b) . c)) type-error)
  t)