Merge pull request #87 from rakeshp/master
Added path to navigate to atom value
This commit is contained in:
commit
4a5f0b79b8
2 changed files with 16 additions and 0 deletions
|
|
@ -279,6 +279,17 @@
|
||||||
(assoc structure key (next-fn (get structure key)))
|
(assoc structure key (next-fn (get structure key)))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(defpath
|
||||||
|
^{:doc "Navigates to atom value."}
|
||||||
|
ATOM
|
||||||
|
[]
|
||||||
|
(select* [this structure next-fn]
|
||||||
|
(next-fn @structure))
|
||||||
|
(transform* [this structure next-fn]
|
||||||
|
(do
|
||||||
|
(reset! structure (next-fn @structure))
|
||||||
|
structure)))
|
||||||
|
|
||||||
(defpath
|
(defpath
|
||||||
^{:doc "Navigates to the key only if it exists in the map."}
|
^{:doc "Navigates to the key only if it exists in the map."}
|
||||||
must
|
must
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,11 @@
|
||||||
(is (= 5 (s/select-one (s/comp-paths :a :b) {:a {:b 5}})))
|
(is (= 5 (s/select-one (s/comp-paths :a :b) {:a {:b 5}})))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(deftest atom-test
|
||||||
|
(let [v (s/transform s/ATOM inc (atom 1))]
|
||||||
|
(is (instance? clojure.lang.Atom v))
|
||||||
|
(is (= 2 (s/select-one s/ATOM v) @v))))
|
||||||
|
|
||||||
(defspec view-test
|
(defspec view-test
|
||||||
(for-all+
|
(for-all+
|
||||||
[i gen/int
|
[i gen/int
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue