aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/run
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/scala/async/run')
-rw-r--r--src/test/scala/scala/async/run/anf/AnfTransformSpec.scala2
-rw-r--r--src/test/scala/scala/async/run/live/LiveVariablesSpec.scala22
-rw-r--r--src/test/scala/scala/async/run/toughtype/ToughType.scala38
3 files changed, 50 insertions, 12 deletions
diff --git a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
index 757ae0b..2cce7e8 100644
--- a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
+++ b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala
@@ -403,6 +403,6 @@ class AnfTransformSpec {
""".stripMargin
})
val applyImplicitView = tree.collect { case x if x.getClass.getName.endsWith("ApplyImplicitView") => x }
- applyImplicitView.map(_.toString) mustBe List("view(a$1)")
+ applyImplicitView.map(_.toString) mustStartWith List("view(a$macro$")
}
}
diff --git a/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
index 17d33af..30646a6 100644
--- a/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
+++ b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
@@ -36,9 +36,9 @@ class LiveVariablesSpec {
// a == Cell(1)
val b: Cell[Int] = await(m1(a)) // await$2$1
// b == Cell(2)
- assert(AsyncTestLV.log.exists(_ == ("await$1$1" -> Cell(1))), AsyncTestLV.log)
+ assert(AsyncTestLV.log.exists(_._2 == Cell(1)), AsyncTestLV.log)
val res = await(m2(b)) // await$3$1
- assert(AsyncTestLV.log.exists(_ == ("await$2$1" -> Cell(2))))
+ assert(AsyncTestLV.log.exists(_._2 == Cell(2)))
res
}
@@ -60,9 +60,9 @@ class LiveVariablesSpec {
// a == Cell(1)
val b: Any = await(m1(a)) // await$5$1
// b == Cell(2)
- assert(AsyncTestLV.log.exists(_ == ("await$4$1" -> Cell(1))))
+ assert(AsyncTestLV.log.exists(_._2 == Cell(1)))
val res = await(m2(b)) // await$6$1
- assert(AsyncTestLV.log.exists(_ == ("await$5$1" -> Cell(2))))
+ assert(AsyncTestLV.log.exists(_._2 == Cell(2)))
res
}
@@ -84,9 +84,9 @@ class LiveVariablesSpec {
// a == 1
val b: Any = await(m1(a)) // await$8$1
// b == Cell(2)
- assert(!AsyncTestLV.log.exists(p => p._1 == "await$7$1"))
+ // assert(!AsyncTestLV.log.exists(p => p._1 == "await$7$1"))
val res = await(m2(b)) // await$9$1
- assert(AsyncTestLV.log.exists(_ == ("await$8$1" -> Cell(2))))
+ assert(AsyncTestLV.log.exists(_._2 == Cell(2)))
res
}
@@ -108,9 +108,9 @@ class LiveVariablesSpec {
// a == Cell(1)
val b: Meter = await(m1(a)) // await$11$1
// b == Meter(2)
- assert(AsyncTestLV.log.exists(_ == ("await$10$1" -> Cell(1))))
+ assert(AsyncTestLV.log.exists(_._2 == Cell(1)))
val res = await(m2(b.len)) // await$12$1
- assert(AsyncTestLV.log.exists(entry => entry._1 == "await$11$1" && entry._2.asInstanceOf[Meter].len == 2L))
+ assert(AsyncTestLV.log.exists(_._2.asInstanceOf[Meter].len == 2L))
res
}
@@ -138,12 +138,12 @@ class LiveVariablesSpec {
}
// state #3
- assert(AsyncTestLV.log.exists(entry => entry._1 == "await$14$1"))
+ // assert(AsyncTestLV.log.exists(entry => entry._1 == "await$14$1"))
val b = await(m1(a, y.v)) // await$15$1
// state #8
- assert(AsyncTestLV.log.exists(_ == ("a$1" -> MCell(10))), AsyncTestLV.log)
- assert(AsyncTestLV.log.exists(_ == ("y$1" -> MCell(11))))
+ assert(AsyncTestLV.log.exists(_._2 == MCell(10)), AsyncTestLV.log)
+ assert(AsyncTestLV.log.exists(_._2 == MCell(11)))
b
}
diff --git a/src/test/scala/scala/async/run/toughtype/ToughType.scala b/src/test/scala/scala/async/run/toughtype/ToughType.scala
index 0f56ae0..c4d6c80 100644
--- a/src/test/scala/scala/async/run/toughtype/ToughType.scala
+++ b/src/test/scala/scala/async/run/toughtype/ToughType.scala
@@ -286,6 +286,39 @@ class ToughTypeSpec {
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
+ }
+
+ @Test def awaitOfAbstractType(): Unit = {
+ import ExecutionContext.Implicits.global
+
+ def combine[A](a1: A, a2: A): A = a1
+
+ def combineAsync[A](a1: Future[A], a2: Future[A]) = async {
+ combine(await(a1), await(a2))
+ }
+
+ val fut = combineAsync(Future(1), Future(2))
+
+ val result = Await.result(fut, 5.seconds)
+ result mustEqual 1
+ }
}
class IntWrapper(val value: String) extends AnyVal {
@@ -293,6 +326,11 @@ class IntWrapper(val value: String) extends AnyVal {
}
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