blob: c59a43348c708a6a5aa2815ae119cca0cbd7c3f3 (
plain)
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
|
Testing closure scopes.
1. Ensure that the declaring scope is retained in functions.
-- Expect stdout --
Make function with x=1
Make function with x=2
Make function with x=3
x is 1
x is 2
x is 3
-- End --
-- Testcase --
{%
let count=0;
function a() {
let x = ++count;
print("Make function with x=", x, "\n");
return function() {
print("x is ", x, "\n");
};
}
let fn1 = a();
let fn2 = a();
let fn3 = a();
fn1();
fn2();
fn3();
%}
-- End --
|