Skip to content

Commit

Permalink
Diff: swap the order of expected-vs-obtained
Browse files Browse the repository at this point in the history
It was mapping obtained to original, and expected to revised.
  • Loading branch information
kitbellew committed Jan 18, 2025
1 parent 17e0616 commit d6f444f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions munit-diff/shared/src/main/scala/munit/diff/Diff.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Diff(val obtained: String, val expected: String) extends Serializable {
val expectedClean: String = AnsiColors.filterAnsi(expected)
val obtainedLines: Seq[String] = splitIntoLines(obtainedClean)
val expectedLines: Seq[String] = splitIntoLines(expectedClean)
val unifiedDiff: String = createUnifiedDiff(obtainedLines, expectedLines)
val unifiedDiff: String = createUnifiedDiff(expectedLines, obtainedLines)
def isEmpty: Boolean = unifiedDiff.isEmpty()

def createReport(
Expand Down Expand Up @@ -46,7 +46,7 @@ class Diff(val obtained: String, val expected: String) extends Serializable {
val red = AnsiColors.use(AnsiColors.LightRed)
val reset = AnsiColors.use(AnsiColors.Reset)
val green = AnsiColors.use(AnsiColors.LightGreen)
sb.append(s" (${red}- obtained${reset}, ${green}+ expected${reset})")
sb.append(s" (${red}- expected${reset}, ${green}+ obtained${reset})")
sb.append("\n")
sb.append(unifiedDiff)
}
Expand Down Expand Up @@ -80,8 +80,8 @@ class Diff(val obtained: String, val expected: String) extends Serializable {
else {
DiffUtils
.generateUnifiedDiff(
"obtained",
"expected",
"obtained",
original.asJava,
diff,
1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ object AssertionsFrameworkSuite
|values are not the same
|=> Obtained
|a.A()
|=> Diff (- obtained, + expected)
|-a.A()
|+b.B()
|=> Diff (- expected, + obtained)
|-b.B()
|+a.A()
|==> failure munit.AssertionsFrameworkSuite.toString-has-different-whitespace - tests/shared/src/main/scala/munit/AssertionsFrameworkSuite.scala:39 values are not equal, even if their text representation only differs in leading/trailing whitespace and ANSI escape characters: foo
|38: test("toString-has-different-whitespace") {
|39: assertEquals[Any, Any]("foo", "foo ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ object DiffProductFrameworkSuite
| 2
| )
|)
|=> Diff (- obtained, + expected)
|=> Diff (- expected, + obtained)
| name = "John",
|- age = 43,
|+ age = 42,
|- age = 42,
|+ age = 43,
| friends = List(
|+ 1,
|- 1,
| 2
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ object Issue179FrameworkSuite
|=> Obtained
| '''|
| |'''.stripMargin
|=> Diff (- obtained, + expected)
|-
|+A
|=> Diff (- expected, + obtained)
|-A
|+
|""".stripMargin
)
12 changes: 6 additions & 6 deletions tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ object FullStackTraceFrameworkSuite
|diff assertion failed
|=> Obtained
|"a"
|=> Diff (- obtained, + expected)
|-a
|+b
|=> Diff (- expected, + obtained)
|-b
|+a
|""".stripMargin
)

Expand All @@ -57,8 +57,8 @@ object SmallStackTraceFrameworkSuite
|diff assertion failed
|=> Obtained
|"a"
|=> Diff (- obtained, + expected)
|-a
|+b
|=> Diff (- expected, + obtained)
|-b
|+a
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ object TestTransformFrameworkSuite
|values are not the same
|=> Obtained
|0
|=> Diff (- obtained, + expected)
|-0
|+1
|=> Diff (- expected, + obtained)
|-1
|+0
|==> extra info
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class ComparisonFailExceptionSuite extends BaseSuite {
| "2",
| "3"
|)
|=> Diff (- obtained, + expected)
|=> Diff (- expected, + obtained)
| List(
|- "1",
|- "2",
|- "3"
|+ 1,
|+ 2
|- 1,
|- 2
|+ "1",
|+ "2",
|+ "3"
| )
|""".stripMargin
)
Expand Down
10 changes: 5 additions & 5 deletions tests/shared/src/test/scala/munit/DiffsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class DiffsSuite extends FunSuite { self =>
// intuitive results.
assertNoDiff(
obtained,
"""|-a
|-+b
|++c
"""|--c
|+-b
| +a
|""".stripMargin
)
}
Expand All @@ -32,8 +32,8 @@ class DiffsSuite extends FunSuite { self =>
"trailing-whitespace",
"a\nb",
"a \nb",
"""|-a
|+a
"""|-a
|+a
| b
|""".stripMargin
)
Expand Down

0 comments on commit d6f444f

Please sign in to comment.