add VOID selector
This commit is contained in:
parent
732a6422e6
commit
c9b78ce0d6
2 changed files with 23 additions and 0 deletions
|
|
@ -135,6 +135,17 @@
|
||||||
|
|
||||||
;; Built-in pathing and context operations
|
;; Built-in pathing and context operations
|
||||||
|
|
||||||
|
(defpath
|
||||||
|
^{:doc "Stops navigation at this point. For selection returns nothing and for
|
||||||
|
transformation returns the structure unchanged"}
|
||||||
|
VOID
|
||||||
|
[]
|
||||||
|
(select* [this structure next-fn]
|
||||||
|
nil )
|
||||||
|
(transform* [this structure next-fn]
|
||||||
|
structure
|
||||||
|
))
|
||||||
|
|
||||||
(def ALL (comp-paths (i/->AllStructurePath)))
|
(def ALL (comp-paths (i/->AllStructurePath)))
|
||||||
|
|
||||||
(def VAL (i/->ValCollect))
|
(def VAL (i/->ValCollect))
|
||||||
|
|
|
||||||
|
|
@ -566,6 +566,18 @@
|
||||||
(s/setval [:a s/NIL->VECTOR s/END] [:b] nil)))
|
(s/setval [:a s/NIL->VECTOR s/END] [:b] nil)))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defspec void-test
|
||||||
|
(for-all+
|
||||||
|
[s1 (gen/vector (limit-size 5 gen/int))]
|
||||||
|
(and
|
||||||
|
(empty? (s/select s/VOID s1))
|
||||||
|
(empty? (s/select [s/VOID s/ALL s/ALL s/ALL s/ALL] s1))
|
||||||
|
(= s1 (s/transform s/VOID inc s1))
|
||||||
|
(= s1 (s/transform [s/ALL s/VOID s/ALL] inc s1))
|
||||||
|
(= (s/transform [s/ALL (s/cond-path even? nil odd? s/VOID)] inc s1)
|
||||||
|
(s/transform [s/ALL even?] inc s1))
|
||||||
|
)))
|
||||||
|
|
||||||
#+clj
|
#+clj
|
||||||
(deftest large-params-test
|
(deftest large-params-test
|
||||||
(let [path (apply s/comp-paths (repeat 25 s/keypath))
|
(let [path (apply s/comp-paths (repeat 25 s/keypath))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue