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 291
291
(str " Call to " (pr-str v) " did not conform to spec:\n " (with-out-str (explain-out ed)))
292
292
ed)))
293
293
conformed)))]
294
- (doto
294
+ (cond->
295
295
(c/fn
296
296
[& args]
297
297
(if *instrument-enabled*
305
305
(conform! v :fn (:fn specs) {:args cargs :ret cret} args))
306
306
ret)))
307
307
(apply f args)))
308
- (gobj/extend f))))
308
+ (not ( instance? MultiFn f)) ( doto ( gobj/extend f) ))))
309
309
310
310
(defn- macroexpand-check
311
311
[v args]
Original file line number Diff line number Diff line change 1
1
(ns cljs.spec-test
2
2
(: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 ]]))
4
4
5
5
(s/def ::even? (s/and number? even?))
6
6
(s/def ::odd? (s/and number? odd?))
16
16
(let [xs [42 11 13 15 {:a 1 :b 2 :c 3 } 1 2 3 42 43 44 11 ]]
17
17
(is (= xs (s/unform s2 (s/conform s2 xs))))))
18
18
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
+
19
46
(comment
20
47
21
48
(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