5 |
|
|
6 |
(in-package :cl-test) |
(in-package :cl-test) |
7 |
|
|
8 |
(deftest documentation.1 |
;;; documentation (x function) (doc-type (eql 't)) |
9 |
|
|
10 |
|
(deftest documentation.function.t.1 |
11 |
(let* ((sym (gensym))) |
(let* ((sym (gensym))) |
12 |
(eval `(defun ,sym () nil)) |
(eval `(defun ,sym () nil)) |
13 |
(documentation (symbol-function sym) t)) |
(documentation (symbol-function sym) t)) |
14 |
nil) |
nil) |
15 |
|
|
16 |
(deftest documentation.2 |
(deftest documentation.function.t.2 |
17 |
(let* ((sym (gensym))) |
(let* ((sym (gensym))) |
18 |
(eval `(defun ,sym () nil)) |
(eval `(defun ,sym () nil)) |
19 |
(let ((fn (symbol-function sym)) |
(let ((fn (symbol-function sym)) |
20 |
(doc "FOO")) |
(doc "FOO1")) |
21 |
(multiple-value-prog1 |
(multiple-value-prog1 |
22 |
(setf (documentation fn t) "FOO") |
(setf (documentation fn t) (copy-seq doc)) |
23 |
(assert (or (null (documentation fn t)) |
(assert (or (null (documentation fn t)) |
24 |
(equal doc (documentation fn t))))))) |
(equal doc (documentation fn t))))))) |
25 |
"FOO") |
"FOO1") |
26 |
|
|
27 |
(deftest documentation.3 |
(deftest documentation.function.t.3 |
28 |
|
(let* ((sym (gensym))) |
29 |
|
(eval `(defmacro ,sym () nil)) |
30 |
|
(documentation (macro-function sym) t)) |
31 |
|
nil) |
32 |
|
|
33 |
|
(deftest documentation.function.t.4 |
34 |
|
(let* ((sym (gensym))) |
35 |
|
(eval `(defmacro ,sym () nil)) |
36 |
|
(let ((fn (macro-function sym)) |
37 |
|
(doc "FOO2")) |
38 |
|
(multiple-value-prog1 |
39 |
|
(setf (documentation fn t) (copy-seq doc)) |
40 |
|
(assert (or (null (documentation fn t)) |
41 |
|
(equal doc (documentation fn t))))))) |
42 |
|
"FOO2") |
43 |
|
|
44 |
|
(deftest documentation.function.t.5 |
45 |
|
(let* ((sym (gensym)) |
46 |
|
(fn (eval `#'(lambda () ',sym)))) |
47 |
|
(documentation fn t)) |
48 |
|
nil) |
49 |
|
|
50 |
|
(deftest documentation.function.t.6 |
51 |
|
(let* ((sym (gensym)) |
52 |
|
(fn (eval `#'(lambda () ',sym))) |
53 |
|
(doc "FOO3")) |
54 |
|
(multiple-value-prog1 |
55 |
|
(setf (documentation fn t) (copy-seq doc)) |
56 |
|
(assert (or (null (documentation fn t)) |
57 |
|
(equal doc (documentation fn t)))))) |
58 |
|
"FOO3") |
59 |
|
|
60 |
|
(deftest documentation.function.t.7 |
61 |
|
(let* ((sym (gensym)) |
62 |
|
(fn (eval `(defgeneric ,sym (x))))) |
63 |
|
(documentation fn t)) |
64 |
|
nil) |
65 |
|
|
66 |
|
(deftest documentation.function.t.8 |
67 |
|
(let* ((sym (gensym)) |
68 |
|
(fn (eval `(defgeneric ,sym (x)))) |
69 |
|
(doc "FOO4")) |
70 |
|
(multiple-value-prog1 |
71 |
|
(setf (documentation fn t) (copy-seq doc)) |
72 |
|
(assert (or (null (documentation fn t)) |
73 |
|
(equal doc (documentation fn t)))))) |
74 |
|
"FOO4") |
75 |
|
|
76 |
|
;;; documentation (x function) (doc-type (eql 'function)) |
77 |
|
|
78 |
|
(deftest documentation.function.function.1 |
79 |
(let* ((sym (gensym))) |
(let* ((sym (gensym))) |
80 |
(eval `(defun ,sym () nil)) |
(eval `(defun ,sym () nil)) |
81 |
(documentation (symbol-function sym) 'function)) |
(documentation (symbol-function sym) 'function)) |
82 |
nil) |
nil) |
83 |
|
|
84 |
(deftest documentation.4 |
(deftest documentation.function.function.2 |
85 |
(let* ((sym (gensym))) |
(let* ((sym (gensym))) |
86 |
(eval `(defun ,sym () nil)) |
(eval `(defun ,sym () nil)) |
87 |
(let ((fn (symbol-function sym)) |
(let ((fn (symbol-function sym)) |
88 |
(doc "FOO")) |
(doc "FOO5")) |
89 |
(multiple-value-prog1 |
(multiple-value-prog1 |
90 |
(setf (documentation fn 'function) "FOO") |
(setf (documentation fn 'function) (copy-seq doc)) |
91 |
(assert (or (null (documentation fn 'function)) |
(assert (or (null (documentation fn 'function)) |
92 |
(equal doc (documentation fn 'function))))))) |
(equal doc (documentation fn 'function))))))) |
93 |
"FOO") |
"FOO5") |
94 |
|
|
95 |
|
(deftest documentation.function.function.3 |
96 |
|
(let* ((sym (gensym))) |
97 |
|
(eval `(defmacro ,sym () nil)) |
98 |
|
(documentation (symbol-function sym) 'function)) |
99 |
|
nil) |
100 |
|
|
101 |
|
(deftest documentation.function.function.4 |
102 |
|
(let* ((sym (gensym))) |
103 |
|
(eval `(defmacro ,sym () nil)) |
104 |
|
(let ((fn (macro-function sym)) |
105 |
|
(doc "FOO6")) |
106 |
|
(multiple-value-prog1 |
107 |
|
(setf (documentation fn t) (copy-seq doc)) |
108 |
|
(assert (or (null (documentation fn 'function)) |
109 |
|
(equal doc (documentation fn 'function))))))) |
110 |
|
"FOO6") |
111 |
|
|
112 |
|
(deftest documentation.function.function.5 |
113 |
|
(let* ((sym (gensym)) |
114 |
|
(fn (eval `(defgeneric ,sym (x))))) |
115 |
|
(documentation fn 'function)) |
116 |
|
nil) |
117 |
|
|
118 |
|
(deftest documentation.function.function.8 |
119 |
|
(let* ((sym (gensym)) |
120 |
|
(fn (eval `(defgeneric ,sym (x)))) |
121 |
|
(doc "FOO4A")) |
122 |
|
(multiple-value-prog1 |
123 |
|
(setf (documentation fn t) (copy-seq doc)) |
124 |
|
(assert (or (null (documentation fn 'function)) |
125 |
|
(equal doc (documentation fn 'function)))))) |
126 |
|
"FOO4A") |
127 |
|
|
|
|
|
128 |
|
|
129 |
|
;;; documentation (x list) (doc-type (eql 'function)) |
130 |
|
|
131 |
|
(deftest documentation.list.function.1 |
132 |
|
(let* ((sym (gensym))) |
133 |
|
(eval `(defun (setf ,sym) (&rest args) (declare (ignore args)) nil)) |
134 |
|
(documentation `(setf ,sym) 'function)) |
135 |
|
nil) |
136 |
|
|
137 |
|
(deftest documentation.list.function.2 |
138 |
|
(let* ((sym (gensym))) |
139 |
|
(eval `(defun (setf ,sym) (&rest args) (declare (ignore args)) nil)) |
140 |
|
(let ((fn `(setf ,sym)) |
141 |
|
(doc "FOO7")) |
142 |
|
(multiple-value-prog1 |
143 |
|
(setf (documentation fn 'function) (copy-seq doc)) |
144 |
|
(assert (or (null (documentation fn 'functiom)) |
145 |
|
(equal doc (documentation fn 'function))))))) |
146 |
|
"FOO7") |
147 |
|
|
148 |
|
;;; documentation (x list) (doc-type (eql 'compiler-macro)) |
149 |
|
|
150 |
|
(deftest documentation.list.compiler-macro.1 |
151 |
|
(let* ((sym (gensym))) |
152 |
|
(eval `(define-compiler-macro (setf ,sym) (&rest args) (declare (ignore args)) nil)) |
153 |
|
(documentation `(setf ,sym) 'compiler-macro)) |
154 |
|
nil) |
155 |
|
|
156 |
|
(deftest documentation.list.compiler-macro.2 |
157 |
|
(let* ((sym (gensym))) |
158 |
|
(eval `(define-compiler-macro (setf ,sym) (&rest args) (declare (ignore args)) nil)) |
159 |
|
(let ((fn `(setf ,sym)) |
160 |
|
(doc "FOO8")) |
161 |
|
(multiple-value-prog1 |
162 |
|
(setf (documentation fn 'compiler-macro) (copy-seq doc)) |
163 |
|
(assert (or (null (documentation fn 'functiom)) |
164 |
|
(equal doc (documentation fn 'compiler-macro))))))) |
165 |
|
"FOO8") |
166 |
|
|
167 |
|
;;; documentation (x symbol) (doc-type (eql 'function)) |
168 |
|
|
169 |
|
(deftest documentation.symbol.function.1 |
170 |
|
(let* ((sym (gensym))) |
171 |
|
(eval `(defun ,sym () nil)) |
172 |
|
(documentation sym 'function)) |
173 |
|
nil) |
174 |
|
|
175 |
|
(deftest documentation.symbol.function.2 |
176 |
|
(let* ((sym (gensym))) |
177 |
|
(eval `(defun ,sym () nil)) |
178 |
|
(let ((doc "FOO9")) |
179 |
|
(multiple-value-prog1 |
180 |
|
(setf (documentation sym 'function) (copy-seq doc)) |
181 |
|
(assert (or (null (documentation sym 'function)) |
182 |
|
(equal doc (documentation sym 'function))))))) |
183 |
|
"FOO9") |
184 |
|
|
185 |
|
(deftest documentation.symbol.function.3 |
186 |
|
(let* ((sym (gensym))) |
187 |
|
(eval `(defmacro ,sym () nil)) |
188 |
|
(documentation sym 'function)) |
189 |
|
nil) |
190 |
|
|
191 |
|
(deftest documentation.symbol.function.4 |
192 |
|
(let* ((sym (gensym))) |
193 |
|
(eval `(defmacro ,sym () nil)) |
194 |
|
(let ((doc "FOO9A")) |
195 |
|
(multiple-value-prog1 |
196 |
|
(setf (documentation sym 'function) (copy-seq doc)) |
197 |
|
(assert (or (null (documentation sym 'function)) |
198 |
|
(equal doc (documentation sym 'function))))))) |
199 |
|
"FOO9A") |
200 |
|
|
201 |
|
(deftest documentation.symbol.function.5 |
202 |
|
(let* ((sym (gensym))) |
203 |
|
(eval `(defgeneric ,sym (x))) |
204 |
|
(documentation sym 'function)) |
205 |
|
nil) |
206 |
|
|
207 |
|
(deftest documentation.symbol.function.6 |
208 |
|
(let* ((sym (gensym))) |
209 |
|
(eval `(defgeneric ,sym (x))) |
210 |
|
(let ((doc "FOO9B")) |
211 |
|
(multiple-value-prog1 |
212 |
|
(setf (documentation sym 'function) (copy-seq doc)) |
213 |
|
(assert (or (null (documentation sym 'function)) |
214 |
|
(equal doc (documentation sym 'function))))))) |
215 |
|
"FOO9B") |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
;;; documentation (x symbol) (doc-type (eql 'compiler-macro)) |
220 |
|
|
221 |
|
(deftest documentation.symbol.compiler-macro.1 |
222 |
|
(let* ((sym (gensym))) |
223 |
|
(eval `(define-compiler-macro ,sym (&rest args) (declare (ignore args)) nil)) |
224 |
|
(documentation sym 'compiler-macro)) |
225 |
|
nil) |
226 |
|
|
227 |
|
(deftest documentation.symbol.compiler-macro.2 |
228 |
|
(let* ((sym (gensym))) |
229 |
|
(eval `(define-compiler-macro ,sym (&rest args) (declare (ignore args)) nil)) |
230 |
|
(let ((doc "FOO10")) |
231 |
|
(multiple-value-prog1 |
232 |
|
(setf (documentation sym 'compiler-macro) (copy-seq doc)) |
233 |
|
(assert (or (null (documentation sym 'compiler-macro)) |
234 |
|
(equal doc (documentation sym 'compiler-macro))))))) |
235 |
|
"FOO10") |
236 |
|
|
237 |
|
;;; documentation (x symbol) (doc-type (eql 'setf)) |
238 |
|
|
239 |
|
(deftest documentation.symbol.setf.1 |
240 |
|
(let* ((sym (gensym)) |
241 |
|
(doc "FOO11")) |
242 |
|
(eval `(defun ,sym () (declare (special *x*)) *x*)) |
243 |
|
(eval `(define-setf-expander ,sym () |
244 |
|
(let ((g (gemsym))) |
245 |
|
(values nil nil (list g) `(locally (declare (special *x*)) (setf *x* ,g)) |
246 |
|
'(locally (declare (special *x*)) *x*))))) |
247 |
|
(multiple-value-prog1 |
248 |
|
(values |
249 |
|
(documentation sym 'setf) |
250 |
|
(setf (documentation sym 'setf) (copy-seq doc))) |
251 |
|
(assert (or (null (documentation sym 'setf)) |
252 |
|
(equal doc (documentation sym 'setf)))))) |
253 |
|
nil "FOO11") |
254 |
|
|
255 |
|
(deftest documentation.symbol.setf.2 |
256 |
|
(let* ((sym (gensym)) |
257 |
|
(doc "FOO12")) |
258 |
|
(eval `(defmacro ,sym () `(locally (declare (special *x*)) *x*))) |
259 |
|
(eval `(define-setf-expander ,sym () |
260 |
|
(let ((g (gemsym))) |
261 |
|
(values nil nil (list g) `(locally (declare (special *x*)) (setf *x* ,g)) |
262 |
|
'(locally (declare (special *x*)) *x*))))) |
263 |
|
(multiple-value-prog1 |
264 |
|
(values |
265 |
|
(documentation sym 'setf) |
266 |
|
(setf (documentation sym 'setf) (copy-seq doc))) |
267 |
|
(assert (or (null (documentation sym 'setf)) |
268 |
|
(equal doc (documentation sym 'setf)))))) |
269 |
|
nil "FOO12") |
270 |
|
|
271 |
|
;;; documentation (x method-combination) (doc-type (eql 't)) |
272 |
|
;;; documentation (x method-combination) (doc-type (eql 'method-combination)) |
273 |
|
;;; There's no portable way to test those, since there's no portable way to |
274 |
|
;;; get a method combination object |
275 |
|
|
276 |
|
;;; documentation (x symbol) (doc-type (eql 'method-combination)) |
277 |
|
|
278 |
|
(deftest documentation.symbol.method-combination.1 |
279 |
|
(let* ((sym (gensym)) |
280 |
|
(doc "FOO13")) |
281 |
|
(eval `(define-method-combination ,sym :identity-with-one-argument t)) |
282 |
|
(multiple-value-prog1 |
283 |
|
(values |
284 |
|
(documentation sym 'method-combination) |
285 |
|
(setf (documentation sym 'method-combination) (copy-seq doc))) |
286 |
|
(assert (or (null (documentation sym 'method-combination)) |
287 |
|
(equal doc (documentation sym 'method-combination)))))) |
288 |
|
nil "FOO13") |
289 |
|
|
290 |
|
;;; documentation (x standard-method) (doc-type (eql 't)) |
291 |
|
|
292 |
|
(deftest documentation.standard-method.t.1 |
293 |
|
(let* ((sym (gensym)) |
294 |
|
(doc "FOO14")) |
295 |
|
(eval `(defgeneric ,sym (x))) |
296 |
|
(let ((method (eval `(defmethod ,sym ((x t)) nil)))) |
297 |
|
(multiple-value-prog1 |
298 |
|
(values |
299 |
|
(documentation method t) |
300 |
|
(setf (documentation method t) (copy-seq doc))) |
301 |
|
(assert (or (null (documentation method 't)) |
302 |
|
(equal doc (documentation method 't))))))) |
303 |
|
nil "FOO14") |
304 |
|
|
305 |
|
;;; documentation (x package) (doc-type (eql 't)) |
306 |
|
|
307 |
|
(deftest documentation.package.t.1 |
308 |
|
(let ((package-name "PACKAGE-NAME-FOR-DOCUMENATION-TESTS-1")) |
309 |
|
(unwind-protect |
310 |
|
(progn |
311 |
|
(eval `(defpackage ,package-name (:use))) |
312 |
|
(let ((pkg (find-package package-name)) |
313 |
|
(doc "FOO15")) |
314 |
|
(assert pkg) |
315 |
|
(multiple-value-prog1 |
316 |
|
(values |
317 |
|
(documentation pkg t) |
318 |
|
(setf (documentation pkg t) (copy-seq doc))) |
319 |
|
(assert (or (null (documentation pkg 't)) |
320 |
|
(equal doc (documentation pkg 't))))))) |
321 |
|
(delete-package package-name))) |
322 |
|
nil "FOO15") |