1 ;;;; miscellaneous tests of SYMBOL-related stuff
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 ;;; Reported by Paul F. Dietz
15 (with-test (:name
(:symbol
:non-simple-string-name
))
16 (let ((sym (make-symbol (make-array '(1) :element-type
'character
17 :adjustable t
:initial-contents
"X"))))
18 (assert (simple-string-p (symbol-name sym
)))
19 (print sym
(make-broadcast-stream))))
21 (with-test (:name
(gentemp :pprinter
))
22 (let* ((*print-pprint-dispatch
* (copy-pprint-dispatch)))
23 (set-pprint-dispatch 'string
25 (declare (ignore obj
))
26 (write-string "BAR-" stream
)))
27 (assert (string= "FOO-" (gentemp "FOO-") :end2
4))))
29 (with-test (:name
(gensym :fixnum-restriction
))
30 (gensym (1+ most-positive-fixnum
)))
33 ;; CLHS states that SYMBOL-FUNCTION of a symbol naming a special operator
34 ;; or macro must return something implementation-defined that might not
35 ;; be a function. In this implementation it is a function, but it is illegal
36 ;; to assign that function into another symbol via (SETF FDEFINITION).
37 (with-test (:name
:setf-fdefinition-no-magic-functions
)
38 (assert-error (setf (fdefinition 'mysym
) (fdefinition 'and
)))
39 (assert-error (setf (fdefinition 'mysym
) (fdefinition 'if
)))
40 (assert-error (setf (symbol-function 'mysym
) (symbol-function 'and
)))
41 (assert-error (setf (symbol-function 'mysym
) (symbol-function 'if
))))
43 (with-test (:name
:macro-guard-function-name
)
45 (when (macro-function s
)
46 (let* ((f (symbol-function s
))
47 (name (sb-kernel:%fun-name f
)))
48 (if (special-operator-p s
)
49 (assert (typep name
'(cons (eql :special
)
51 (assert (typep name
'(cons (eql :macro
)
52 (cons symbol null
)))))))))
54 (with-test (:name
:fdefinition-no-consing
55 :skipped-on
:interpreter
)
56 (ctu:assert-no-consing
(fdefinition 'list
)))
58 (with-test (:name
:tree-shaker
:skipped-on
:sb-devel
)
59 ;; Assert that even without the "!" prefix convention
60 ;; these used-only-at-cross-compile-time macros disappear.
61 (dolist (s '("DEFINE-FOP"
66 "DEFINE-PRIMITIVE-OBJECT"))
67 (assert (not (apropos-list s
)))))
69 (with-test (:name
:progv-no-body
)
70 (checked-compile-and-assert