summaryrefslogtreecommitdiff
path: root/graphics/asymptote/tests/template/multiImport.asy
blob: 94d5c30feb51f3643b8036f64b8e84134faa1ff4 (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
import TestLib;

StartTest('multiple_imports');
struct A {int x=1;}
access "template/imports/C"(T=A) as p;
assert(p.global == 17);
p.global = 42;
access "template/imports/C"(T=A) as q;
assert(q.global == 42);
EndTest();

StartTest('import_in_function');
struct B {int x=1;}
void f(int expected, int newValue) {
  // Importing inside a function is not recommended practice, but it should
  // work.
  access "template/imports/C"(T=B) as p;
  assert(p.global == expected);
  p.global = newValue;
}
f(17, 23);
f(23, 27);
access "template/imports/C"(T=B) as p;
assert(p.global == 27);
EndTest();