Skip to content

Commit d0564de

Browse files
committed
internal/core/adt: add tests for 3639 and 3661
Issue #3669 Issue #3661 Issue #3678 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I62c29888f28ff07181c820be1925f7e0d4dc5792 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207236 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 393e9fa commit d0564de

File tree

1 file changed

+311
-12
lines changed

1 file changed

+311
-12
lines changed

cue/testdata/builtins/validators.txtar

+311-12
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,45 @@ issue3474: topValidator: failType: {
186186
if true {C: 1}
187187
}
188188
}
189+
-- validator_is_top.cue --
190+
issue3639: {
191+
a: {#X} & #X
192+
a: b: 1
193+
#X: matchN(1, [{b: int}])
194+
}
195+
issue3661: {
196+
#X: matchN(1, [{ b!: int }])
197+
a: b: 1
198+
a: #X
199+
["a"]: #X
200+
}
201+
issue3678: {
202+
#X: matchN(1, [{
203+
a!: string
204+
}, {
205+
c!: string
206+
}])
189207

208+
x: c: "c"
209+
210+
y: #X
211+
y: x
212+
x: #X
213+
}
190214
-- out/eval/stats --
191-
Leaks: 1
192-
Freed: 117
193-
Reused: 110
194-
Allocs: 8
195-
Retain: 12
215+
Leaks: 4
216+
Freed: 177
217+
Reused: 170
218+
Allocs: 11
219+
Retain: 23
196220

197-
Unifications: 118
198-
Conjuncts: 226
199-
Disjuncts: 131
221+
Unifications: 181
222+
Conjuncts: 327
223+
Disjuncts: 202
200224
-- out/evalalpha --
201225
Errors:
226+
issue3639.a.b: field not allowed:
227+
./validator_is_top.cue:3:5
202228
callOfCallToValidator.e: cannot call previously called validator b:
203229
./in.cue:94:5
204230
issue3418.t1: invalid value "foo" (does not satisfy matchN): conflicting values 2 and 1:
@@ -244,6 +270,12 @@ issue3474.topValidator.failType.A: invalid value {C:1} (does not satisfy matchN)
244270
./issue3474.cue:53:5
245271
./issue3474.cue:53:12
246272
./issue3474.cue:54:5
273+
issue3661.a.b: field not allowed:
274+
./validator_is_top.cue:7:6
275+
./validator_is_top.cue:8:5
276+
issue3678.y.c: field not allowed:
277+
./validator_is_top.cue:13:6
278+
./validator_is_top.cue:19:5
247279

248280
Result:
249281
(_|_){
@@ -457,12 +489,81 @@ Result:
457489
}
458490
}
459491
}
492+
issue3639: (_|_){
493+
// [eval]
494+
a: (_|_){
495+
// [eval] issue3639.a.b: field not allowed:
496+
// ./validator_is_top.cue:3:5
497+
b: (_|_){
498+
// [eval] issue3639.a.b: field not allowed:
499+
// ./validator_is_top.cue:3:5
500+
}
501+
}
502+
#X: (_){ matchN(1, (#list){
503+
0: (_|_){// &[{
504+
// b: int
505+
// }]
506+
}
507+
}) }
508+
}
509+
issue3661: (_|_){
510+
// [eval]
511+
#X: (_){ matchN(1, (#list){
512+
0: (_|_){// &[{
513+
// b!: int
514+
// }]
515+
}
516+
}) }
517+
a: (_|_){
518+
// [eval] issue3661.a.b: field not allowed:
519+
// ./validator_is_top.cue:7:6
520+
// ./validator_is_top.cue:8:5
521+
b: (_|_){
522+
// [eval] issue3661.a.b: field not allowed:
523+
// ./validator_is_top.cue:7:6
524+
// ./validator_is_top.cue:8:5
525+
}
526+
}
527+
}
528+
issue3678: (_|_){
529+
// [eval]
530+
#X: (_){ matchN(1, (#list){
531+
0: (_|_){// &[{
532+
// a!: string
533+
// }]
534+
}
535+
1: (_|_){// &[{
536+
// c!: string
537+
// }]
538+
}
539+
}) }
540+
x: (#struct){
541+
c: (string){ "c" }
542+
}
543+
y: (_|_){
544+
// [eval] issue3678.y.c: field not allowed:
545+
// ./validator_is_top.cue:13:6
546+
// ./validator_is_top.cue:19:5
547+
c: (_|_){
548+
// [eval] issue3678.y.c: field not allowed:
549+
// ./validator_is_top.cue:13:6
550+
// ./validator_is_top.cue:19:5
551+
}
552+
}
553+
}
460554
}
461555
-- diff/-out/evalalpha<==>+out/eval --
462556
diff old new
463557
--- old
464558
+++ new
465-
@@ -27,7 +27,7 @@
559+
@@ -1,4 +1,6 @@
560+
Errors:
561+
+issue3639.a.b: field not allowed:
562+
+ ./validator_is_top.cue:3:5
563+
callOfCallToValidator.e: cannot call previously called validator b:
564+
./in.cue:94:5
565+
issue3418.t1: invalid value "foo" (does not satisfy matchN): conflicting values 2 and 1:
566+
@@ -27,7 +29,7 @@
466567
./issue3418.cue:10:16
467568
./issue3418.cue:10:18
468569
./issue3418.cue:11:5
@@ -471,7 +572,20 @@ diff old new
471572
./issue3474.cue:12:5
472573
./issue3474.cue:12:22
473574
./issue3474.cue:13:5
474-
@@ -134,11 +134,7 @@
575+
@@ -44,6 +46,12 @@
576+
./issue3474.cue:53:5
577+
./issue3474.cue:53:12
578+
./issue3474.cue:54:5
579+
+issue3661.a.b: field not allowed:
580+
+ ./validator_is_top.cue:7:6
581+
+ ./validator_is_top.cue:8:5
582+
+issue3678.y.c: field not allowed:
583+
+ ./validator_is_top.cue:13:6
584+
+ ./validator_is_top.cue:19:5
585+
586+
Result:
587+
(_|_){
588+
@@ -134,11 +142,7 @@
475589
0: (int){ 1 }
476590
}
477591
}
@@ -484,7 +598,7 @@ diff old new
484598
_a: (_|_){
485599
// [incomplete] issue2098.incomplete1._a: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1):
486600
// ./in.cue:112:6
487-
@@ -202,7 +198,7 @@
601+
@@ -202,7 +206,7 @@
488602
failAfter: (_|_){
489603
// [eval]
490604
A: (_|_){
@@ -493,7 +607,7 @@ diff old new
493607
// ./issue3474.cue:12:5
494608
// ./issue3474.cue:12:22
495609
// ./issue3474.cue:13:5
496-
@@ -245,7 +241,7 @@
610+
@@ -245,7 +249,7 @@
497611
}
498612
incomplete: (struct){
499613
A: (int){ &(matchN(1, (#list){
@@ -502,6 +616,107 @@ diff old new
502616
}
503617
}), int) }
504618
}
619+
@@ -261,44 +265,66 @@
620+
}
621+
}
622+
}
623+
- issue3639: (struct){
624+
- a: (struct){
625+
- b: (int){ 1 }
626+
- }
627+
- #X: (_){ matchN(1, (#list){
628+
- 0: (_|_){// {
629+
+ issue3639: (_|_){
630+
+ // [eval]
631+
+ a: (_|_){
632+
+ // [eval] issue3639.a.b: field not allowed:
633+
+ // ./validator_is_top.cue:3:5
634+
+ b: (_|_){
635+
+ // [eval] issue3639.a.b: field not allowed:
636+
+ // ./validator_is_top.cue:3:5
637+
+ }
638+
+ }
639+
+ #X: (_){ matchN(1, (#list){
640+
+ 0: (_|_){// &[{
641+
// b: int
642+
- // }
643+
- }
644+
- }) }
645+
- }
646+
- issue3661: (struct){
647+
- #X: (_){ matchN(1, (#list){
648+
- 0: (_|_){// {
649+
+ // }]
650+
+ }
651+
+ }) }
652+
+ }
653+
+ issue3661: (_|_){
654+
+ // [eval]
655+
+ #X: (_){ matchN(1, (#list){
656+
+ 0: (_|_){// &[{
657+
// b!: int
658+
- // }
659+
- }
660+
- }) }
661+
- a: (struct){
662+
- b: (int){ 1 }
663+
- }
664+
- }
665+
- issue3678: (struct){
666+
- #X: (_){ matchN(1, (#list){
667+
- 0: (_|_){// {
668+
+ // }]
669+
+ }
670+
+ }) }
671+
+ a: (_|_){
672+
+ // [eval] issue3661.a.b: field not allowed:
673+
+ // ./validator_is_top.cue:7:6
674+
+ // ./validator_is_top.cue:8:5
675+
+ b: (_|_){
676+
+ // [eval] issue3661.a.b: field not allowed:
677+
+ // ./validator_is_top.cue:7:6
678+
+ // ./validator_is_top.cue:8:5
679+
+ }
680+
+ }
681+
+ }
682+
+ issue3678: (_|_){
683+
+ // [eval]
684+
+ #X: (_){ matchN(1, (#list){
685+
+ 0: (_|_){// &[{
686+
// a!: string
687+
- // }
688+
- }
689+
- 1: (_|_){// {
690+
+ // }]
691+
+ }
692+
+ 1: (_|_){// &[{
693+
// c!: string
694+
- // }
695+
- }
696+
- }) }
697+
- x: (struct){
698+
- c: (string){ "c" }
699+
- }
700+
- y: (struct){
701+
- c: (string){ "c" }
702+
+ // }]
703+
+ }
704+
+ }) }
705+
+ x: (#struct){
706+
+ c: (string){ "c" }
707+
+ }
708+
+ y: (_|_){
709+
+ // [eval] issue3678.y.c: field not allowed:
710+
+ // ./validator_is_top.cue:13:6
711+
+ // ./validator_is_top.cue:19:5
712+
+ c: (_|_){
713+
+ // [eval] issue3678.y.c: field not allowed:
714+
+ // ./validator_is_top.cue:13:6
715+
+ // ./validator_is_top.cue:19:5
716+
+ }
717+
}
718+
}
719+
}
505720
-- out/eval --
506721
Errors:
507722
callOfCallToValidator.e: cannot call previously called validator b:
@@ -766,6 +981,46 @@ Result:
766981
}
767982
}
768983
}
984+
issue3639: (struct){
985+
a: (struct){
986+
b: (int){ 1 }
987+
}
988+
#X: (_){ matchN(1, (#list){
989+
0: (_|_){// {
990+
// b: int
991+
// }
992+
}
993+
}) }
994+
}
995+
issue3661: (struct){
996+
#X: (_){ matchN(1, (#list){
997+
0: (_|_){// {
998+
// b!: int
999+
// }
1000+
}
1001+
}) }
1002+
a: (struct){
1003+
b: (int){ 1 }
1004+
}
1005+
}
1006+
issue3678: (struct){
1007+
#X: (_){ matchN(1, (#list){
1008+
0: (_|_){// {
1009+
// a!: string
1010+
// }
1011+
}
1012+
1: (_|_){// {
1013+
// c!: string
1014+
// }
1015+
}
1016+
}) }
1017+
x: (struct){
1018+
c: (string){ "c" }
1019+
}
1020+
y: (struct){
1021+
c: (string){ "c" }
1022+
}
1023+
}
7691024
}
7701025
-- out/compile --
7711026
--- in.cue
@@ -1016,3 +1271,47 @@ Result:
10161271
}
10171272
}
10181273
}
1274+
--- validator_is_top.cue
1275+
{
1276+
issue3639: {
1277+
a: ({
1278+
〈1;#X〉
1279+
} & 〈0;#X〉)
1280+
a: {
1281+
b: 1
1282+
}
1283+
#X: matchN(1, [
1284+
{
1285+
b: int
1286+
},
1287+
])
1288+
}
1289+
issue3661: {
1290+
#X: matchN(1, [
1291+
{
1292+
b!: int
1293+
},
1294+
])
1295+
a: {
1296+
b: 1
1297+
}
1298+
a: 〈0;#X〉
1299+
["a"]: 〈0;#X〉
1300+
}
1301+
issue3678: {
1302+
#X: matchN(1, [
1303+
{
1304+
a!: string
1305+
},
1306+
{
1307+
c!: string
1308+
},
1309+
])
1310+
x: {
1311+
c: "c"
1312+
}
1313+
y: 〈0;#X〉
1314+
y: 〈0;x〉
1315+
x: 〈0;#X〉
1316+
}
1317+
}

0 commit comments

Comments
 (0)