Skip to content

Commit f58dcdf

Browse files
DaoWendnolen
authored andcommitted
CLJS-1583: (hash (symbol "/")) does not match (hash '/)
Modify symbol function to correctly handle "/" corner-case, and add tests comparing properties of '/ vs (symbol "/").
1 parent e531c34 commit f58dcdf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@
978978
(if (symbol? name)
979979
name
980980
(let [idx (.indexOf name "/")]
981-
(if (== idx -1)
981+
(if (< idx 1)
982982
(symbol nil name)
983983
(symbol (.substring name 0 idx)
984984
(.substring name (inc idx) (. name -length)))))))

src/test/cljs/cljs/core_test.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@
302302
(testing "Testing symbol ctor is idempotent"
303303
(is (= 'a (symbol 'a))))
304304

305+
(testing "Testing constructed division symbol"
306+
(is (= '/ (symbol "/")))
307+
(is (= (namespace '/) (namespace (symbol "/"))))
308+
(is (= (hash '/) (hash (symbol "/")))))
309+
305310
(testing "Testing keyword ctor"
306311
(is (= :a (keyword "a")))
307312
(is (= :a (keyword 'a)))

0 commit comments

Comments
 (0)