Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 18fbf56

Browse files
Added test case to factory
1 parent f50f477 commit 18fbf56

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

modules/pulp/src/test/scala/io/scalaland/pulp/FactorySpec.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class FactorySpec extends Specification {
2121
@Factory class ComplexCase[T](t: T, name: String, size: Int)
2222
@Factory class ComplexCase2[T](t: T)(name: String)(size: Int)
2323

24+
trait TestTC[T]
25+
@Factory class TCCase1[T: TestTC](implicit i: Int)
26+
@Factory class TCCase2[T: TestTC]
27+
@Factory class TCCase3[T: TestTC](d: Double)(implicit i: Int)
28+
2429
"@Factory annotation" should {
2530

2631
"generate implicit Provider def for a monomorphic class without a companion" in {
@@ -55,5 +60,15 @@ class FactorySpec extends Specification {
5560

5661
Provider.get[ComplexCase2[Double]] must not(beNull)
5762
}
63+
64+
"generate implicit Provider def for a class with type class constraint" in {
65+
implicit val stringTCProvider: Provider[TestTC[String]] = Provider.const(new TestTC[String] {})
66+
implicit val doubleProvider: Provider[Double] = Provider.const(1.0)
67+
implicit val intProvider: Provider[Int] = Provider.const(10)
68+
69+
Provider.get[TCCase1[String]] must not(beNull)
70+
Provider.get[TCCase2[String]] must not(beNull)
71+
Provider.get[TCCase3[String]] must not(beNull)
72+
}
5873
}
5974
}

0 commit comments

Comments
 (0)