Skip to content

Commit

Permalink
Test for wvlet#3454
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Mar 26, 2024
1 parent 451eaf2 commit b57d10b
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,23 @@ object GenericMethodTest extends AirSpec {
m.call(obj, "dummy") shouldBe "hello"
}

case class Gen[X](value: X) {
def pass(x: X): X = x
def myself: Gen[X] = this
def wrap(x: X): Gen[X] = Gen[X](value)
def unwrap(x: Gen[X]): X = x.value
}

test("Methods of generic type") {
val typeSurface = Surface.of[Gen[String]]
val methods = Surface.methodsOf[Gen[String]]
val pass = methods.find(_.name == "pass").get
pass.returnType shouldBe Surface.of[String]
val myself = methods.find(_.name == "myself").get
myself.returnType shouldBe typeSurface
val wrap = methods.find(_.name == "wrap").get
wrap.returnType shouldBe typeSurface
val unwrap = methods.find(_.name == "unwrap").get
unwrap.returnType shouldBe Surface.of[String]
}
}

0 comments on commit b57d10b

Please sign in to comment.