This repository was archived by the owner on Jan 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +20
-19
lines changed
munit/src/main/scala/com/softwaremill/diffx/munit
scalatest/src/main/scala/com/softwaremill/diffx/scalatest
specs2/src/main/scala/com/softwaremill/diffx/specs2
utest/src/main/scala/com/softwaremill/diffx/utest Expand file tree Collapse file tree 4 files changed +20
-19
lines changed Original file line number Diff line number Diff line change 1
1
package com .softwaremill .diffx .munit
2
2
3
- import com .softwaremill .diffx .{ConsoleColorConfig , Diff , DiffResultDifferent }
3
+ import com .softwaremill .diffx .{ConsoleColorConfig , Diff }
4
4
import munit .Assertions ._
5
5
import munit .Location
6
6
7
7
trait DiffxAssertions {
8
8
def assertEqual [T : Diff ](t1 : T , t2 : T )(implicit c : ConsoleColorConfig , loc : Location ): Unit = {
9
9
val result = Diff .compare(t1, t2)
10
- result match {
11
- case different : DiffResultDifferent => fail(different.show())(loc)
12
- case _ => // do nothing
10
+ if (! result.isIdentical) {
11
+ fail(result.show())(loc)
13
12
}
14
13
}
15
14
}
Original file line number Diff line number Diff line change 1
1
package com .softwaremill .diffx .scalatest
2
2
3
- import com .softwaremill .diffx .{ConsoleColorConfig , Diff , DiffResultDifferent }
3
+ import com .softwaremill .diffx .{ConsoleColorConfig , Diff }
4
4
import org .scalatest .matchers .{MatchResult , Matcher }
5
5
6
6
trait DiffMatcher {
7
7
def matchTo [A : Diff ](right : A )(implicit c : ConsoleColorConfig ): Matcher [A ] = { left =>
8
- Diff [A ].apply(left, right) match {
9
- case c : DiffResultDifferent =>
10
- val diff = c.show().split('\n ' ).mkString(Console .RESET , s " ${Console .RESET }\n ${Console .RESET }" , Console .RESET )
11
- MatchResult (matches = false , s " Matching error: \n $diff" , " " )
12
- case _ => MatchResult (matches = true , " " , " " )
8
+ val result = Diff [A ].apply(left, right)
9
+ if (! result.isIdentical) {
10
+ val diff = result.show().split('\n ' ).mkString(Console .RESET , s " ${Console .RESET }\n ${Console .RESET }" , Console .RESET )
11
+ MatchResult (matches = false , s " Matching error: \n $diff" , " " )
12
+ } else {
13
+ MatchResult (matches = true , " " , " " )
13
14
}
14
15
}
15
16
}
Original file line number Diff line number Diff line change 1
1
package com .softwaremill .diffx .specs2
2
2
3
- import com .softwaremill .diffx .{ConsoleColorConfig , Diff , DiffResultDifferent }
3
+ import com .softwaremill .diffx .{ConsoleColorConfig , Diff }
4
4
import org .specs2 .matcher .{Expectable , MatchResult , Matcher }
5
5
6
6
trait DiffMatcher {
@@ -14,11 +14,13 @@ trait DiffMatcher {
14
14
diff.apply(left.value, right).isIdentical
15
15
},
16
16
okMessage = " " ,
17
- koMessage = diff.apply(left.value, right) match {
18
- case c : DiffResultDifferent =>
19
- c.show()
20
- case _ =>
17
+ koMessage = {
18
+ val diffResult = diff.apply(left.value, right)
19
+ if (! diffResult.isIdentical) {
20
+ diffResult.show()
21
+ } else {
21
22
" "
23
+ }
22
24
},
23
25
left
24
26
)
Original file line number Diff line number Diff line change 1
1
package com .softwaremill .diffx .utest
2
2
3
- import com .softwaremill .diffx .{ConsoleColorConfig , Diff , DiffResultDifferent }
3
+ import com .softwaremill .diffx .{ConsoleColorConfig , Diff }
4
4
import utest .AssertionError
5
5
6
6
trait DiffxAssertions {
7
7
8
8
def assertEqual [T : Diff ](t1 : T , t2 : T )(implicit c : ConsoleColorConfig ): Unit = {
9
9
val result = Diff .compare(t1, t2)
10
- result match {
11
- case different : DiffResultDifferent => throw AssertionError (different.show(), Seq .empty, null )
12
- case _ => // do nothing
10
+ if (! result.isIdentical) {
11
+ throw AssertionError (result.show(), Seq .empty, null )
13
12
}
14
13
}
15
14
}
You can’t perform that action at this time.
0 commit comments