constantp.lsp 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Jan 13 19:12:17 2003
;;;; Contains: Tests for CONSTANTP

;;; See also defconstant.lsp

(in-package :cl-test)

(deftest constantp.error.1
  (classify-error (constantp))
  program-error)

(deftest constantp.error.2
  (classify-error (constantp nil nil nil))
  program-error)


(deftest constantp.1
  (loop for e in *universe*
	when (and (not (symbolp e))
		   (not (consp e))
		   (not (constantp e)))
	collect e)
  nil)

(deftest constantp.2
28
  (notnot-mv (constantp t))
29
30
31
  t)
  
(deftest constantp.3
32
  (notnot-mv (constantp nil))
33
34
35
  t)

(deftest constantp.4
36
  (notnot-mv (constantp :foo))
37
38
39
40
41
42
43
44
45
  t)

(deftest constantp.5
  (constantp (gensym))
  nil)

(defconstant constantp-test-symbol 1)

(defmacro constantp-macro (form &environment env)
46
  (notnot-mv (constantp form env)))
47
48
49
50
51
52
53
54
55
56

(deftest constantp.6
  (constantp-macro constantp-test-symbol)
  t)
  
(deftest constantp.7
  (constantp '(incf x))
  nil)

(deftest constantp.8
57
  (notnot-mv (constantp 1 nil))
58
59
60
  t)

(deftest constantp.9
61
  (notnot-mv (constantp ''(((foo)))))
62
63
  t)

64
(deftest constantp.10
65
  (notnot-mv (constantp 'pi))
66
67
  t)

68
69
70
71
72
73
74
75
76
(deftest constantp.order.1
  (let ((i 0) x y)
    (values
     (notnot (constantp (progn (setf x (incf i)) 1)
			(progn (setf y (incf i)) nil)))
     i x y))
  t 2 1 2)

  
77