Skip to content

Commit 996e8b0

Browse files
committed
internal/core/adt: add tests for Issue 3977
Issue #3977 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I05a073cf6cf70f9831749e404f811cb288e449a0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1217225 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent d567750 commit 996e8b0

File tree

1 file changed

+347
-0
lines changed

1 file changed

+347
-0
lines changed

cue/testdata/eval/nonrooted.txtar

Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
-- in.cue --
2+
issue3977: inlineExpr: {
3+
#NetworkID: 1
4+
#fn: {
5+
x: #NetworkID
6+
out: x + 1
7+
}
8+
9+
err: (#fn & {x: 2}).out
10+
}
11+
issue3977: inlineDisj1: {
12+
#NetworkID: "2" | "3" | "4"
13+
#fn: {
14+
x: #NetworkID
15+
out: "value=\(x)"
16+
}
17+
18+
err: (#fn & {x: "invalid"}).out
19+
}
20+
issue3977: inlineDisj2: {
21+
#NetworkID: 1
22+
#fn: {
23+
x: #NetworkID
24+
out: x + 10
25+
}
26+
27+
err: (#fn & {x: *2 | 4}).out
28+
}
29+
issue3977: inlineDisj3: {
30+
#NetworkID: 1
31+
#fn: {
32+
x: #NetworkID
33+
out: x + 10
34+
}
35+
36+
err: (#fn & {x: *2 | int}).out
37+
}
38+
issue3977: inlineLet: {
39+
#NetworkID: 1
40+
let p = {
41+
x: #NetworkID
42+
out: x + 10
43+
} & {
44+
x: 2
45+
}
46+
47+
err: p.out
48+
}
49+
-- out/eval/stats --
50+
Leaks: 9
51+
Freed: 48
52+
Reused: 43
53+
Allocs: 14
54+
Retain: 27
55+
56+
Unifications: 47
57+
Conjuncts: 87
58+
Disjuncts: 68
59+
-- out/evalalpha --
60+
Errors:
61+
x: conflicting values 2 and 1:
62+
./in.cue:20:14
63+
./in.cue:26:19
64+
x: conflicting values 4 and 1:
65+
./in.cue:20:14
66+
./in.cue:26:23
67+
x: 2 errors in empty disjunction::
68+
./in.cue:23:8
69+
70+
Result:
71+
(_|_){
72+
// [eval]
73+
issue3977: (_|_){
74+
// [eval]
75+
inlineExpr: (struct){
76+
#NetworkID: (int){ 1 }
77+
#fn: (#struct){
78+
x: (int){ 1 }
79+
out: (int){ 2 }
80+
}
81+
err: (int){ 3 }
82+
}
83+
inlineDisj1: (struct){
84+
#NetworkID: (string){ |((string){ "2" }, (string){ "3" }, (string){ "4" }) }
85+
#fn: (#struct){
86+
x: (string){ |((string){ "2" }, (string){ "3" }, (string){ "4" }) }
87+
out: (_|_){
88+
// [incomplete] issue3977.inlineDisj1.#fn.out: invalid interpolation: unresolved disjunction "2" | "3" | "4" (type string):
89+
// ./in.cue:14:8
90+
}
91+
}
92+
err: (string){ "value=invalid" }
93+
}
94+
inlineDisj2: (_|_){
95+
// [eval]
96+
#NetworkID: (int){ 1 }
97+
#fn: (#struct){
98+
x: (int){ 1 }
99+
out: (int){ 11 }
100+
}
101+
err: (_|_){
102+
// [eval] x: conflicting values 2 and 1:
103+
// ./in.cue:20:14
104+
// ./in.cue:26:19
105+
// x: conflicting values 4 and 1:
106+
// ./in.cue:20:14
107+
// ./in.cue:26:23
108+
// x: 2 errors in empty disjunction::
109+
// ./in.cue:23:8
110+
}
111+
}
112+
inlineDisj3: (struct){
113+
#NetworkID: (int){ 1 }
114+
#fn: (#struct){
115+
x: (int){ 1 }
116+
out: (int){ 11 }
117+
}
118+
err: (int){ 11 }
119+
}
120+
inlineLet: (struct){
121+
#NetworkID: (int){ 1 }
122+
let p#1 = (_|_){
123+
// [eval]
124+
x: (_|_){
125+
// [eval] issue3977.inlineLet.p.x: conflicting values 1 and 2:
126+
// ./in.cue:38:14
127+
// ./in.cue:43:6
128+
}
129+
out: (_|_){
130+
// [eval] issue3977.inlineLet.p.x: conflicting values 1 and 2:
131+
// ./in.cue:38:14
132+
// ./in.cue:43:6
133+
}
134+
}
135+
err: (int){ 12 }
136+
}
137+
}
138+
}
139+
-- diff/-out/evalalpha<==>+out/eval --
140+
diff old new
141+
--- old
142+
+++ new
143+
@@ -1,13 +1,9 @@
144+
Errors:
145+
x: conflicting values 2 and 1:
146+
./in.cue:20:14
147+
- ./in.cue:22:8
148+
- ./in.cue:26:8
149+
./in.cue:26:19
150+
x: conflicting values 4 and 1:
151+
./in.cue:20:14
152+
- ./in.cue:22:8
153+
- ./in.cue:26:8
154+
./in.cue:26:23
155+
x: 2 errors in empty disjunction::
156+
./in.cue:23:8
157+
@@ -46,13 +42,9 @@
158+
err: (_|_){
159+
// [eval] x: conflicting values 2 and 1:
160+
// ./in.cue:20:14
161+
- // ./in.cue:22:8
162+
- // ./in.cue:26:8
163+
// ./in.cue:26:19
164+
// x: conflicting values 4 and 1:
165+
// ./in.cue:20:14
166+
- // ./in.cue:22:8
167+
- // ./in.cue:26:8
168+
// ./in.cue:26:23
169+
// x: 2 errors in empty disjunction::
170+
// ./in.cue:23:8
171+
@@ -71,15 +63,13 @@
172+
let p#1 = (_|_){
173+
// [eval]
174+
x: (_|_){
175+
- // [eval] issue3977.inlineLet.p.x: conflicting values 2 and 1:
176+
- // ./in.cue:38:14
177+
- // ./in.cue:40:8
178+
- // ./in.cue:43:6
179+
- }
180+
- out: (_|_){
181+
- // [eval] issue3977.inlineLet.p.x: conflicting values 2 and 1:
182+
- // ./in.cue:38:14
183+
- // ./in.cue:40:8
184+
+ // [eval] issue3977.inlineLet.p.x: conflicting values 1 and 2:
185+
+ // ./in.cue:38:14
186+
+ // ./in.cue:43:6
187+
+ }
188+
+ out: (_|_){
189+
+ // [eval] issue3977.inlineLet.p.x: conflicting values 1 and 2:
190+
+ // ./in.cue:38:14
191+
// ./in.cue:43:6
192+
}
193+
}
194+
-- out/eval --
195+
Errors:
196+
x: conflicting values 2 and 1:
197+
./in.cue:20:14
198+
./in.cue:22:8
199+
./in.cue:26:8
200+
./in.cue:26:19
201+
x: conflicting values 4 and 1:
202+
./in.cue:20:14
203+
./in.cue:22:8
204+
./in.cue:26:8
205+
./in.cue:26:23
206+
x: 2 errors in empty disjunction::
207+
./in.cue:23:8
208+
209+
Result:
210+
(_|_){
211+
// [eval]
212+
issue3977: (_|_){
213+
// [eval]
214+
inlineExpr: (struct){
215+
#NetworkID: (int){ 1 }
216+
#fn: (#struct){
217+
x: (int){ 1 }
218+
out: (int){ 2 }
219+
}
220+
err: (int){ 3 }
221+
}
222+
inlineDisj1: (struct){
223+
#NetworkID: (string){ |((string){ "2" }, (string){ "3" }, (string){ "4" }) }
224+
#fn: (#struct){
225+
x: (string){ |((string){ "2" }, (string){ "3" }, (string){ "4" }) }
226+
out: (_|_){
227+
// [incomplete] issue3977.inlineDisj1.#fn.out: invalid interpolation: unresolved disjunction "2" | "3" | "4" (type string):
228+
// ./in.cue:14:8
229+
}
230+
}
231+
err: (string){ "value=invalid" }
232+
}
233+
inlineDisj2: (_|_){
234+
// [eval]
235+
#NetworkID: (int){ 1 }
236+
#fn: (#struct){
237+
x: (int){ 1 }
238+
out: (int){ 11 }
239+
}
240+
err: (_|_){
241+
// [eval] x: conflicting values 2 and 1:
242+
// ./in.cue:20:14
243+
// ./in.cue:22:8
244+
// ./in.cue:26:8
245+
// ./in.cue:26:19
246+
// x: conflicting values 4 and 1:
247+
// ./in.cue:20:14
248+
// ./in.cue:22:8
249+
// ./in.cue:26:8
250+
// ./in.cue:26:23
251+
// x: 2 errors in empty disjunction::
252+
// ./in.cue:23:8
253+
}
254+
}
255+
inlineDisj3: (struct){
256+
#NetworkID: (int){ 1 }
257+
#fn: (#struct){
258+
x: (int){ 1 }
259+
out: (int){ 11 }
260+
}
261+
err: (int){ 11 }
262+
}
263+
inlineLet: (struct){
264+
#NetworkID: (int){ 1 }
265+
let p#1 = (_|_){
266+
// [eval]
267+
x: (_|_){
268+
// [eval] issue3977.inlineLet.p.x: conflicting values 2 and 1:
269+
// ./in.cue:38:14
270+
// ./in.cue:40:8
271+
// ./in.cue:43:6
272+
}
273+
out: (_|_){
274+
// [eval] issue3977.inlineLet.p.x: conflicting values 2 and 1:
275+
// ./in.cue:38:14
276+
// ./in.cue:40:8
277+
// ./in.cue:43:6
278+
}
279+
}
280+
err: (int){ 12 }
281+
}
282+
}
283+
}
284+
-- out/compile --
285+
--- in.cue
286+
{
287+
issue3977: {
288+
inlineExpr: {
289+
#NetworkID: 1
290+
#fn: {
291+
x: 〈1;#NetworkID〉
292+
out: (〈0;x〉 + 1)
293+
}
294+
err: (〈0;#fn〉 & {
295+
x: 2
296+
}).out
297+
}
298+
}
299+
issue3977: {
300+
inlineDisj1: {
301+
#NetworkID: ("2"|"3"|"4")
302+
#fn: {
303+
x: 〈1;#NetworkID〉
304+
out: "value=\(〈0;x〉)"
305+
}
306+
err: (〈0;#fn〉 & {
307+
x: "invalid"
308+
}).out
309+
}
310+
}
311+
issue3977: {
312+
inlineDisj2: {
313+
#NetworkID: 1
314+
#fn: {
315+
x: 〈1;#NetworkID〉
316+
out: (〈0;x〉 + 10)
317+
}
318+
err: (〈0;#fn〉 & {
319+
x: (*2|4)
320+
}).out
321+
}
322+
}
323+
issue3977: {
324+
inlineDisj3: {
325+
#NetworkID: 1
326+
#fn: {
327+
x: 〈1;#NetworkID〉
328+
out: (〈0;x〉 + 10)
329+
}
330+
err: (〈0;#fn〉 & {
331+
x: (*2|int)
332+
}).out
333+
}
334+
}
335+
issue3977: {
336+
inlineLet: {
337+
#NetworkID: 1
338+
let p#1 = ({
339+
x: 〈1;#NetworkID〉
340+
out: (〈0;x〉 + 10)
341+
} & {
342+
x: 2
343+
})
344+
err: 〈0;let p#1〉.out
345+
}
346+
}
347+
}

0 commit comments

Comments
 (0)