blob: ee0a78e1fc8a858b0e89cb2292b9f8cc07a36cbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package scala.async
package run
package nesteddef
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.Test
@RunWith(classOf[JUnit4])
class NestedDef {
@Test
def nestedDef() {
import AsyncId._
val result = async {
val a = 0
val x = await(a) - 1
val local = 43
def bar(d: Double) = -d + a + local
def foo(z: Any) = (a.toDouble, bar(x).toDouble, z)
foo(await(2))
}
result mustBe ((0d, 44d, 2))
}
@Test
def nestedFunction() {
import AsyncId._
val result = async {
val a = 0
val x = await(a) - 1
val local = 43
val bar = (d: Double) => -d + a + local
val foo = (z: Any) => (a.toDouble, bar(x).toDouble, z)
foo(await(2))
}
result mustBe ((0d, 44d, 2))
}
}
|