summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/imp/unravel.asy
blob: 0f61326fd6622bae43cce5a48493e9013d2f0bcf (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import TestLib;
StartTest("unravel");
{
  struct A {
    int x=1, y=2, z=3;
    int y() { return 7; }
  }

  A a=new A;
  unravel a;
  assert(x==1);
  assert(y==2);
  assert(z==3);
  assert(y()==7);
}
{
  struct A {
    private int x=1;
    int y=2, z=3;
    int y() { return 7; }
  } 

  int x=5;
  A a=new A;
  unravel a;
  assert(x==5);
  assert(y==2);
  assert(z==3);
}
{
  struct A {
    public int x=1;
    int y=2, z=3;
    int y() { return 7; }
  }

  int z=5;
  A a=new A;
  from a unravel x,y;
  assert(x==1);
  assert(y==2);
  assert(z==5);
  assert(y()==7);
}
{
  struct A {
    public int x=1;
    int y=2, z=3;
    int y() { return 7; }
  }

  int y=4;
  int z=5;
  A a=new A;
  from a unravel x,y as blah;
  assert(x==1);
  assert(y==4);
  assert(blah==2);
  assert(z==5);
  assert(blah()==7);
}
{
  struct A {
    struct B {
      static int x=4;
    }
  }
  A a=new A;
  int x=3;
  from a.B unravel x;
  assert(x==4);
}
{
  struct A {
    struct B {
      static int x=4;
    }
  }
  A a=new A;
  A.B b=new a.B;
  int x=3;
  from b unravel x;
  assert(x==4);
}
{
  struct A {
    static struct B {
      static int x=4;
    }
  }
  int x=3;
  from A.B unravel x;
  assert(x==4);
}
EndTest();