...
1# Tests various patterns of insertion of conjuncts.
2# See https://cuelang.org/issues/2169
3
4-- a.cue --
5embeddingDirect: t1: {
6 #a: _
7 _
8} & {
9 #a: "s"
10 #a
11}
12
13embeddingExpr: t1: {
14 #a: _
15 _
16} & {
17 #a: "s"
18 [ #a ][0]
19}
20
21unifiedDirect: {
22 t1: {
23 #a: _
24 _
25 }
26 t1: {
27 #a
28 #a: _
29 }
30 t1: {
31 _
32 #a: "s"
33 }
34}
35
36
37unifiedExpr: {
38 t1: {
39 #a: _
40 _
41 }
42 t1: {
43 [ #a ][0]
44 #a: _
45 }
46 t1: {
47 #a: "s"
48 _
49 }
50}
51
52// These two embeddings both add fields to each other's original source, which
53// then, in turn, needs to be added.
54cross: t1: {
55 a: {
56 b: {v: 1, a: w: 2}
57 // from b.a: {x: 2, b: y: 5}
58 }
59 b: {
60 a: {x: 2, b: y: 5}
61 // from a.b: {v: 1, a: v: 2}
62 }
63 a
64 b
65}
66
67-- complex.cue --
68// Multiple levels of insertion
69recursive: t1: {
70 e: {}
71 c: d: e: f: 1
72 c.d
73 c: d:
74 // This part gets embedded within t1, which ends up adding new fields
75 // to here, when then again need to be embedded in t1, which then
76 // will add more fields to node e.
77 c: d: e: g: 1
78}
79
80recursive: t2: {
81 c
82 c: c: g: 1
83}
84
85-- issue2169.cue --
86embeddedFunctionalExpr: {
87 #fn: {
88 #in: _
89 _
90 } & {
91 #in: "str"
92
93 ({
94 #t: _
95 #t
96 } & {
97 #t: #in
98 _
99 }) + ""
100 }
101 #fn
102}
103-- out/eval/stats --
104Leaks: 8
105Freed: 59
106Reused: 54
107Allocs: 13
108Retain: 24
109
110Unifications: 67
111Conjuncts: 163
112Disjuncts: 73
113-- out/eval --
114(struct){
115 embeddingDirect: (struct){
116 t1: (string){
117 "s"
118 #a: (string){ "s" }
119 }
120 }
121 embeddingExpr: (struct){
122 t1: (string){
123 "s"
124 #a: (string){ "s" }
125 }
126 }
127 unifiedDirect: (struct){
128 t1: (string){
129 "s"
130 #a: (string){ "s" }
131 }
132 }
133 unifiedExpr: (struct){
134 t1: (string){
135 "s"
136 #a: (string){ "s" }
137 }
138 }
139 cross: (struct){
140 t1: (struct){
141 a: (struct){
142 b: (struct){
143 v: (int){ 1 }
144 a: (struct){
145 w: (int){ 2 }
146 }
147 y: (int){ 5 }
148 }
149 x: (int){ 2 }
150 w: (int){ 2 }
151 }
152 b: (struct){
153 a: (struct){
154 x: (int){ 2 }
155 b: (struct){
156 y: (int){ 5 }
157 }
158 w: (int){ 2 }
159 }
160 v: (int){ 1 }
161 y: (int){ 5 }
162 }
163 x: (int){ 2 }
164 y: (int){ 5 }
165 v: (int){ 1 }
166 w: (int){ 2 }
167 }
168 }
169 recursive: (struct){
170 t1: (struct){
171 e: (struct){
172 f: (int){ 1 }
173 g: (int){ 1 }
174 }
175 c: (struct){
176 d: (struct){
177 e: (struct){
178 f: (int){ 1 }
179 g: (int){ 1 }
180 }
181 c: (struct){
182 d: (struct){
183 e: (struct){
184 g: (int){ 1 }
185 }
186 }
187 }
188 }
189 }
190 }
191 t2: (struct){
192 c: (struct){
193 c: (struct){
194 g: (int){ 1 }
195 }
196 g: (int){ 1 }
197 }
198 g: (int){ 1 }
199 }
200 }
201 embeddedFunctionalExpr: (string){
202 "str"
203 #fn: (string){
204 "str"
205 #in: (string){ "str" }
206 }
207 #in: (string){ "str" }
208 }
209}
210-- out/evalalpha --
211(struct){
212 embeddingDirect: (struct){
213 t1: (string){
214 "s"
215 #a: (string){ "s" }
216 }
217 }
218 embeddingExpr: (struct){
219 t1: (string){
220 "s"
221 #a: (string){ "s" }
222 }
223 }
224 unifiedDirect: (struct){
225 t1: (string){
226 "s"
227 #a: (string){ "s" }
228 }
229 }
230 unifiedExpr: (struct){
231 t1: (string){
232 "s"
233 #a: (string){ "s" }
234 }
235 }
236 cross: (struct){
237 t1: (struct){
238 a: (struct){
239 b: (struct){
240 v: (int){ 1 }
241 a: (struct){
242 w: (int){ 2 }
243 }
244 y: (int){ 5 }
245 }
246 x: (int){ 2 }
247 w: (int){ 2 }
248 }
249 b: (struct){
250 a: (struct){
251 x: (int){ 2 }
252 b: (struct){
253 y: (int){ 5 }
254 }
255 w: (int){ 2 }
256 }
257 v: (int){ 1 }
258 y: (int){ 5 }
259 }
260 v: (int){ 1 }
261 w: (int){ 2 }
262 x: (int){ 2 }
263 y: (int){ 5 }
264 }
265 }
266 recursive: (struct){
267 t1: (struct){
268 e: (struct){
269 f: (int){ 1 }
270 g: (int){ 1 }
271 }
272 c: (struct){
273 d: (struct){
274 e: (struct){
275 f: (int){ 1 }
276 g: (int){ 1 }
277 }
278 c: (struct){
279 d: (struct){
280 e: (struct){
281 g: (int){ 1 }
282 }
283 }
284 }
285 }
286 }
287 }
288 t2: (struct){
289 c: (struct){
290 c: (struct){
291 g: (int){ 1 }
292 }
293 g: (int){ 1 }
294 }
295 g: (int){ 1 }
296 }
297 }
298 embeddedFunctionalExpr: (string){
299 "str"
300 #fn: (string){
301 "str"
302 #in: (string){ "str" }
303 }
304 #in: (string){ "str" }
305 }
306}
307-- diff/-out/evalalpha<==>+out/eval --
308diff old new
309--- old
310+++ new
311@@ -47,10 +47,10 @@
312 v: (int){ 1 }
313 y: (int){ 5 }
314 }
315- x: (int){ 2 }
316- y: (int){ 5 }
317 v: (int){ 1 }
318 w: (int){ 2 }
319+ x: (int){ 2 }
320+ y: (int){ 5 }
321 }
322 }
323 recursive: (struct){
324-- diff/todo/p3 --
325Reordering.
326-- out/compile --
327--- a.cue
328{
329 embeddingDirect: {
330 t1: ({
331 #a: _
332 _
333 } & {
334 #a: "s"
335 〈0;#a〉
336 })
337 }
338 embeddingExpr: {
339 t1: ({
340 #a: _
341 _
342 } & {
343 #a: "s"
344 [
345 〈1;#a〉,
346 ][0]
347 })
348 }
349 unifiedDirect: {
350 t1: {
351 #a: _
352 _
353 }
354 t1: {
355 〈0;#a〉
356 #a: _
357 }
358 t1: {
359 _
360 #a: "s"
361 }
362 }
363 unifiedExpr: {
364 t1: {
365 #a: _
366 _
367 }
368 t1: {
369 [
370 〈1;#a〉,
371 ][0]
372 #a: _
373 }
374 t1: {
375 #a: "s"
376 _
377 }
378 }
379 cross: {
380 t1: {
381 a: {
382 b: {
383 v: 1
384 a: {
385 w: 2
386 }
387 }
388 }
389 b: {
390 a: {
391 x: 2
392 b: {
393 y: 5
394 }
395 }
396 }
397 〈0;a〉
398 〈0;b〉
399 }
400 }
401}
402--- complex.cue
403{
404 recursive: {
405 t1: {
406 e: {}
407 c: {
408 d: {
409 e: {
410 f: 1
411 }
412 }
413 }
414 〈0;c〉.d
415 c: {
416 d: {
417 c: {
418 d: {
419 e: {
420 g: 1
421 }
422 }
423 }
424 }
425 }
426 }
427 }
428 recursive: {
429 t2: {
430 〈0;c〉
431 c: {
432 c: {
433 g: 1
434 }
435 }
436 }
437 }
438}
439--- issue2169.cue
440{
441 embeddedFunctionalExpr: {
442 #fn: ({
443 #in: _
444 _
445 } & {
446 #in: "str"
447 (({
448 #t: _
449 〈0;#t〉
450 } & {
451 #t: 〈1;#in〉
452 _
453 }) + "")
454 })
455 〈0;#fn〉
456 }
457}
View as plain text