Skip to content

Commit

Permalink
fix one more testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
goshacodes committed Apr 12, 2024
1 parent 678a03a commit 64e227b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions shared/src/main/scala-3/org/scalamock/clazz/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private[clazz] class Utils(using val quotes: Quotes):
TypeRepr.of[Any]
case OrType(_, _: ParamRef | _: AppliedType) =>
TypeRepr.of[Any]
case AppliedType(tycon, params) =>
TypeRepr.of[Any]
case other =>
other
}
Expand Down
10 changes: 10 additions & 0 deletions shared/src/test/scala-3/com/paulbutcher/test/Scala3Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,35 @@ class Scala3Spec extends AnyFunSpec with MockFactory with Matchers {

trait C

trait D[T]

trait ComplexUnionIntersectionCases {

def complexMethod1[T](x: A[T] & T): A[T] & T
def complexMethod2[T](x: A[A[T]] | T): A[T] | T
def complexMethod3[F[_], T](x: F[A[T] & F[T]] | T & A[F[T]]): F[T] & T
def complexMethod4[T](x: A[B & C] ): A[B & C]
def complexMethod5[T](x: A[B | A[C]]): A[B | C]

def complexMethod6[T](x: A[T | A[C]]): A[T | C]

def complexMethod6[T](x: D[T | A[C]]): D[T | C]
}

val m = mock[ComplexUnionIntersectionCases]

val obj = new A[B] with B {}
val obj2 = new A[A[B]] with B {}
val obj3 = new D[String | A[C]] {}
val obj4 = new D[String | C] {}

(m.complexMethod1[B] _).expects(obj).returns(obj)
(m.complexMethod2[B] _).expects(obj2).returns(new A[B] {})
(m.complexMethod6[String](_: D[String | A[C]])).expects(obj3).returns(obj4)

m.complexMethod1[B](obj)
m.complexMethod2[B](obj2)
m.complexMethod6[String](obj3)
}

it("mock methods returning function") {
Expand Down

0 comments on commit 64e227b

Please sign in to comment.