Permalink
Browse files

CLJS-768: Fix assoc!-ing non-numeric keys into TransientVector.

  • Loading branch information...
1 parent 90cf724 commit 8419d8aeb6d2e975029fc693f96137775d2442c6 @favila favila committed with swannodette Feb 21, 2014
Showing with 10 additions and 2 deletions.
  1. +4 −1 src/cljs/cljs/core.cljs
  2. +6 −1 test/cljs/cljs/core_test.cljs
View
@@ -3773,7 +3773,10 @@ reduces them without incurring seq initialization"
(throw (js/Error. "persistent! called twice"))))
ITransientAssociative
- (-assoc! [tcoll key val] (-assoc-n! tcoll key val))
+ (-assoc! [tcoll key val]
+ (if (number? key)
+ (-assoc-n! tcoll key val)
+ (throw (js/Error. "TransientVector's key for assoc! must be a number."))))
ITransientVector
(-assoc-n! [tcoll n val]
@@ -2076,7 +2076,6 @@
(assert (= (-> (transient {}) (assoc! :a 1 :b 2) persistent!) {:a 1 :b 2}))
(assert (= (-> (transient {:a 1 :b 2 :c 3}) (dissoc! :a :b) persistent!) {:c 3}))
-
;; CLJS-767
(doseq [n [nil "-1" "" "0" "1" false true (js-obj)]]
@@ -2087,5 +2086,11 @@
(assert (= :fail (try (assoc (range 1 3) n 4)
(catch js/Error e :fail)))))
+ ;; CLJS-768
+
+ (doseq [n [nil "-1" "" "0" "1" false true (js-obj)]]
+ (assert (= :fail (try (assoc! (transient [1 2]) n 4)
+ (catch js/Error e :fail)))))
+
:ok
)

0 comments on commit 8419d8a

Please sign in to comment.