Skip to content

Commit

Permalink
Add fromProductTyped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist committed Jan 27, 2022
1 parent 6855857 commit 8248da2
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
@@ -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
@@ -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 8248da2

Please sign in to comment.