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 (in-package "CL-USER")
16 ;;; Reported by Paul F. Dietz
17 (with-test (:name
(:symbol
:non-simple-string-name
))
18 (let ((sym (make-symbol (make-array '(1) :element-type
'character
19 :adjustable t
:initial-contents
"X"))))
20 (assert (simple-string-p (symbol-name sym
)))
21 (print sym
(make-broadcast-stream))))
23 (with-test (:name
(gentemp :pprinter
))
24 (let* ((*print-pprint-dispatch
* (copy-pprint-dispatch)))
25 (set-pprint-dispatch 'string
27 (declare (ignore obj
))
28 (write-string "BAR-" stream
)))
29 (assert (string= "FOO-" (gentemp "FOO-") :end2
4))))
31 (with-test (:name
(gensym :fixnum-restriction
))
32 (gensym (1+ most-positive-fixnum
)))
35 ;; CLHS states that SYMBOL-FUNCTION of a symbol naming a special operator
36 ;; or macro must return something implementation-defined that might not
37 ;; be a function. In this implementation it is a function, but it is illegal
38 ;; to assign that function into another symbol via (SETF FDEFINITION).
39 (with-test (:name
:setf-fdefinition-no-magic-functions
)
40 (assert-error (setf (fdefinition 'mysym
) (fdefinition 'and
)))
41 (assert-error (setf (fdefinition 'mysym
) (fdefinition 'if
)))
42 (assert-error (setf (symbol-function 'mysym
) (symbol-function 'and
)))
43 (assert-error (setf (symbol-function 'mysym
) (symbol-function 'if
))))
45 (with-test (:name
:macro-guard-function-name
)
47 (when (macro-function s
)
48 (let* ((f (symbol-function s
))
49 (name (sb-kernel:%fun-name f
)))
50 (if (special-operator-p s
)
51 (assert (typep name
'(cons (eql :special
)
53 (assert (typep name
'(cons (eql :macro
)
54 (cons symbol null
)))))))))
56 (load "compiler-test-util.lisp")
58 (with-test (:name
:fdefinition-no-consing
59 :skipped-on
:interpreter
)
60 (ctu:assert-no-consing
(fdefinition 'list
)))