File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,11 @@ the sorting function."}
43
43
{:added " 1.1" }
44
44
[inner outer form]
45
45
(cond
46
- (list? form) (outer (apply list (map inner form)))
47
- (satisfies? IMapEntry form) (outer (vec (map inner form)))
48
- (seq? form) (outer (doall (map inner form)))
49
- (satisfies? IRecord form)
50
- (outer (reduce (fn [r x] (conj r (inner x))) form form))
51
- (coll? form) (outer (into (empty form) (map inner form)))
52
- :else (outer form)))
46
+ (list? form) (outer (apply list (map inner form)))
47
+ (seq? form) (outer (doall (map inner form)))
48
+ (record? form) (outer (reduce (fn [r x] (conj r (inner x))) form form))
49
+ (coll? form) (outer (into (empty form) (map inner form)))
50
+ :else (outer form)))
53
51
54
52
(defn postwalk
55
53
" Performs a depth-first, post-order traversal of form. Calls f on
Original file line number Diff line number Diff line change 19
19
(w/prewalk #(if (keyword? %) (str %) %) (Rec1. 1 )))
20
20
" Mirror Clojure behavior" )))
21
21
22
-
22
+ (deftest test-preserves-meta
23
+ (testing " Test preserves meta"
24
+ (is (= (-> (w/prewalk identity [1 (with-meta [1 2 ] {:foo 3 })])
25
+ (nth 1 ) meta)
26
+ {:foo 3 }))
27
+ (is (= (-> (w/postwalk identity [1 (with-meta [1 2 ] {:foo 3 })])
28
+ (nth 1 ) meta)
29
+ {:foo 3 }))))
You can’t perform that action at this time.
0 commit comments