cons.lsp 1.05 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Apr 19 21:24:25 2003
;;;; Contains: Tests for CONS

(in-package :cl-test)

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

10 11
;;; Various easy tests of cons

12 13 14 15 16 17 18 19
(deftest cons-of-symbols
  (cons 'a 'b)
  (a . b))

(deftest cons-with-nil
  (cons 'a nil)
  (a))

20
;;; successive calls to cons produces results that are equal, but not eq
21 22
(deftest cons-eq-equal
  (let ((x (cons 'a 'b))
sds's avatar
sds committed
23
        (y (cons 'a 'b)))
24
    (and (not (eqt x y))
sds's avatar
sds committed
25
         (equalt x y)))
26 27
  t)

28
;;; list can be expressed as a bunch of conses (with nil)
29 30
(deftest cons-equal-list
  (equalt (cons 'a (cons 'b (cons 'c nil)))
sds's avatar
sds committed
31
          (list 'a 'b 'c))
32 33 34 35 36 37 38
  t)

;;; Order of evaluation of cons arguments
(deftest cons.order.1
  (let ((i 0)) (values (cons (incf i) (incf i)) i))
  (1 . 2) 2)

pfdietz's avatar
pfdietz committed
39 40
(def-fold-test cons.fold.1 (cons 'a 'b))

41 42
;;; Error tests

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

(deftest cons.error.2
48 49
  (signals-error (cons 'a) program-error)
  t)
50 51

(deftest cons.error.3
52 53
  (signals-error (cons 'a 'b 'c) program-error)
  t)