2
;;;; Author: Paul Dietz
3
;;;; Created: Fri Oct 18 21:06:45 2002
4
;;;; Contains: Tests of CCASE
10
(ccase x (a 1) (b 2) (c 3)))
14
(signals-error (let ((x 1)) (ccase x)) type-error)
19
(let ((x 1))(ccase x (a 1) (b 2) (c 3)))
23
;;; It is legal to use T or OTHERWISE as key designators
24
;;; in CCASE forms. They have no special meaning here.
28
(let ((x 1)) (ccase x (t nil)))
34
(let ((x 1)) (ccase x (otherwise nil)))
40
(ccase x ((a z) 1) ((y b w) 2) ((b c) 3)))
52
(let ((x (1+ most-positive-fixnum)))
53
(ccase x (#.(1+ most-positive-fixnum) 'a)))
58
(let (x) (ccase x (nil 'a)))
69
(ccase x (b 0) (a (values 1 2 3)) (c nil)))
74
(let ((x t)) (ccase x (a 10)))
80
(ccase x ((t) 10) (t 20)))
84
(let ((x (list 'a 'b)))
85
(eval `(let ((y (quote ,x))) (ccase y ((,x) 1) (a 2)))))
90
(let ((x 'otherwise)) (ccase x ((t) 10)))
96
(let ((x t)) (ccase x ((otherwise) 10)))
102
(let ((x 'a)) (ccase x (b 0) (c 1) (otherwise 2)))
108
(let ((x 'a)) (ccase x (b 0) (c 1) ((t) 2)))
121
(deftest ccase.21 (let ((x 1)) (ccase x (1 (values)) (2 'a))))
123
(deftest ccase.23 (let ((x 1)) (ccase x (1 (values 'a 'b 'c))))
126
;;; Show that the key expression is evaluated only once.
128
(let ((a (vector 'a 'b 'c 'd 'e))
131
(ccase (aref a (incf i))
139
;;; Repeated keys are allowed (all but the first are ignored)
143
(ccase x ((a b c) 10) (b 20)))
148
(ccase x (b 20) ((a b c) 10)))
153
(ccase x (b 20) (b 10) (d 0)))
156
;;; There are implicit progns
175
((type-error #'(lambda (c) (store-value 7 c))))
183
;;; No implicit tagbody
190
(return-from done 'bad))))
192
(return-from done 'good)))
196
;;; (deftest ccase.error.1
197
;;; (signals-error (ccase) program-error)
200
(deftest ccase.error.1
201
(signals-error (funcall (macro-function 'ccase))
205
(deftest ccase.error.2
206
(signals-error (funcall (macro-function 'ccase) '(ccase t))
210
(deftest ccase.error.3
211
(signals-error (funcall (macro-function 'ccase) '(ccase t) nil nil)