File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -4325,6 +4325,9 @@ reduces them without incurring seq initialization"
43254325 is not acceptable to the new validator, an Error will be thrown and the
43264326 validator will not be changed."
43274327 [iref val]
4328+ (when (and (some? val)
4329+ (not (val (-deref iref))))
4330+ (throw (js/Error. " Validator rejected reference state" )))
43284331 (set! (.-validator iref) val))
43294332
43304333(defn get-validator
Original file line number Diff line number Diff line change 4747 (testing " Testing atom validators"
4848 (is (= coll? (get-validator a)))
4949 (is (thrown? js/Error (reset! a 1 )))
50+ (is (thrown? js/Error (set-validator! a number?)))
51+ (is (some? (get-validator a)))
52+ (set-validator! a nil )
53+ (is (nil? (get-validator a)))
54+ (let [e1 (ex-info " " {})]
55+ (try
56+ (set-validator! a (fn [_] (throw e1)))
57+ (catch :default e2
58+ (is (identical? e1 e2)))))
5059 (is (= {:a 1 } (meta a)))
5160 (alter-meta! a assoc :b 2 )
5261 (is (= {:a 1 :b 2 } (meta a)))))
You can’t perform that action at this time.
0 commit comments