blob: 701d5d6cafbb35232fe814d3fc540449852fe720 (
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
|
/*
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.async
package run
package lazyval
import org.junit.Test
import scala.async.internal.AsyncId._
class LazyValSpec {
@Test
def lazyValAllowed() {
val result = async {
var x = 0
lazy val y = { x += 1; 42 }
assert(x == 0, x)
val z = await(1)
val result = y + x
assert(x == 1, x)
identity(y)
assert(x == 1, x)
result
}
result mustBe 43
}
}
|