File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 291291 (str " Call to " (pr-str v) " did not conform to spec:\n " (with-out-str (explain-out ed)))
292292 ed)))
293293 conformed)))]
294- (doto
294+ (cond->
295295 (c/fn
296296 [& args]
297297 (if *instrument-enabled*
305305 (conform! v :fn (:fn specs) {:args cargs :ret cret} args))
306306 ret)))
307307 (apply f args)))
308- (gobj/extend f))))
308+ (not ( instance? MultiFn f)) ( doto ( gobj/extend f) ))))
309309
310310(defn- macroexpand-check
311311 [v args]
Original file line number Diff line number Diff line change 11(ns cljs.spec-test
22 (:require [cljs.spec :as s]
3- [cljs.test :as test :refer-macros [deftest is]]))
3+ [cljs.test :as test :refer-macros [deftest is run-tests ]]))
44
55(s/def ::even? (s/and number? even?))
66(s/def ::odd? (s/and number? odd?))
1616 (let [xs [42 11 13 15 {:a 1 :b 2 :c 3 } 1 2 3 42 43 44 11 ]]
1717 (is (= xs (s/unform s2 (s/conform s2 xs))))))
1818
19+ (defn adder
20+ ([a] a)
21+ ([a b] (+ a b)))
22+
23+ (s/fdef adder
24+ :args (s/cat :a integer? :b (s/? integer?))
25+ :ret integer?)
26+
27+ (s/instrument #'adder)
28+
29+ (deftest test-multi-arity-instrument
30+ (is (= 1 (adder 1 )))
31+ (is (= 3 (adder 1 2 )))
32+ (is (thrown? js/Error (adder " foo" ))))
33+
34+ (defmulti testmm :type )
35+ (defmethod testmm :default [_])
36+ (defmethod testmm :good [_] " good" )
37+
38+ (s/fdef testmm :args (s/cat :m map?) :ret string?)
39+
40+ (s/instrument #'testmm)
41+
42+ (deftest test-multifn-instrument
43+ (is (= " good" (testmm {:type :good })))
44+ (is (thrown? js/Error (testmm " foo" ))))
45+
1946(comment
2047
2148 (s/conform s2 [42 11 13 15 {:a 1 :b 2 :c 3 } 1 2 3 42 43 44 11 ])
You can’t perform that action at this time.
0 commit comments