|
1 | | -(ns lambdaisland.deep-diff2.manipulate-test |
| 1 | +(ns lambdaisland.deep-diff2.minimize-test |
2 | 2 | (:require [clojure.test :refer [deftest testing is are]] |
3 | 3 | [lambdaisland.deep-diff2.diff-test :as diff-test] |
4 | 4 | [clojure.test.check.clojure-test :refer [defspec]] |
5 | 5 | [clojure.test.check.generators :as gen] |
6 | 6 | [clojure.test.check.properties :as prop] |
7 | 7 | [lambdaisland.deep-diff2.diff-impl :as diff] |
8 | | - [lambdaisland.deep-diff2.manipulate :as manipulate] |
9 | 8 | [lambdaisland.deep-diff2 :as ddiff])) |
10 | 9 |
|
11 | 10 | (deftest basic-strip-test |
12 | | - (testing "diff without remove-unchanged" |
| 11 | + (testing "diff without minimize" |
13 | 12 | (let [x {:a 1 :b 2 :d {:e 1} :g [:e [:k 14 :g 15]]} |
14 | 13 | y {:a 1 :c 3 :d {:e 15} :g [:e [:k 14 :g 15]]}] |
15 | 14 | (is (= (ddiff/diff x y) |
|
18 | 17 | :d {:e (diff/->Mismatch 1 15)} |
19 | 18 | :g [:e [:k 14 :g 15]] |
20 | 19 | (diff/->Insertion :c) 3})))) |
21 | | - (testing "diff with remove-unchanged" |
| 20 | + (testing "diff with minimize" |
22 | 21 | (let [x {:a 1 :b 2 :d {:e 1} :g [:e [:k 14 :g 15]]} |
23 | 22 | y {:a 1 :c 3 :d {:e 15} :g [:e [:k 14 :g 15]]}] |
24 | | - (is (= (manipulate/remove-unchanged (ddiff/diff x y)) |
| 23 | + (is (= (ddiff/minimize (ddiff/diff x y)) |
25 | 24 | {(diff/->Deletion :b) 2 |
26 | 25 | :d {:e (diff/->Mismatch 1 15)} |
27 | 26 | (diff/->Insertion :c) 3}))))) |
28 | 27 |
|
29 | | -(deftest remove-unchanged-on-diff-test |
| 28 | +(deftest minimize-on-diff-test |
30 | 29 | (testing "diffing atoms" |
31 | 30 | (testing "when different" |
32 | | - (is (= (manipulate/remove-unchanged |
| 31 | + (is (= (ddiff/minimize |
33 | 32 | (ddiff/diff :a :b)) |
34 | 33 | (diff/->Mismatch :a :b)))) |
35 | 34 |
|
36 | 35 | (testing "when equal" |
37 | | - (is (= (manipulate/remove-unchanged |
| 36 | + (is (= (ddiff/minimize |
38 | 37 | (ddiff/diff :a :a)) |
39 | 38 | nil)))) |
40 | 39 |
|
41 | 40 | (testing "diffing collections" |
42 | 41 | (testing "when different collection types" |
43 | | - (is (= (manipulate/remove-unchanged |
| 42 | + (is (= (ddiff/minimize |
44 | 43 | (ddiff/diff [:a :b] #{:a :b})) |
45 | 44 | (diff/->Mismatch [:a :b] #{:a :b})))) |
46 | 45 |
|
47 | 46 | (testing "when equal with clojure set" |
48 | | - (is (= (manipulate/remove-unchanged |
| 47 | + (is (= (ddiff/minimize |
49 | 48 | (ddiff/diff #{:a :b} #{:a :b})) |
50 | 49 | #{}))) |
51 | 50 |
|
52 | 51 | (testing "when different with clojure set" |
53 | | - (is (= (manipulate/remove-unchanged |
| 52 | + (is (= (ddiff/minimize |
54 | 53 | (ddiff/diff #{:a :b :c} #{:a :b :d})) |
55 | 54 | #{(diff/->Insertion :d) (diff/->Deletion :c)}))) |
56 | 55 |
|
57 | 56 | (testing "when equal with clojure vector" |
58 | | - (is (= (manipulate/remove-unchanged |
| 57 | + (is (= (ddiff/minimize |
59 | 58 | (ddiff/diff [:a :b] [:a :b])) |
60 | 59 | []))) |
61 | 60 |
|
62 | 61 | (testing "when equal with clojure hashmap" |
63 | | - (is (= (manipulate/remove-unchanged |
| 62 | + (is (= (ddiff/minimize |
64 | 63 | (ddiff/diff {:a 1} {:a 1})) |
65 | 64 | {}))) |
66 | 65 |
|
67 | 66 | (testing "when equal with clojure nesting vector" |
68 | | - (is (= (manipulate/remove-unchanged |
| 67 | + (is (= (ddiff/minimize |
69 | 68 | (ddiff/diff [:a [:b :c :d]] [:a [:b :c :d]])) |
70 | 69 | []))))) |
71 | 70 |
|
72 | | -;; "diff itself and remove-unchanged yields empty" |
| 71 | +;; "diff itself and minimize yields empty" |
73 | 72 | (defspec diff-itself 100 |
74 | 73 | (prop/for-all |
75 | 74 | [x diff-test/gen-any-except-NaN] |
76 | 75 | (if (coll? x) |
77 | | - (= (manipulate/remove-unchanged (ddiff/diff x x)) |
| 76 | + (= (ddiff/minimize (ddiff/diff x x)) |
78 | 77 | (empty x)) |
79 | | - (nil? (manipulate/remove-unchanged (ddiff/diff x x)))))) |
| 78 | + (nil? (ddiff/minimize (ddiff/diff x x)))))) |
0 commit comments