-
Notifications
You must be signed in to change notification settings - Fork 0
/
case.pure.lisp
58 lines (51 loc) · 2.05 KB
/
case.pure.lisp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;;;; tests of the CASE family of macros without side effects
;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; While most of SBCL is derived from the CMU CL system, the test
;;;; files (like this one) were written from scratch after the fork
;;;; from CMU CL.
;;;;
;;;; This software is in the public domain and is provided with
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
(cl:in-package :cl-user)
(with-test (:name (case :duplicate-key :compile-time-warning))
(loop
for (expected kind . clauses) in
'((nil
case (1 1)
(2 2)
(3 3))
("Duplicate key 1 in CASE form, occurring in the first clause: (1 1), and the second clause: (1 2)"
case (1 1)
(1 2))
("Duplicate key 2 in CASE form, occurring in the first clause: ((1 2) 1), and the second clause: ((2 3) 2)"
case ((1 2) 1)
((2 3) 2))
(nil
case (#1=(1) 1)
((#1#) 2)))
for form = `(lambda ()
(,kind *readtable*
,@clauses))
do
(multiple-value-bind (fun failure-p warnings style-warnings)
(checked-compile form :allow-style-warnings (when expected t))
(declare (ignore failure-p warnings))
(assert (functionp fun))
(when expected
(dolist (warning style-warnings)
(assert (search expected
(with-standard-io-syntax
(let ((*print-right-margin* nil)
(*print-pretty* t))
(remove #\Newline (princ-to-string warning)))))
()
"~S should have warned ~S, but instead warned: ~A"
form expected warning))
(assert style-warnings ()
"~S should have warned ~S, but didn't."
form expected)))))
(with-test (:name :duplicate-cases-load)
(assert (load "case-test.lisp")))