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"
4325
4325
is not acceptable to the new validator, an Error will be thrown and the
4326
4326
validator will not be changed."
4327
4327
[iref val]
4328
+ (when (and (some? val)
4329
+ (not (val (-deref iref))))
4330
+ (throw (js/Error. " Validator rejected reference state" )))
4328
4331
(set! (.-validator iref) val))
4329
4332
4330
4333
(defn get-validator
Original file line number Diff line number Diff line change 47
47
(testing " Testing atom validators"
48
48
(is (= coll? (get-validator a)))
49
49
(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)))))
50
59
(is (= {:a 1 } (meta a)))
51
60
(alter-meta! a assoc :b 2 )
52
61
(is (= {:a 1 :b 2 } (meta a)))))
You can’t perform that action at this time.
0 commit comments