summaryrefslogtreecommitdiff
blob: 87c143cd65996917cbfa40d0e6ef248e9ccadf13 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(fate_version 1)

(global string test_name)

(set! test_name ( FIELD ACCESS ))

(declare_structure #test_struct_type0
   (int i)
   (int j)
   (int k)
   ((list int) li)
)

(declare_structure #test_struct_type1
   (int i)
   (#test_struct_type0 ts0)
   ((list #test_struct_type0) lts)
)

(declare_structure #test_struct_type2
   (int i)
   (#test_struct_type0 ts0)
   (#test_struct_type1 ts1)
)

(global #test_struct_type0 ts0_0)
(global #test_struct_type0 ts0_1)
(global #test_struct_type1 ts1_0)
(global #test_struct_type1 ts1_1)
(global #test_struct_type2 ts2_0)


(struct:set_fields! ts0_0
   (i 42)
   (j 69)
   (k 420)
   (li (list:range 0 10 1))
)

(struct:set_fields! ts0_1
   (i 42)
   (j 69)
   (k 420)
   (k 42)
   (j 69)
   (i 420)
   (li (list:range 11 20 1))
)

(struct:set_fields! ts1_0
   (i 1337)
   (ts0 (var ts0_0))
   (lts
      (list:add
         (var ts0_1)
         (list:add (var ts0_0) (default (list #test_struct_type0)))
      )
   )
)

(struct:set_fields! ts1_1
   (i 1337)
   (ts0 (var ts0_1))
   (lts
      (list:add
         (var ts0_0)
         (list:add (var ts0_1) (default (list #test_struct_type0)))
      )
   )
)

(set! ts2_0
   (struct:set_fields (default #test_struct_type2)
      (i -1337)
      (ts0 (var ts0_0))
      (ts1 (var ts1_1))
   )
)

(assert!
   (=
      (struct:get_field i ts0_0)
      (var ts0_0.i)
      (struct:get_field k ts0_1)
      (var ts0_1.k)
      42
   )
   [FAILED] (var test_name) Test 0.
   (newline)
   ts0_0.i = (var ts0_0.i)
   (newline)
   ts0_1.k = (var ts0_1.k)
)

(assert!
   (=
      (struct:get_field i ts0_1)
      (var ts0_1.i)
      (struct:get_field k ts0_0)
      (var ts0_0.k)
      420
   )
   [FAILED] (var test_name) Test 1.
   (newline)
   ts0_0.k = (var ts0_0.k)
   (newline)
   ts0_1.i = (var ts0_1.i)
)

(assert!
   (=
      (struct:field i ts0_1)
      (struct:get_field i (struct:set_fields ts1_0 (i 420)))
      (struct:get_field i (struct:field ts0 (struct:field ts1 ts2_0)))
      420
   )
   [FAILED] (var test_name) Test 2.
)

[COMPLETED] (var test_name)

(end!)