Skip to content

Commit

Permalink
Merge pull request #4 from ikitommi/master
Browse files Browse the repository at this point in the history
Fix records with inserts
  • Loading branch information
plexus committed Nov 9, 2018
2 parents 0690935 + 08c196e commit 69d1fcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lambdaisland/deep_diff/diff.clj
Expand Up @@ -119,10 +119,10 @@
(assoc k (diff (get exp k) (get act k)))

(contains? ins idx)
(into (map (juxt ->Insertion act)) (get ins idx)))
(into (map (juxt ->Insertion (partial get act))) (get ins idx)))
(inc idx)])
[(if (contains? ins -1)
(into {} (map (juxt ->Insertion act)) (get ins -1))
(into {} (map (juxt ->Insertion (partial get act))) (get ins -1))
{}) 0]
exp-ks))))

Expand Down
6 changes: 4 additions & 2 deletions test/lambdaisland/deep_diff/diff_test.clj
Expand Up @@ -14,7 +14,7 @@
#'diff/del+ins]]
(alter-meta! v dissoc :private))

(defrecord ARecord [a])
(defrecord ARecord [])

(deftest diff-test
(testing "diffing atoms"
Expand Down Expand Up @@ -102,7 +102,9 @@

(testing "records"
(is (= {:a (diff/->Mismatch 1 2)}
(diff/diff (->ARecord 1) (->ARecord 2))))))
(diff/diff (map->ARecord {:a 1}) (map->ARecord {:a 2}))))
(is (= {(diff/->Insertion :a) 1}
(diff/diff (map->ARecord {}) (map->ARecord {:a 1}))))))

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

0 comments on commit 69d1fcb

Please sign in to comment.