|
199 | 199 | ["[a\rb]" "[a\r b]" "[a \rb]"])]
|
200 | 200 | (doseq [pairs (partition 2 1 read-vals)]
|
201 | 201 | (is (= (first pairs) (second pairs))))))
|
| 202 | + |
| 203 | +(deftest read-symbol |
| 204 | + (is (= 'foo (read-string "foo"))) |
| 205 | + (is (= 'foo/bar (read-string "foo/bar"))) |
| 206 | + (is (= '*+!-_? (read-string "*+!-_?"))) |
| 207 | + (is (= 'abc:def:ghi (read-string "abc:def:ghi"))) |
| 208 | + (is (= 'abc.def/ghi (read-string "abc.def/ghi"))) |
| 209 | + (is (= 'abc/def.ghi (read-string "abc/def.ghi"))) |
| 210 | + (is (= 'abc:def/ghi:jkl.mno (read-string "abc:def/ghi:jkl.mno"))) |
| 211 | + (is (instance? clojure.lang.Symbol (read-string "alphabet"))) |
| 212 | + (is (= "foo//" (str (read-string "foo//")))) |
| 213 | + (is (java.lang.Double/isNaN ^double (read-string "##NaN"))) |
| 214 | + (is (java.lang.Double/isInfinite ^double (read-string "##Inf"))) |
| 215 | + (is (java.lang.Double/isInfinite ^double (read-string "##-Inf"))) |
| 216 | + (testing "Correct array class symbols" |
| 217 | + (doseq [n (range 1 10) |
| 218 | + :let [sym (str "String/" n) |
| 219 | + qsym (str "java.lang.String/" n)]] |
| 220 | + (let [rsym (read-string sym) |
| 221 | + rqsym (read-string qsym)] |
| 222 | + (is (= ((juxt namespace name) rsym) |
| 223 | + ["String" (str n)])) |
| 224 | + (is (= ((juxt namespace name) rqsym) |
| 225 | + ["java.lang.String" (str n)]))))) |
| 226 | + (testing "Correct prim array symbols" |
| 227 | + (doseq [prim ["int" "long" "boolean" "byte" "char" "double" "float" "short"]] |
| 228 | + (doseq [n (range 1 10) |
| 229 | + :let [sym (str prim "/" n)]] |
| 230 | + (let [rsym (read-string sym)] |
| 231 | + (is (= ((juxt namespace name) rsym) |
| 232 | + [prim (str n)])))))) |
| 233 | + (testing "Incorrect Array class symbols" |
| 234 | + (doseq [suffix ["" "0" "11" "1a"] |
| 235 | + :let [sym (str "String/" suffix)]] |
| 236 | + (is (thrown? clojure.lang.ExceptionInfo (read-string sym)) sym)))) |
0 commit comments