make-symbol.lsp 3.26 KB
Newer Older
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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Jun 14 05:45:21 2003
;;;; Contains: Tests of MAKE-SYMBOL

(in-package :cl-test)

(deftest make-symbol.1
  (notnot-mv (symbolp (make-symbol "FOO")))
  t)

(deftest make-symbol.2
  (symbol-package (make-symbol "BAR"))
  nil)

(deftest make-symbol.3
  (symbol-package (make-symbol "CL::FOO"))
  nil)

(deftest make-symbol.4
  (symbol-package (make-symbol "CL:FOO"))
  nil)

(deftest make-symbol.5
  (symbol-name (make-symbol "xyz"))
  "xyz")

(deftest make-symbol.6
    (eqt (make-symbol "A")
sds's avatar
sds committed
30
        (make-symbol "A"))
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  nil)

(deftest make-symbol.7
  (boundp (make-symbol "B"))
  nil)

(deftest make-symbol.8
  (symbol-plist (make-symbol "C"))
  nil)

(deftest make-symbol.9
  (fboundp (make-symbol "D"))
  nil)

(deftest make-symbol.10
  (symbol-name (make-symbol ""))
  "")

49
(deftest make-symbol.11
50
  :notes (:nil-vectors-are-strings)
51 52 53
  (symbol-name (make-symbol (make-array '(0) :element-type nil)))
  "")

54 55
(deftest make-symbol.12
  (let* ((name (make-array '(4) :initial-contents '(#\A #\B #\C #\D)
sds's avatar
sds committed
56 57 58
                           :element-type 'base-char))
         (s (make-symbol name))
         (name2 (symbol-name s)))
59 60 61 62 63 64 65
    (values
     (symbol-package s)
     (string=t name2 "ABCD")))
  nil t)

(deftest make-symbol.13
  (let* ((name (make-array '(6) :initial-contents '(#\A #\B #\C #\D #\E #\F)
sds's avatar
sds committed
66 67 68 69
                           :element-type 'character
                           :fill-pointer 4))
         (s (make-symbol name))
         (name2 (symbol-name s)))
70 71 72 73 74 75 76
    (values
     (symbol-package s)
     (string=t name2 "ABCD")))
  nil t)

(deftest make-symbol.14
  (let* ((name (make-array '(4) :initial-contents '(#\A #\B #\C #\D)
sds's avatar
sds committed
77 78 79 80
                           :adjustable t
                           :element-type 'character))
         (s (make-symbol name))
         (name2 (symbol-name s)))
81 82 83 84 85 86 87
    (values
     (symbol-package s)
     (string=t name2 "ABCD")))
  nil t)

(deftest make-symbol.15
  (let* ((name0 (make-array '(6) :initial-contents '(#\0 #\A #\B #\C #\D #\E)
sds's avatar
sds committed
88 89 90 91 92 93
                            :element-type 'character))
         (name (make-array '(4) :element-type 'character
                           :displaced-to name0
                           :displaced-index-offset 1))
         (s (make-symbol name))
         (name2 (symbol-name s)))
94 95 96 97 98 99 100
    (values
     (symbol-package s)
     (string=t name2 "ABCD")))
  nil t)

(deftest make-symbol.16
  (let* ((name0 (make-array '(6) :initial-contents '(#\0 #\A #\B #\C #\D #\E)
sds's avatar
sds committed
101 102 103 104 105 106
                            :element-type 'base-char))
         (name (make-array '(4) :element-type 'base-char
                           :displaced-to name0
                           :displaced-index-offset 1))
         (s (make-symbol name))
         (name2 (symbol-name s)))
107 108 109 110 111 112
    (values
     (symbol-package s)
     (string=t name2 "ABCD")))
  nil t)


113 114 115 116 117 118 119 120
(deftest make-symbol.order.1
  (let ((i 0))
    (values
     (symbol-name (make-symbol (progn (incf i) "ABC")))
     i))
  "ABC" 1)

(deftest make-symbol.error.1
pfdietz's avatar
pfdietz committed
121 122
  (check-type-error #'make-symbol #'stringp)
  nil)
123 124

(deftest make-symbol.error.9
125 126
  (signals-error (make-symbol) program-error)
  t)
127 128

(deftest make-symbol.error.10
129 130
  (signals-error (make-symbol "a" "a") program-error)
  t)
131 132

(deftest make-symbol.error.11
pfdietz's avatar
pfdietz committed
133
  (signals-type-error x '(#\a #\b #\c) (make-symbol x))
134
  t)