consp.lsp 1.21 KB
Newer Older
1
2
3
4
5
6
7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Apr 19 21:27:16 2003
;;;; Contains: Tests of CONSP

(in-package :cl-test)

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

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;; Lists satisfy consp
(deftest consp-list
  (notnot-mv (consp '(a)))
  t)

;; cons satisfies consp
(deftest consp-cons
  (notnot-mv (consp (cons nil nil)))
  t)

;; nil is not a consp
(deftest consp-nil
  (consp nil)
  nil)

;; The empty list is not a cons
(deftest consp-empty-list
  (consp (list))
  nil)

;; A single element list is a cons
(deftest consp-single-element-list
  (notnot-mv (consp (list 'a)))
  t)

;; For everything in *universe*, it is either an atom, or satisfies
;; consp, but not both
(deftest consp-xor-atom-universe
38
  (check-predicate #'(lambda (x) (or (and (consp x) (not (atom x)))
sds's avatar
sds committed
39
                                     (and (not (consp x)) (atom x)))))
40
  nil)
41
42
43
44

;; Everything in type cons satisfies consp, and vice versa
(deftest consp-cons-universe
  (check-type-predicate 'consp 'cons)
45
  nil)
46
47
48
49
50
51

(deftest consp.order.1
  (let ((i 0))
    (values (consp (incf i)) i))
  nil 1)

52
53
;;; Error tests

54
(deftest consp.error.1
55
56
  (signals-error (consp) program-error)
  t)
57
58

(deftest consp.error.2
59
60
  (signals-error (consp 'a 'b) program-error)
  t)