|
51 | 51 | (defmethod get-comparator PersistentTreeSet
|
52 | 52 | [o] (get-comparator (.-tree-map o)))
|
53 | 53 |
|
54 |
| -(deftest walk |
55 |
| - "Checks that walk returns the correct result and type of collection" |
56 |
| - (let [colls ['(1 2 3) |
57 |
| - [1 2 3] |
58 |
| - #{1 2 3} |
59 |
| - (sorted-set-by > 1 2 3) |
60 |
| - {:a 1, :b 2, :c 3} |
61 |
| - (sorted-map-by > 1 10, 2 20, 3 30) |
62 |
| - (->Foo 1 2 3) |
63 |
| - (map->Foo {:a 1 :b 2 :c 3 :extra 4})]] |
64 |
| - (doseq [c colls] |
65 |
| - (let [walked (w/walk identity identity c)] |
66 |
| - (is (= c walked)) |
67 |
| - ;;(is (= (type c) (type walked))) |
68 |
| - (if (map? c) |
69 |
| - (is (= (w/walk #(update-in % [1] inc) #(reduce + (vals %)) c) |
70 |
| - (reduce + (map (comp inc val) c)))) |
71 |
| - (is (= (w/walk inc #(reduce + %) c) |
72 |
| - (reduce + (map inc c))))) |
73 |
| - (when (or (instance? PersistentTreeMap c) |
74 |
| - (instance? PersistentTreeSet c)) |
75 |
| - (is (= (get-comparator c) (get-comparator walked)))))))) |
| 54 | +(deftest test-walk |
| 55 | + (testing "Test that walk returns the correct result\n" |
| 56 | + (let [colls ['(1 2 3) |
| 57 | + [1 2 3] |
| 58 | + #{1 2 3} |
| 59 | + (sorted-set-by > 1 2 3) |
| 60 | + {:a 1, :b 2, :c 3} |
| 61 | + (sorted-map-by > 1 10, 2 20, 3 30) |
| 62 | + (->Foo 1 2 3) |
| 63 | + (map->Foo {:a 1 :b 2 :c 3 :extra 4})]] |
| 64 | + (doseq [c colls] |
| 65 | + (testing (str "Walking ... " c) |
| 66 | + (let [walked (w/walk identity identity c)] |
| 67 | + (is (= c walked)) |
| 68 | + ;;(is (= (type c) (type walked))) |
| 69 | + (if (map? c) |
| 70 | + (is (= (w/walk #(update-in % [1] inc) #(reduce + (vals %)) c) |
| 71 | + (reduce + (map (comp inc val) c)))) |
| 72 | + (is (= (w/walk inc #(reduce + %) c) |
| 73 | + (reduce + (map inc c))))) |
| 74 | + (when (or (instance? PersistentTreeMap c) |
| 75 | + (instance? PersistentTreeSet c)) |
| 76 | + (is (= (get-comparator c) (get-comparator walked)))))))))) |
76 | 77 |
|
77 | 78 | (deftest walk-mapentry
|
78 | 79 | "Checks that walk preserves the MapEntry type. See CLJS-2909."
|
|
0 commit comments