From 1cdfa2b0bde6bfa730448b370519c424aab16a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0pan=C4=9Bl?= Date: Wed, 4 Dec 2024 17:54:44 +0100 Subject: [PATCH] Check value in modification tests --- .../quicklens/test/ExplicitCopyTest.scala | 12 ++++++++---- .../quicklens/test/ExtensionCopyTest.scala | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExplicitCopyTest.scala b/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExplicitCopyTest.scala index 5651991..bc8f338 100644 --- a/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExplicitCopyTest.scala +++ b/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExplicitCopyTest.scala @@ -34,7 +34,8 @@ class ExplicitCopyTest extends AnyFlatSpec with Matchers { def paths(paths: Paths): Docs = copy(paths = paths) } val docs = Docs() - docs.modify(_.paths.pathItems).using(m => m + ("a" -> PathItem())) + val r = docs.modify(_.paths.pathItems).using(m => m + ("a" -> PathItem())) + r.paths.pathItems should contain ("a" -> PathItem()) } it should "modify a case class with an additional explicit copy" in { @@ -43,7 +44,8 @@ class ExplicitCopyTest extends AnyFlatSpec with Matchers { } val f = Frozen("A", 0) - f.modify(_.state).setTo("B") + val r = f.modify(_.state).setTo("B") + r.state shouldEqual "B" } it should "modify a case class with an ambiguous additional explicit copy" in { @@ -52,7 +54,8 @@ class ExplicitCopyTest extends AnyFlatSpec with Matchers { } val f = Frozen("A", 0) - f.modify(_.state).setTo("B") + val r = f.modify(_.state).setTo("B") + r.state shouldEqual "B" } it should "modify a class with two explicit copy methods" in { @@ -62,7 +65,8 @@ class ExplicitCopyTest extends AnyFlatSpec with Matchers { } val f = new Frozen("A", 0) - f.modify(_.state).setTo("B") + val r = f.modify(_.state).setTo("B") + r.state shouldEqual "B" } it should "modify a case class with an ambiguous additional explicit copy and pick the synthetic one first" in { diff --git a/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExtensionCopyTest.scala b/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExtensionCopyTest.scala index f24effa..0fbb832 100644 --- a/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExtensionCopyTest.scala +++ b/quicklens/src/test/scala-3/com/softwaremill/quicklens/test/ExtensionCopyTest.scala @@ -56,7 +56,7 @@ class ExtensionCopyTest extends AnyFlatSpec with Matchers { val a = VecCompanion(1, 2) val b = a.modify(_.x).using(_ + 10) - assert(b.x == 11) + b.x shouldEqual 11 } it should "modify a class with extension methods in companion" in { @@ -76,7 +76,7 @@ class ExtensionCopyTest extends AnyFlatSpec with Matchers { val a = VecClass(1, 2) val b = a.modify(_.x).using(_ + 10) - assert(b.x == 11) + b.x shouldEqual 11 } it should "modify an opaque type with extension methods" in { @@ -84,6 +84,6 @@ class ExtensionCopyTest extends AnyFlatSpec with Matchers { val a = Vec(1, 2) val b = a.modify(_.x).using(_ + 10) - assert(b.x == 11) + b.x shouldEqual 11 } }