source: trunk/source/tests/ansi-tests/constantp.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Jan 13 19:12:17 2003
4;;;; Contains: Tests for CONSTANTP
5
6;;; See also defconstant.lsp
7
8(in-package :cl-test)
9
10;;; Error tests
11
12(deftest constantp.error.1
13  (signals-error (constantp) program-error)
14  t)
15
16(deftest constantp.error.2
17  (signals-error (constantp nil nil nil) program-error)
18  t)
19
20;;; Non-error tests
21
22(deftest constantp.1
23  (check-predicate #'(lambda (e) (or (symbolp e) (consp e) (constantp e))))
24  nil)
25
26(deftest constantp.2
27  (notnot-mv (constantp t))
28  t)
29 
30(deftest constantp.3
31  (notnot-mv (constantp nil))
32  t)
33
34(deftest constantp.4
35  (notnot-mv (constantp :foo))
36  t)
37
38(deftest constantp.5
39  (constantp (gensym))
40  nil)
41
42(defconstant constantp-test-symbol 1)
43
44(defmacro constantp-macro (form &environment env)
45  (notnot-mv (constantp form env)))
46
47(deftest constantp.6
48  (constantp-macro constantp-test-symbol)
49  t)
50 
51(deftest constantp.7
52  (constantp '(incf x))
53  nil)
54
55(deftest constantp.8
56  (notnot-mv (constantp 1 nil))
57  t)
58
59(deftest constantp.9
60  (notnot-mv (constantp ''(((foo)))))
61  t)
62
63(deftest constantp.10
64  (notnot-mv (constantp 'pi))
65  t)
66
67(defmacro macro-for-constantp.11 (x) x)
68
69(deftest constantp.11
70  (macrolet ((macro-for-constantp.11 (y)
71               (declare (ignore y))
72               '*standard-input*))
73    (macrolet ((%m (&environment env)
74                 (if (constantp '(macro-for-constantp.11 0) env)
75                     :bad
76                     :good)))
77      (%m)))
78  :good)
79   
80
81(deftest constantp.order.1
82  (let ((i 0))
83    (values
84     (notnot (constantp (progn (incf i) 1)))
85     i))
86  t 1)
87
88(deftest constantp.order.2
89  (let ((i 0) x y)
90    (values
91     (notnot (constantp (progn (setf x (incf i)) 1)
92                        (progn (setf y (incf i)) nil)))
93     i x y))
94  t 2 1 2)
95
96 
97
Note: See TracBrowser for help on using the repository browser.