aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2013-10-19 12:45:00 +0200
committerPhilipp Haller <hallerp@gmail.com>2013-10-22 14:41:37 +0200
commit62f22d41cfabc7d0d87c5afef64c1c9015e2cf5e (patch)
treeb26f16fddb9ffc1dd002baa36ba8292e2418dc16 /src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
parent480fffd487d53cfdb943a2287788af2bad409b88 (diff)
downloadscala-async-62f22d41cfabc7d0d87c5afef64c1c9015e2cf5e.tar.gz
scala-async-62f22d41cfabc7d0d87c5afef64c1c9015e2cf5e.tar.bz2
scala-async-62f22d41cfabc7d0d87c5afef64c1c9015e2cf5e.zip
Enables testing the resetting of lifted local variables
- Adds a hook that lets a derived macro insert additional code when zero-ing out a lifted field. - Adds a variant of the `AsyncId` macro that logs zeroed-out fields. - Adds a test using this mechanism
Diffstat (limited to 'src/test/scala/scala/async/run/live/LiveVariablesSpec.scala')
-rw-r--r--src/test/scala/scala/async/run/live/LiveVariablesSpec.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
new file mode 100644
index 0000000..2cecffa
--- /dev/null
+++ b/src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+
+package scala.async
+package run
+package live
+
+import org.junit.Test
+
+import internal.AsyncTestLV
+import AsyncTestLV._
+
+class LiveVariablesSpec {
+
+ @Test
+ def liveVars1() {
+ val f = async { 1 }
+
+ def m1(x: Int): Int =
+ async { x + 1 }
+
+ def m2(x: Int): String =
+ async { x.toString }
+
+ def m3() = async {
+ val a = await(f) // await$1$1
+ // a == 1
+ val b = await(m1(a)) // await$2$1
+ // b == 2
+ assert(AsyncTestLV.log.exists(_ == ("await$1$1" -> 0)))
+ val res = await(m2(b)) // await$3$1
+ assert(AsyncTestLV.log.exists(_ == ("await$2$1" -> 0)))
+ res
+ }
+
+ assert(m3() == "2")
+ }
+
+}