From 97086068d63490a4abf638bba808ab0fb308fbd1 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Sun, 1 Mar 2015 20:33:42 -0500 Subject: [PATCH] fix ALL on regular lists from reversing order --- src/clj/com/rpl/specter/impl.clj | 9 ++++++--- test/clj/com/rpl/specter/core_test.clj | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/clj/com/rpl/specter/impl.clj b/src/clj/com/rpl/specter/impl.clj index 73c5386..b1bfb2f 100644 --- a/src/clj/com/rpl/specter/impl.clj +++ b/src/clj/com/rpl/specter/impl.clj @@ -142,9 +142,12 @@ (select* [this vals structure next-fn] (into [] (r/mapcat (partial next-fn vals) structure))) (update* [this vals structure next-fn] - (let [ret (r/map (partial next-fn vals) structure)] - (into (empty structure) ret)) - )) + (let [ret (r/map (partial next-fn vals) structure) + res (into (empty structure) ret)] + (if (list? structure) + (reverse res) + res + )))) (deftype ValStructurePath [] StructurePath diff --git a/test/clj/com/rpl/specter/core_test.clj b/test/clj/com/rpl/specter/core_test.clj index fd3e1c0..d7637fa 100644 --- a/test/clj/com/rpl/specter/core_test.clj +++ b/test/clj/com/rpl/specter/core_test.clj @@ -68,7 +68,14 @@ (for-all+ [v (gen/vector gen/int)] (let [v2 (update [ALL] inc v)] - (= v2 (map inc v)) + (and (vector? v2) (= v2 (map inc v))) + ))) + +(defspec update-all-list + (for-all+ + [v (gen/list gen/int)] + (let [v2 (update [ALL] inc v)] + (and (list? v2) (= v2 (map inc v))) ))) (defspec update-all-filter