diff options
Diffstat (limited to 'src/test/scala/scala/async/run/toughtype/ToughType.scala')
-rw-r--r-- | src/test/scala/scala/async/run/toughtype/ToughType.scala | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/test/scala/scala/async/run/toughtype/ToughType.scala b/src/test/scala/scala/async/run/toughtype/ToughType.scala index 5ff1605..9ae33b1 100644 --- a/src/test/scala/scala/async/run/toughtype/ToughType.scala +++ b/src/test/scala/scala/async/run/toughtype/ToughType.scala @@ -239,9 +239,82 @@ class ToughTypeSpec { val result = Await.result(f, 5.seconds) result mustEqual (new IntWrapper("foo")) } + + @Test def ticket86NestedValueClass() { + import ExecutionContext.Implicits.global + + val f = async { + val a = Future.successful(new IntWrapper("42")) + await(await(a).plusStr) + } + val result = Await.result(f, 5.seconds) + result mustEqual "42!" + } + + @Test def ticket86MatchedValueClass(): Unit = { + import ExecutionContext.Implicits.global + + def doAThing(param: IntWrapper) = Future(None) + + val fut = async { + Option(new IntWrapper("value!")) match { + case Some(valueHolder) => + await(doAThing(valueHolder)) + case None => + None + } + } + + val result = Await.result(fut, 5.seconds) + result mustBe None + } + + @Test def ticket86MatchedParameterizedValueClass(): Unit = { + import ExecutionContext.Implicits.global + + def doAThing(param: ParamWrapper[String]) = Future(None) + + val fut = async { + Option(new ParamWrapper("value!")) match { + case Some(valueHolder) => + await(doAThing(valueHolder)) + case None => + None + } + } + + val result = Await.result(fut, 5.seconds) + result mustBe None + } + + @Test def ticket86PrivateValueClass(): Unit = { + import ExecutionContext.Implicits.global + + def doAThing(param: PrivateWrapper) = Future(None) + + val fut = async { + Option(PrivateWrapper.Instance) match { + case Some(valueHolder) => + await(doAThing(valueHolder)) + case None => + None + } + } + + val result = Await.result(fut, 5.seconds) + result mustBe None + } } -class IntWrapper(val value: String) extends AnyVal +class IntWrapper(val value: String) extends AnyVal { + def plusStr = Future.successful(value + "!") +} +class ParamWrapper[T](val value: T) extends AnyVal + +class PrivateWrapper private (private val value: String) extends AnyVal +object PrivateWrapper { + def Instance = new PrivateWrapper("") +} trait A |