Skip to content

Commit 08c196e

Browse files
committed
Fix records with inserts
1 parent 0690935 commit 08c196e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/lambdaisland/deep_diff/diff.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@
119119
(assoc k (diff (get exp k) (get act k)))
120120

121121
(contains? ins idx)
122-
(into (map (juxt ->Insertion act)) (get ins idx)))
122+
(into (map (juxt ->Insertion (partial get act))) (get ins idx)))
123123
(inc idx)])
124124
[(if (contains? ins -1)
125-
(into {} (map (juxt ->Insertion act)) (get ins -1))
125+
(into {} (map (juxt ->Insertion (partial get act))) (get ins -1))
126126
{}) 0]
127127
exp-ks))))
128128

test/lambdaisland/deep_diff/diff_test.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'diff/del+ins]]
1515
(alter-meta! v dissoc :private))
1616

17-
(defrecord ARecord [a])
17+
(defrecord ARecord [])
1818

1919
(deftest diff-test
2020
(testing "diffing atoms"
@@ -102,7 +102,9 @@
102102

103103
(testing "records"
104104
(is (= {:a (diff/->Mismatch 1 2)}
105-
(diff/diff (->ARecord 1) (->ARecord 2))))))
105+
(diff/diff (map->ARecord {:a 1}) (map->ARecord {:a 2}))))
106+
(is (= {(diff/->Insertion :a) 1}
107+
(diff/diff (map->ARecord {}) (map->ARecord {:a 1}))))))
106108

107109
(is (= [{:x (diff/->Mismatch 1 2)}]
108110
(diff/diff [{:x 1}] [{:x 2}])))

0 commit comments

Comments
 (0)