copy-tree.lsp 1.16 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Apr 19 21:31:33 2003
;;;; Contains: Tests of COPY-TREE

6

7

8

9

10 11 12
;; Try copy-tree on a tree containing elements of various kinds
(deftest copy-tree.1
  (let* ((x (cons 'a (list
sds's avatar
sds committed
13 14 15 16 17 18 19
                     (cons 'b 'c)
                     (cons 1 1.2)
                     (list (list "abcde"
                                 (make-array '(10) :initial-element
                                             (cons 'e 'f)))
                                'g))))
         (y (copy-tree x)))
20 21 22 23 24 25
    (check-cons-copy x y))
  t)

;; Try copy-tree on *universe*
(deftest copy-tree.2
  (let* ((x (copy-list *universe*))
sds's avatar
sds committed
26
         (y (copy-tree x)))
27 28 29 30 31 32 33 34 35 36
    (check-cons-copy x y))
  t)

(deftest copy-tree.order.1
  (let ((i 0))
    (values
     (copy-tree (progn (incf i) '(a b c)))
     i))
  (a b c) 1)

pfdietz's avatar
pfdietz committed
37 38 39 40
(def-fold-test copy-tree.fold.1 (copy-tree '(a . b)))
(def-fold-test copy-tree.fold.2 (copy-tree '(a)))
(def-fold-test copy-tree.fold.3 (copy-tree '(a b c d e)))

41 42
;;; Error tests

43
(deftest copy-tree.error.1
44 45
  (signals-error (copy-tree) program-error)
  t)
46 47

(deftest copy-tree.error.2
48 49
  (signals-error (copy-tree 'a 'b) program-error)
  t)