Skip to content

Commit 68fc0c4

Browse files
committed
Expand test
1 parent 890531d commit 68fc0c4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/run/memoTest.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,24 @@ object Test extends App {
1212

1313
assert(foo(1) + foo(2) == 4)
1414
assert(bar(1) + bar(2) == 4)
15+
16+
class Context(val n: Int)
17+
def f(c: Context): Context = {
18+
println("computing f")
19+
Context(c.n + 1)
20+
}
21+
given as Context(0)
22+
23+
locally {
24+
given as Context given (c: Context) = memo(f(c))
25+
println(the[Context].n)
26+
println(the[Context].n)
27+
}
28+
29+
val ctx = f(the[Context])
30+
locally {
31+
given as Context = ctx
32+
println(the[Context].n)
33+
println(the[Context].n)
34+
}
1535
}

0 commit comments

Comments
 (0)