|
6 | 6 | (t/assert= (:a m) 1) |
7 | 7 | (t/assert= (:b m) 2) |
8 | 8 | (t/assert= (:c m) 3) |
9 | | - |
10 | 9 | (t/assert= (:d m) nil) |
11 | 10 | (t/assert= (:d m :foo) :foo))) |
12 | 11 |
|
|
29 | 28 | (t/assert= (not= :foo/bar :cat/bar) true) |
30 | 29 | (t/assert= (not= :foo/cat :foo/dog) true)) |
31 | 30 |
|
| 31 | +(t/deftest keyword-reader |
| 32 | + (t/assert= (read-string ":1") :1) |
| 33 | + (t/assert= (read-string ":1") :1) |
| 34 | + (t/assert= (read-string ":1.0") :1.0) |
| 35 | + (t/assert= (read-string ":foo") :foo) |
| 36 | + (t/assert= (read-string ":1foo") :1foo) |
| 37 | + (t/assert= (read-string ":foo/bar") :foo/bar) |
| 38 | + (t/assert= (read-string ":1foo/1bar") :1foo/1bar) |
| 39 | + (t/assert= (read-string ":nil") :nil) |
| 40 | + (t/assert= (read-string ":true") :true) |
| 41 | + (t/assert= (read-string ":false") :false) |
| 42 | + |
| 43 | + ;; We are reading at runtime so the namespace isn't |
| 44 | + ;; going to be pixie.test.test-keywords. Its probably |
| 45 | + ;; 'user but lets explicitly set it. |
| 46 | + ;; The refer-ns is to initialize a new space |
| 47 | + (refer-ns 'my.other.ns 'my.fake.core 'fake) |
| 48 | + (binding [*ns* (the-ns 'my.other.ns)] |
| 49 | + (t/assert= (read-string "::1") :my.other.ns/1) |
| 50 | + (t/assert= (read-string "::1.0") :my.other.ns/1.0) |
| 51 | + (t/assert= (read-string "::foo") :my.other.ns/foo) |
| 52 | + (t/assert= (read-string "::true") :my.other.ns/true))) |
| 53 | + |
32 | 54 | (t/deftest string-to-keyword |
| 55 | + (t/assert= (keyword "1") :1) |
| 56 | + (t/assert= (keyword "1") :1) |
| 57 | + (t/assert= (keyword "1.0") :1.0) |
33 | 58 | (t/assert= (keyword "foo") :foo) |
| 59 | + (t/assert= (keyword "1foo") :1foo) |
34 | 60 | (t/assert= (keyword "foo/bar") :foo/bar) |
| 61 | + (t/assert= (keyword "1foo/1bar") :1foo/1bar) |
| 62 | + (t/assert= (keyword "nil") :nil) |
| 63 | + (t/assert= (keyword "true") :true) |
| 64 | + (t/assert= (keyword "false") :false) |
35 | 65 | (t/assert-throws? (keyword 1)) |
36 | 66 | (t/assert-throws? (keyword :a)) |
37 | 67 | (t/assert-throws? (keyword 'a)) |
|
0 commit comments