1
1
![ diffx] ( https://github.com/softwaremill/diffx/raw/master/banner.png )
2
2
3
- [ ![ CI ] ( https://github.com /softwaremill/diffx/workflows/CI/badge .svg )] ( https://github.com /softwaremill/diffx/actions?query=workflow%3A%22CI%22 )
3
+ [ ![ Build Status ] ( https://travis-ci.org /softwaremill/diffx.svg?branch=master )] ( https://travis-ci.org /softwaremill/diffx )
4
4
[ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/com.softwaremill.diffx/diffx-core_2.13/badge.svg )] ( https://search.maven.org/search?q=g:com.softwaremill.diffx )
5
5
[ ![ Gitter] ( https://badges.gitter.im/softwaremill/diffx.svg )] ( https://gitter.im/softwaremill/diffx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge )
6
6
[ ![ Mergify Status] ( https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/softwaremill/diffx&style=flat )] ( https://mergify.io )
@@ -38,7 +38,7 @@ The library is published for Scala 2.12 and 2.13.
38
38
Add the following dependency:
39
39
40
40
``` scala
41
- " com.softwaremill.diffx" %% " diffx-core" % " 0.4.5 "
41
+ " com.softwaremill.diffx" %% " diffx-core" % " 0.5.0 "
42
42
```
43
43
44
44
``` scala
@@ -51,34 +51,53 @@ val right: Foo = Foo(
51
51
List (123 , 1234 ),
52
52
Some (Bar (" asdf" , 5 ))
53
53
)
54
- // right: Foo = Foo(Bar("asdf", 5), List(123, 1234), Some(Bar("asdf", 5)))
54
+ // right: Foo = Foo(
55
+ // bar = Bar(s = "asdf", i = 5),
56
+ // b = List(123, 1234),
57
+ // parent = Some(value = Bar(s = "asdf", i = 5))
58
+ // )
55
59
56
60
val left : Foo = Foo (
57
61
Bar (" asdf" , 66 ),
58
62
List (1234 ),
59
63
Some (right)
60
64
)
61
65
// left: Foo = Foo(
62
- // Bar("asdf", 66),
63
- // List(1234),
64
- // Some(Foo(Bar("asdf", 5), List(123, 1234), Some(Bar("asdf", 5))))
66
+ // bar = Bar(s = "asdf", i = 66),
67
+ // b = List(1234),
68
+ // parent = Some(
69
+ // value = Foo(
70
+ // bar = Bar(s = "asdf", i = 5),
71
+ // b = List(123, 1234),
72
+ // parent = Some(value = Bar(s = "asdf", i = 5))
73
+ // )
74
+ // )
65
75
// )
66
76
67
77
import com .softwaremill .diffx .generic .auto ._
68
78
import com .softwaremill .diffx ._
69
79
compare(left, right)
70
80
// res0: DiffResult = DiffResultObject(
71
- // "Foo",
72
- // ListMap(
81
+ // name = "Foo",
82
+ // fields = ListMap(
73
83
// "bar" -> DiffResultObject(
74
- // "Bar",
75
- // ListMap("s" -> Identical("asdf"), "i" -> DiffResultValue(66, 5))
84
+ // name = "Bar",
85
+ // fields = ListMap(
86
+ // "s" -> Identical(value = "asdf"),
87
+ // "i" -> DiffResultValue(left = 66, right = 5)
88
+ // )
76
89
// ),
77
90
// "b" -> DiffResultObject(
78
- // "List",
79
- // ListMap("0" -> DiffResultValue(1234, 123), "1" -> DiffResultMissing(1234))
91
+ // name = "List",
92
+ // fields = ListMap(
93
+ // "0" -> DiffResultValue(left = 1234, right = 123),
94
+ // "1" -> DiffResultMissing(value = 1234)
95
+ // )
80
96
// ),
81
- // "parent" -> DiffResultValue("repl.MdocSession.App.Foo", "repl.MdocSession.App.Bar")
97
+ // "parent" -> DiffResultValue(
98
+ // left = "repl.MdocSession.App.Foo",
99
+ // right = "repl.MdocSession.App.Bar"
100
+ // )
82
101
// )
83
102
// )
84
103
```
@@ -131,7 +150,7 @@ If anyone has an idea how this could be improved, I am open for suggestions.
131
150
To use with scalatest, add the following dependency:
132
151
133
152
``` scala
134
- " com.softwaremill.diffx" %% " diffx-scalatest" % " 0.4.5 " % Test
153
+ " com.softwaremill.diffx" %% " diffx-scalatest" % " 0.5.0 " % Test
135
154
```
136
155
137
156
Then, extend the ` com.softwaremill.diffx.scalatest.DiffMatcher ` trait or ` import com.softwaremill.diffx.scalatest.DiffMatcher._ ` .
@@ -151,7 +170,7 @@ Giving you nice error messages:
151
170
To use with specs2, add the following dependency:
152
171
153
172
``` scala
154
- " com.softwaremill.diffx" %% " diffx-specs2" % " 0.4.5 " % Test
173
+ " com.softwaremill.diffx" %% " diffx-specs2" % " 0.5.0 " % Test
155
174
```
156
175
157
176
Then, extend the ` com.softwaremill.diffx.specs2.DiffMatcher ` trait or ` import com.softwaremill.diffx.specs2.DiffMatcher._ ` .
@@ -169,7 +188,7 @@ left must matchTo(right)
169
188
To use with utest, add following dependency:
170
189
171
190
``` scala
172
- " com.softwaremill.diffx" %% " diffx-utest" % " 0.4.5 " % Test
191
+ " com.softwaremill.diffx" %% " diffx-utest" % " 0.5.0 " % Test
173
192
```
174
193
175
194
Then, mixin ` DiffxAssertions ` trait or add ` import com.softwaremill.diffx.utest.DiffxAssertions._ ` to your test code.
@@ -191,7 +210,7 @@ instance of the `Diff` typeclass into the implicit scope. The whole process look
191
210
192
211
``` scala
193
212
case class Person (name: String , age: Int )
194
- implicit val modifiedDiff : Diff [Person ] = Derived [Diff [Person ]].ignore[ Person , String ] (_.name)
213
+ implicit val modifiedDiff : Diff [Person ] = Derived [Diff [Person ]].ignore(_.name)
195
214
```
196
215
197
216
## Customization
@@ -220,16 +239,16 @@ sealed trait ABParent
220
239
case class A (id : String , name : String ) extends ABParent
221
240
case class B (id : String , name : String ) extends ABParent
222
241
223
- implicit val diffA : Diff [A ] = Derived [Diff [A ]].ignore[ A , String ] (_.id)
242
+ implicit val diffA : Diff [A ] = Derived [Diff [A ]].ignore(_.id)
224
243
```
225
244
``` scala
226
245
val a1 : ABParent = A (" 1" , " X" )
227
- // a1: ABParent = A("1", "X")
246
+ // a1: ABParent = A(id = "1", name = "X")
228
247
val a2 : ABParent = A (" 2" , " X" )
229
- // a2: ABParent = A("2", "X")
248
+ // a2: ABParent = A(id = "2", name = "X")
230
249
231
250
compare(a1, a2)
232
- // res6: DiffResult = Identical(A( "1", "X"))
251
+ // res6: DiffResult = Identical(value = A(id = "1", name = "X"))
233
252
```
234
253
235
254
As you can see instead of summoning bare instance of ` Diff ` for given ` A ` we summoned ` Derived[Diff[A]] ` .
@@ -245,17 +264,17 @@ with the compiler option `"-P:silencer:globalFilters=^magnolia: using fallback d
245
264
246
265
- [ com.softwaremill.common.tagging] ( https://github.com/softwaremill/scala-common )
247
266
``` scala
248
- " com.softwaremill.diffx" %% " diffx-tagging" % " 0.4.5 "
267
+ " com.softwaremill.diffx" %% " diffx-tagging" % " 0.5.0 "
249
268
```
250
269
`com.softwaremill.diffx.tagging.DiffTaggingSupport`
251
270
- [eu.timepit.refined](https:// github.com/ fthomas/ refined)
252
271
```scala
253
- " com.softwaremill.diffx" %% " diffx-refined" % " 0.4.5 "
272
+ " com.softwaremill.diffx" %% " diffx-refined" % " 0.5.0 "
254
273
```
255
274
`com.softwaremill.diffx.refined.RefinedSupport`
256
275
- [org.typelevel.cats](https:// github.com/ typelevel/ cats)
257
276
```scala
258
- " com.softwaremill.diffx" %% " diffx-cats" % " 0.4.5 "
277
+ " com.softwaremill.diffx" %% " diffx-cats" % " 0.5.0 "
259
278
```
260
279
`com.softwaremill.diffx.cats.DiffCatsInstances`
261
280
0 commit comments