diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index 12bb528..a10eaf3 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -270,11 +270,11 @@ (next-fn (afn structure)) )) -(defpath biview [afn bfn] +(defpath parser [parse unparse] (select* [this structure next-fn] - (next-fn (afn structure))) + (next-fn (parse structure))) (transform* [this structure next-fn] - (bfn (next-fn (afn structure))) + (unparse (next-fn (parse structure))) )) (defn selected? diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index 442d7a4..e150c87 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -242,6 +242,16 @@ (s/transform (s/view afn) identity i) ))) +(defspec parser-test + (for-all+ + [i gen/int + j gen/int] + (and (= (first (s/select (s/parser #(+ % j) #(- % j)) i)) + (+ j i)) + (= (s/transform (s/parser #(+ % j) #(- % j)) identity i) + i) + ))) + (deftest selected?-test (is (= [[1 3 5] [2 :a] [7 11 4 2 :a] [10 1 :a] []] (s/setval [s/ALL (s/selected? s/ALL even?) s/END]