Skip to content

Commit

Permalink
Add fromProductTyped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist committed Dec 16, 2021
1 parent 26319cf commit 5d8a855
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/neg/deriving-from-product-typed.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import deriving.Mirror

case class A(x: Int, y: String)
case class B(a: Any, b: Any)
object A:
def f = summon[Mirror.ProductOf[A]].fromProductTyped((1, 2)) // error
def g = summon[Mirror.ProductOf[A]].fromTuple((1, 2)) // error
def h = summon[Mirror.ProductOf[B]].fromProductTyped(A(1, ""))
def i = summon[Mirror.ProductOf[A]].fromProductTyped(B(1, "")) // error

11 changes: 11 additions & 0 deletions tests/run/deriving-from-product-typed.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
case class A(x: Option[Int], y: Option[Any])
case class B(x: Some[Int], y: Some[Boolean])

object Test extends App:
import deriving.*

val ma = summon[Mirror.ProductOf[A]]

ma.fromProductTyped(B(Some(1), Some(true)))
ma.fromProductTyped((Some(1), Some(false)))

0 comments on commit 5d8a855

Please sign in to comment.