add satisfies-protpath?

This commit is contained in:
nathanmarz 2017-04-03 13:46:08 -04:00
parent 0bb3ac8440
commit c3164d722d
3 changed files with 14 additions and 2 deletions

View file

@ -1,5 +1,6 @@
## 1.0.1-SNAPSHOT
* Add `satisfies-protpath?`
* Inline cache vars are marked private so as not to interfere with tooling
* Bug fix: Using `pred` no longer inserts unecessary `coerce-nav` call at callsite
* Bug fix: Dynamic navs in argument position to another nav now properly expanded and compiled

View file

@ -430,6 +430,9 @@
(let [inav# ~retrieve]
(i/exec-transform* inav# ~@rargs))))))))
(defmacro satisfies-protpath? [protpath o]
`(satisfies? ~(protpath-sym protpath) ~o))
(defn extend-protocolpath* [protpath-prot extensions]
(let [m (-> protpath-prot :sigs keys first)
params (-> protpath-prot :sigs first last :arglists first)]

View file

@ -10,7 +10,7 @@
select-first transform setval replace-in
select-any selected-any? collected? traverse
multi-transform path dynamicnav recursive-path
defdynamicnav traverse-all]]))
defdynamicnav traverse-all satisfies-protpath?]]))
(:use
#?(:clj [clojure.test :only [deftest is]])
#?(:clj [clojure.test.check.clojure-test :only [defspec]])
@ -21,7 +21,7 @@
select-first transform setval replace-in
select-any selected-any? collected? traverse
multi-transform path dynamicnav recursive-path
defdynamicnav traverse-all]]))
defdynamicnav traverse-all satisfies-protpath?]]))
@ -1513,3 +1513,11 @@
(is (= [1] (foo 1)))
(is (= [10] (foo 10)))
))
(defprotocolpath FooPP)
(extend-protocolpath FooPP String s/STAY)
(deftest satisfies-protpath-test
(is (satisfies-protpath? FooPP "a"))
(is (not (satisfies-protpath? FooPP 1)))
)