revappend.lsp 1.43 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Apr 19 22:37:43 2003
;;;; Contains: Tests of REVAPPEND

(in-package :cl-test)

8 9
(compile-and-load "cons-aux.lsp")

10 11
(deftest revappend.1
    (let* ((x (list 'a 'b 'c))
sds's avatar
sds committed
12 13 14 15
           (y (list 'd 'e 'f))
           (xcopy (make-scaffold-copy x))
           (ycopy (make-scaffold-copy y))
           )
16
      (let ((result (revappend x y)))
sds's avatar
sds committed
17 18 19 20 21
        (and
         (check-scaffold-copy x xcopy)
         (check-scaffold-copy y ycopy)
         (eqt (cdddr result) y)
         result)))
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  (c b a d e f))

(deftest revappend.2
    (revappend (copy-tree '(a b c d e)) 10)
  (e d c b a . 10))

(deftest revappend.3
    (revappend nil 'a)
  a)

(deftest revappend.4
    (revappend (copy-tree '(a (b c) d)) nil)
  (d (b c) a))

(deftest revappend.order.1
  (let ((i 0) x y)
    (values
     (revappend (progn (setf x (incf i)) (copy-list '(a b c)))
sds's avatar
sds committed
40
                (progn (setf y (incf i)) (copy-list '(d e f))))
41 42 43
     i x y))
  (c b a d e f) 2 1 2)

pfdietz's avatar
pfdietz committed
44 45 46 47 48
(def-fold-test revappend.fold.1 (revappend '(x) nil))
(def-fold-test revappend.fold.2 (revappend '(x y z) nil))

;;; Error tests

49
(deftest revappend.error.1
50 51
  (signals-error (revappend) program-error)
  t)
52 53

(deftest revappend.error.2
54 55
  (signals-error (revappend nil) program-error)
  t)
56 57

(deftest revappend.error.3
58 59
  (signals-error (revappend nil nil nil) program-error)
  t)
60 61

(deftest revappend.error.4
62 63
  (signals-error (revappend '(a . b) '(z)) type-error)
  t)