Skip to content

Commit 9f46e1a

Browse files
committed
internal/core/adt: add test case for selection problem
We add two test cases for which the value of #Step should be the same in either case. This is the case for eval v2, but not eval v3. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Iee04f55e5745e12fb9b08d9d121c85bab14fa95b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202906 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 02d5751 commit 9f46e1a

File tree

1 file changed

+148
-24
lines changed

1 file changed

+148
-24
lines changed

cue/testdata/cycle/inline_non_recursive.txtar

Lines changed: 148 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,29 @@ issue3182: {
7979
}.p.x.y
8080
}
8181
}
82+
-- select.cue --
83+
// The value of #Step should be consistent between these test cases.
84+
select: direct: {
85+
#Step: (#Job & {opt: _}).opt
86+
#Job: matchN(1, [#NormalJob])
87+
}
88+
select: indirect: {
89+
#Step: #Job.opt
90+
#Job: matchN(1, [#NormalJob]) & {opt: _}
91+
}
92+
#NormalJob: {
93+
req!: int
94+
opt?: run?: string
95+
}
8296
-- out/evalalpha/stats --
83-
Leaks: 272
97+
Leaks: 302
8498
Freed: 0
8599
Reused: 0
86-
Allocs: 272
100+
Allocs: 302
87101
Retain: 0
88102

89-
Unifications: 251
90-
Conjuncts: 1299
103+
Unifications: 280
104+
Conjuncts: 1396
91105
Disjuncts: 0
92106
-- out/evalalpha --
93107
Errors:
@@ -192,28 +206,57 @@ Result:
192206
}
193207
third: (int){ 1 }
194208
}
209+
select: (struct){
210+
direct: (struct){
211+
#Step: (_|_){
212+
// [incomplete] invalid value {opt:_} (does not satisfy matchN(1, [~(#NormalJob)])): 0 matched, expected 1:
213+
// ./select.cue:4:8
214+
// ./select.cue:3:10
215+
// ./select.cue:4:15
216+
}
217+
#Job: (_){ matchN(1, (#list){
218+
0: (_|_){// &[〈3;#NormalJob〉]
219+
}
220+
}) }
221+
}
222+
indirect: (struct){
223+
#Step: (_){ _ }
224+
#Job: (_|_){
225+
// [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN(1, [~(#NormalJob)])): 0 matched, expected 1:
226+
// ./select.cue:8:8
227+
// ./select.cue:8:15
228+
opt: (_){ _ }
229+
}
230+
}
231+
}
232+
#NormalJob: (#struct){
233+
req!: (int){ int }
234+
opt?: (#struct){
235+
run?: (string){ string }
236+
}
237+
}
195238
}
196239
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
197240
diff old new
198241
--- old
199242
+++ new
200243
@@ -1,9 +1,9 @@
201-
-Leaks: 306
202-
-Freed: 405
203-
-Reused: 401
204-
-Allocs: 310
205-
-Retain: 1066
206-
+Leaks: 272
244+
-Leaks: 309
245+
-Freed: 437
246+
-Reused: 429
247+
-Allocs: 317
248+
-Retain: 1074
249+
+Leaks: 302
207250
+Freed: 0
208251
+Reused: 0
209-
+Allocs: 272
252+
+Allocs: 302
210253
+Retain: 0
211254

212-
-Unifications: 711
213-
-Conjuncts: 2759
214-
-Disjuncts: 1446
215-
+Unifications: 251
216-
+Conjuncts: 1299
255+
-Unifications: 746
256+
-Conjuncts: 2813
257+
-Disjuncts: 1485
258+
+Unifications: 280
259+
+Conjuncts: 1396
217260
+Disjuncts: 0
218261
-- diff/-out/evalalpha<==>+out/eval --
219262
diff old new
@@ -253,19 +296,47 @@ diff old new
253296
}
254297
}
255298
}
299+
@@ -102,9 +102,14 @@
300+
}
301+
select: (struct){
302+
direct: (struct){
303+
- #Step: (_){ _ }
304+
+ #Step: (_|_){
305+
+ // [incomplete] invalid value {opt:_} (does not satisfy matchN(1, [~(#NormalJob)])): 0 matched, expected 1:
306+
+ // ./select.cue:4:8
307+
+ // ./select.cue:3:10
308+
+ // ./select.cue:4:15
309+
+ }
310+
#Job: (_){ matchN(1, (#list){
311+
- 0: (_|_){// 〈3;#NormalJob〉
312+
+ 0: (_|_){// &[〈3;#NormalJob〉]
313+
}
314+
}) }
315+
}
316+
@@ -111,7 +116,7 @@
317+
indirect: (struct){
318+
#Step: (_){ _ }
319+
#Job: (_|_){
320+
- // [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN(1, [{req!:int,opt?:{run?:string}}])): 0 matched, expected 1:
321+
+ // [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN(1, [~(#NormalJob)])): 0 matched, expected 1:
322+
// ./select.cue:8:8
323+
// ./select.cue:8:15
324+
opt: (_){ _ }
325+
-- diff/todo/p1 --
326+
select: values of #Step differ
256327
-- diff/todo/p3 --
257328
Error positions.
258329
Incorrect path due to structure sharing.
259330
-- out/eval/stats --
260-
Leaks: 306
261-
Freed: 405
262-
Reused: 401
263-
Allocs: 310
264-
Retain: 1066
331+
Leaks: 309
332+
Freed: 437
333+
Reused: 429
334+
Allocs: 317
335+
Retain: 1074
265336

266-
Unifications: 711
267-
Conjuncts: 2759
268-
Disjuncts: 1446
337+
Unifications: 746
338+
Conjuncts: 2813
339+
Disjuncts: 1485
269340
-- out/eval --
270341
Errors:
271342
issue3182.first.t2.x.b: structural cycle
@@ -369,6 +440,30 @@ Result:
369440
}
370441
third: (int){ 1 }
371442
}
443+
select: (struct){
444+
direct: (struct){
445+
#Step: (_){ _ }
446+
#Job: (_){ matchN(1, (#list){
447+
0: (_|_){// 〈3;#NormalJob〉
448+
}
449+
}) }
450+
}
451+
indirect: (struct){
452+
#Step: (_){ _ }
453+
#Job: (_|_){
454+
// [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN(1, [{req!:int,opt?:{run?:string}}])): 0 matched, expected 1:
455+
// ./select.cue:8:8
456+
// ./select.cue:8:15
457+
opt: (_){ _ }
458+
}
459+
}
460+
}
461+
#NormalJob: (#struct){
462+
req!: (int){ int }
463+
opt?: (#struct){
464+
run?: (string){ string }
465+
}
466+
}
372467
}
373468
-- out/compile --
374469
--- in.cue
@@ -525,3 +620,32 @@ Result:
525620
}
526621
}
527622
}
623+
--- select.cue
624+
{
625+
select: {
626+
direct: {
627+
#Step: (〈0;#Job〉 & {
628+
opt: _
629+
}).opt
630+
#Job: matchN(1, [
631+
〈3;#NormalJob〉,
632+
])
633+
}
634+
}
635+
select: {
636+
indirect: {
637+
#Step: 〈0;#Job〉.opt
638+
#Job: (matchN(1, [
639+
〈3;#NormalJob〉,
640+
]) & {
641+
opt: _
642+
})
643+
}
644+
}
645+
#NormalJob: {
646+
req!: int
647+
opt?: {
648+
run?: string
649+
}
650+
}
651+
}

0 commit comments

Comments
 (0)