diff --git a/modules/core/shared/src/main/scala/weaver/internals/ExpectSame.scala b/modules/core/shared/src/main/scala/weaver/internals/ExpectSame.scala index f246010a..82dccb07 100644 --- a/modules/core/shared/src/main/scala/weaver/internals/ExpectSame.scala +++ b/modules/core/shared/src/main/scala/weaver/internals/ExpectSame.scala @@ -29,7 +29,8 @@ private[weaver] trait ExpectSame { def same[A]( expected: A, found: A)( - implicit loc: SourceLocation): Expectations = eql(expected, found)( - Comparison.fromEq(Eq.fromUniversalEquals, Show.fromToString), - loc) + implicit comparisonA: Comparison[A] = + Comparison.fromEq[A](Eq.fromUniversalEquals, Show.fromToString), + loc: SourceLocation): Expectations = + eql(expected, found)(comparisonA, loc) } diff --git a/modules/framework-cats/shared/src/test/scala/DogFoodTests.scala b/modules/framework-cats/shared/src/test/scala/DogFoodTests.scala index b500a23c..0e7cda57 100644 --- a/modules/framework-cats/shared/src/test/scala/DogFoodTests.scala +++ b/modules/framework-cats/shared/src/test/scala/DogFoodTests.scala @@ -260,11 +260,36 @@ object DogFoodTests extends IOSuite { case (logs, _) => val actual = extractLogEventAfterFailures(logs) { - case LoggedEvent.Error(msg) if msg.contains("(Comparison)") => msg + case LoggedEvent.Error(msg) if msg.contains("(eql Comparison)") => + msg }.get val expected = """ - |- (Comparison) 0ms + |- (eql Comparison) 0ms + | Values not equal: (src/main/DogFoodTests.scala:5) + | + | Foo { | Foo { + | s: foo | s: foo + | i: [1] | i: [2] + | } | } + """.stripMargin.trim + + expect.same(actual, expected) + } + } + + test( + "expect.same delegates to Comparison show when an instance is found") { + _.runSuite(Meta.Rendering).map { + case (logs, _) => + val actual = + extractLogEventAfterFailures(logs) { + case LoggedEvent.Error(msg) if msg.contains("(same Comparison)") => + msg + }.get + + val expected = """ + |- (same Comparison) 0ms | Values not equal: (src/main/DogFoodTests.scala:5) | | Foo { | Foo { diff --git a/modules/framework-cats/shared/src/test/scala/Meta.scala b/modules/framework-cats/shared/src/test/scala/Meta.scala index f5ea1d2f..6d6b5e33 100644 --- a/modules/framework-cats/shared/src/test/scala/Meta.scala +++ b/modules/framework-cats/shared/src/test/scala/Meta.scala @@ -40,25 +40,28 @@ object Meta { cancel("I was cancelled :(") } - pureTest("(Comparison)") { - import cats.Show - case class Foo(s: String, i: Int) - object Foo { - val show: Show[Foo] = Show.show[Foo] { - case Foo(s, i) => - s""" + import cats.Show + case class Foo(s: String, i: Int) + object Foo { + val show: Show[Foo] = Show.show[Foo] { + case Foo(s, i) => + s""" |Foo { | s: ${Show[String].show(s)} | i: ${Show[Int].show(i)} |} """.stripMargin.trim() - } - implicit val comparison: Comparison[Foo] = - Comparison.fromEq[Foo](cats.Eq.fromUniversalEquals, show) } + implicit val comparison: Comparison[Foo] = + Comparison.fromEq[Foo](cats.Eq.fromUniversalEquals, show) + } + pureTest("(eql Comparison)") { expect.eql(Foo("foo", 1), Foo("foo", 2)) } + pureTest("(same Comparison)") { + expect.same(Foo("foo", 1), Foo("foo", 2)) + } } object FailingTestStatusReporting extends SimpleIOSuite {