summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/frames/loop.asy
blob: ceb65a1ff56162b9de0a6b13c79d312f1c75ab05 (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
import TestLib;
StartTest("loop");

int f();
for (int i=0; i<10; ++i) { 
  int x=i;
  for (int j=0; j<10; ++j) {
    int y=j;
    if (i==5 && j==7) {
      f = new int () { return x*y; };
    }
  }
}
assert(f()==35);

int f();

for (int i=0; i<10; ++i) { 
  int x=i;
  for (int j=0; j<10; ++j) {
    int y=j;
    if (i==5 && j==7) {
      f = new int () { return i*y; };
    }
  }
}
assert(f()==70);

EndTest();