Skip to content

Commit a16bbf7

Browse files
committed
internal/core/adt: add tests for Issue 3825
These tests address part of the issue mentioned in Issue 3825. Issue #3825 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I037719ca74f980f567e0d4a21925bb00f5c90d66 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1212021 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 85fb117 commit a16bbf7

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
// Ensure that references are resolved on the boundaries of disjunctions.
2+
-- in.cue --
3+
resolveAcrossDisjunct: t1: {
4+
{} | { #B: 1} // d resolves to 1 in the second case.
5+
{d: #B} | {}
6+
#B: int
7+
}
8+
resolveAcrossDisjunct: nested: {
9+
{} | { a: b: #B: 1} // d resolves to 1 in the second case.
10+
{d: a.b.#B} | {}
11+
a: b: #B: int
12+
}
13+
-- out/evalalpha/stats --
14+
Leaks: 48
15+
Freed: 0
16+
Reused: 0
17+
Allocs: 48
18+
Retain: 0
19+
20+
Unifications: 12
21+
Conjuncts: 33
22+
Disjuncts: 12
23+
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
24+
diff old new
25+
--- old
26+
+++ new
27+
@@ -1,9 +1,9 @@
28+
-Leaks: 0
29+
-Freed: 44
30+
-Reused: 32
31+
-Allocs: 12
32+
+Leaks: 48
33+
+Freed: 0
34+
+Reused: 0
35+
+Allocs: 48
36+
Retain: 0
37+
38+
-Unifications: 32
39+
-Conjuncts: 67
40+
-Disjuncts: 44
41+
+Unifications: 12
42+
+Conjuncts: 33
43+
+Disjuncts: 12
44+
-- out/eval/stats --
45+
Leaks: 0
46+
Freed: 44
47+
Reused: 32
48+
Allocs: 12
49+
Retain: 0
50+
51+
Unifications: 32
52+
Conjuncts: 67
53+
Disjuncts: 44
54+
-- out/evalalpha --
55+
(struct){
56+
resolveAcrossDisjunct: (struct){
57+
t1: (struct){ |((struct){
58+
#B: (int){ int }
59+
d: (int){ int }
60+
}, (struct){
61+
#B: (int){ int }
62+
}, (struct){
63+
#B: (int){ 1 }
64+
d: (int){ int }
65+
}, (struct){
66+
#B: (int){ 1 }
67+
}) }
68+
nested: (struct){ |((struct){
69+
a: (struct){
70+
b: (struct){
71+
#B: (int){ int }
72+
}
73+
}
74+
d: (int){ int }
75+
}, (struct){
76+
a: (struct){
77+
b: (struct){
78+
#B: (int){ int }
79+
}
80+
}
81+
}, (struct){
82+
a: (struct){
83+
b: (struct){
84+
#B: (int){ 1 }
85+
}
86+
}
87+
d: (int){ int }
88+
}, (struct){
89+
a: (struct){
90+
b: (struct){
91+
#B: (int){ 1 }
92+
}
93+
}
94+
}) }
95+
}
96+
}
97+
-- diff/-out/evalalpha<==>+out/eval --
98+
diff old new
99+
--- old
100+
+++ new
101+
@@ -7,7 +7,7 @@
102+
#B: (int){ int }
103+
}, (struct){
104+
#B: (int){ 1 }
105+
- d: (int){ 1 }
106+
+ d: (int){ int }
107+
}, (struct){
108+
#B: (int){ 1 }
109+
}) }
110+
@@ -30,7 +30,7 @@
111+
#B: (int){ 1 }
112+
}
113+
}
114+
- d: (int){ 1 }
115+
+ d: (int){ int }
116+
}, (struct){
117+
a: (struct){
118+
b: (struct){
119+
-- out/eval --
120+
(struct){
121+
resolveAcrossDisjunct: (struct){
122+
t1: (struct){ |((struct){
123+
#B: (int){ int }
124+
d: (int){ int }
125+
}, (struct){
126+
#B: (int){ int }
127+
}, (struct){
128+
#B: (int){ 1 }
129+
d: (int){ 1 }
130+
}, (struct){
131+
#B: (int){ 1 }
132+
}) }
133+
nested: (struct){ |((struct){
134+
a: (struct){
135+
b: (struct){
136+
#B: (int){ int }
137+
}
138+
}
139+
d: (int){ int }
140+
}, (struct){
141+
a: (struct){
142+
b: (struct){
143+
#B: (int){ int }
144+
}
145+
}
146+
}, (struct){
147+
a: (struct){
148+
b: (struct){
149+
#B: (int){ 1 }
150+
}
151+
}
152+
d: (int){ 1 }
153+
}, (struct){
154+
a: (struct){
155+
b: (struct){
156+
#B: (int){ 1 }
157+
}
158+
}
159+
}) }
160+
}
161+
}
162+
-- out/compile --
163+
--- in.cue
164+
{
165+
resolveAcrossDisjunct: {
166+
t1: {
167+
({}|{
168+
#B: 1
169+
})
170+
({
171+
d: 〈1;#B〉
172+
}|{})
173+
#B: int
174+
}
175+
}
176+
resolveAcrossDisjunct: {
177+
nested: {
178+
({}|{
179+
a: {
180+
b: {
181+
#B: 1
182+
}
183+
}
184+
})
185+
({
186+
d: 〈1;a〉.b.#B
187+
}|{})
188+
a: {
189+
b: {
190+
#B: int
191+
}
192+
}
193+
}
194+
}
195+
}

0 commit comments

Comments
 (0)