1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; While most of SBCL is derived from the CMU CL system, the test
5 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; This software is in the public domain and is provided with
9 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
10 ;;;; more information.
12 (load "assertoid.lisp")
13 (use-package '#:assertoid
)
17 (defun test (kind name state make-body
19 (list (format nil
"~A.~A"
20 name
'#:replacement
))))
21 (flet ((search-string (string)
22 (declare (ignorable string
))
24 (dolist (fragment `(,(string name
)
25 "deprecated" "as" "of" "SBCL" "1.2.10"
26 "Use" ,@replacements
"instead"))
27 (let ((match (search fragment string
:start2
(or start
0))))
29 (setf start
(+ match
(length fragment
))))))))
30 ;; Check the signaled warning condition.
33 (function (handler-bind
38 (compile nil
`(lambda ()
39 ,@(funcall make-body name
))))))
41 (assert (typep condition
(ecase state
42 (:early
'early-deprecation-warning
)
43 (:late
'late-deprecation-warning
)
44 (:final
'final-deprecation-warning
))))
45 (search-string (princ-to-string condition
))
48 (assert (eq :deprecated
(funcall function
))))
50 (assert-error (funcall function
)
51 (or deprecation-error cell-error
)))))
52 ;; Check the documentation.
54 (search-string (documentation name kind
))))
56 ;;;; Deprecated variables
58 (sb-int:define-deprecated-variable
:early
"1.2.10"
59 deprecated-variable.early
61 :replacement deprecated-variable.early.replacement
)
63 (with-test (:name
(sb-int:define-deprecated-variable
:early
))
64 (test 'variable
'deprecated-variable.early
:early
65 (lambda (name) `(,name
)))
66 (test 'variable
'deprecated-variable.early
:early
67 (lambda (name) `((symbol-value ',name
))))
68 (test 'variable
'deprecated-variable.early
:early
69 (lambda (name) `((symbol-global-value ',name
)))))
71 (sb-int:define-deprecated-variable
:late
"1.2.10"
72 deprecated-variable.late
74 :replacement deprecated-variable.late.replacement
)
76 (with-test (:name
(sb-int:define-deprecated-variable
:late
))
77 (test 'variable
'deprecated-variable.late
:late
78 (lambda (name) `(,name
)))
79 (test 'variable
'deprecated-variable.late
:late
80 (lambda (name) `((symbol-value ',name
))))
81 (test 'variable
'deprecated-variable.late
:late
82 (lambda (name) `((symbol-global-value ',name
)))))
84 (sb-int:define-deprecated-variable
:final
"1.2.10"
85 deprecated-variable.final
87 :replacement deprecated-variable.final.replacement
)
89 (with-test (:name
(sb-int:define-deprecated-variable
:final
))
90 (test 'variable
'deprecated-variable.final
:final
91 (lambda (name) `(,name
)))
92 (test 'variable
'deprecated-variable.final
:final
93 (lambda (name) `((symbol-value ',name
))))
94 (test 'variable
'deprecated-variable.final
:final
95 (lambda (name) `((symbol-global-value ',name
)))))
98 ;;;; Deprecated functions
100 (sb-int:define-deprecated-function
:early
"1.2.10"
101 deprecated-function.early deprecated-function.early.replacement
()
104 (with-test (:name
(sb-int:define-deprecated-function
:early
))
105 (test 'function
'deprecated-function.early
:early
106 (lambda (name) `((,name
)))))
108 (sb-int:define-deprecated-function
:late
"1.2.10"
109 deprecated-function.late deprecated-function.late.replacement
()
112 (with-test (:name
(sb-int:define-deprecated-function
:late
))
113 (test 'function
'deprecated-function.late
:late
114 (lambda (name) `((,name
)))))
116 (sb-int:define-deprecated-function
:final
"1.2.10"
117 deprecated-function.final deprecated-function.final.replacement
()
120 (with-test (:name
(sb-int:define-deprecated-function
:final
))
121 (test 'function
'deprecated-function.final
:final
122 (lambda (name) `((,name
)))))
124 (sb-int:define-deprecated-function
:early
"1.2.10"
125 deprecated-function.two-replacements
126 (deprecated-function.two-replacements.replacement1
127 deprecated-function.two-replacements.replacement2
)
131 (with-test (:name
(sb-int:define-deprecated-function
:two-replacements
))
133 'function
'deprecated-function.two-replacements
:early
134 (lambda (name) `((,name
)))
135 :replacements
'("DEPRECATED-FUNCTION.TWO-REPLACEMENTS.REPLACEMENT1"
136 "DEPRECATED-FUNCTION.TWO-REPLACEMENTS.REPLACEMENT2")))
138 (sb-int:define-deprecated-function
:early
"1.2.10"
139 deprecated-function.three-replacements
140 (deprecated-function.three-replacements.replacement1
141 deprecated-function.three-replacements.replacement2
142 deprecated-function.three-replacements.replacement3
)
146 (with-test (:name
(sb-int:define-deprecated-function
:three-replacements
))
148 'function
'deprecated-function.three-replacements
:early
149 (lambda (name) `((,name
)))
150 :replacements
'("DEPRECATED-FUNCTION.THREE-REPLACEMENTS.REPLACEMENT1"
151 "DEPRECATED-FUNCTION.THREE-REPLACEMENTS.REPLACEMENT2"
152 "DEPRECATED-FUNCTION.THREE-REPLACEMENTS.REPLACEMENT3")))
154 (with-test (:name
:deftype-tricky-constant
)
155 (assert-signal (eval '(deftype cows
() (if nil
'foo
'sb-thread
::spinlock
)))