Skip to content

Commit

Permalink
Check value in modification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Dec 4, 2024
1 parent d013799 commit 1cdfa2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -76,14 +76,14 @@ 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 {
import ExtensionCopyTest.*

val a = Vec(1, 2)
val b = a.modify(_.x).using(_ + 10)
assert(b.x == 11)
b.x shouldEqual 11
}
}

0 comments on commit 1cdfa2b

Please sign in to comment.