Skip to content

Commit 73e9929

Browse files
mfikesdnolen
authored andcommitted
CLJS-1638: :elide-asserts disables atom validators in :advanced
1 parent e8d14e6 commit 73e9929

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4244,7 +4244,8 @@ reduces them without incurring seq initialization"
42444244
(if (instance? Atom a)
42454245
(let [validate (.-validator a)]
42464246
(when-not (nil? validate)
4247-
(assert (validate new-value) "Validator rejected reference state"))
4247+
(when-not (validate new-value)
4248+
(throw (js/Error. "Validator rejected reference state"))))
42484249
(let [old-value (.-state a)]
42494250
(set! (.-state a) new-value)
42504251
(when-not (nil? (.-watches a))

src/test/cljs/cljs/core_test.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@
743743
(let [a (atom [1] :validator coll? :meta {:a 1})]
744744
(testing "Testing atom validators"
745745
(is (= coll? (get-validator a)))
746+
(is (thrown? js/Error (reset! a 1)))
746747
(is (= {:a 1} (meta a)))
747748
(alter-meta! a assoc :b 2)
748749
(is (= {:a 1 :b 2} (meta a)))))

0 commit comments

Comments
 (0)