Skip to content

Commit c8ff441

Browse files
committed
internal/core/adt: add test for issue 3332
Issue #3332 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I875a3f9d5285bf58b4fb26c3998f70cee31ba484 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199339 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 81740d5 commit c8ff441

File tree

1 file changed

+99
-23
lines changed

1 file changed

+99
-23
lines changed

cue/testdata/eval/closedness.txtar

+99-23
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,26 @@ inline: {
222222
age2: 5 // not allowed
223223
}
224224
}
225+
-- validation.cue --
226+
import "list"
227+
228+
issue3332: {
229+
#def: field: list.MinItems(1)
230+
use: #def & {
231+
field: ["value"]
232+
}
233+
}
234+
225235
-- out/eval/stats --
226236
Leaks: 3
227-
Freed: 263
228-
Reused: 255
237+
Freed: 269
238+
Reused: 261
229239
Allocs: 11
230240
Retain: 29
231241

232-
Unifications: 258
233-
Conjuncts: 472
234-
Disjuncts: 292
242+
Unifications: 264
243+
Conjuncts: 482
244+
Disjuncts: 299
235245
-- out/eval --
236246
Errors:
237247
a.q.e: field not allowed:
@@ -763,6 +773,16 @@ Result:
763773
age2: (int){ 5 }
764774
}
765775
}
776+
issue3332: (struct){
777+
#def: (#struct){
778+
field: (list){ list.MinItems(1) }
779+
}
780+
use: (#struct){
781+
field: (#list){
782+
0: (string){ "value" }
783+
}
784+
}
785+
}
766786
}
767787
-- out/evalalpha --
768788
Errors:
@@ -790,6 +810,8 @@ inline.err1.age1: field not allowed:
790810
inline.err2.age2: field not allowed:
791811
./reroot.cue:147:8
792812
./reroot.cue:149:3
813+
issue3332.use.field.0: field not allowed:
814+
./validation.cue:6:11
793815

794816
Result:
795817
(_|_){
@@ -1223,12 +1245,29 @@ Result:
12231245
}
12241246
}
12251247
}
1248+
issue3332: (_|_){
1249+
// [eval]
1250+
#def: (#struct){
1251+
field: (list){ list.MinItems(1) }
1252+
}
1253+
use: (_|_){
1254+
// [eval]
1255+
field: (_|_){
1256+
// [eval] issue3332.use.field.0: field not allowed:
1257+
// ./validation.cue:6:11
1258+
0: (_|_){
1259+
// [eval] issue3332.use.field.0: field not allowed:
1260+
// ./validation.cue:6:11
1261+
}
1262+
}
1263+
}
1264+
}
12261265
}
12271266
-- diff/-out/evalalpha<==>+out/eval --
12281267
diff old new
12291268
--- old
12301269
+++ new
1231-
@@ -1,66 +1,28 @@
1270+
@@ -1,66 +1,30 @@
12321271
Errors:
12331272
+nested.err1.x.b.f: field not allowed:
12341273
+ ./reroot.cue:114:6
@@ -1308,10 +1347,12 @@ diff old new
13081347
+inline.err2.age2: field not allowed:
13091348
+ ./reroot.cue:147:8
13101349
+ ./reroot.cue:149:3
1350+
+issue3332.use.field.0: field not allowed:
1351+
+ ./validation.cue:6:11
13111352

13121353
Result:
13131354
(_|_){
1314-
@@ -76,13 +38,13 @@
1355+
@@ -76,13 +40,13 @@
13151356
}
13161357
}
13171358
#Extended: (#struct){
@@ -1332,7 +1373,7 @@ diff old new
13321373
}
13331374
broken: (#struct){
13341375
name: (string){ "base" }
1335-
@@ -94,13 +56,13 @@
1376+
@@ -94,13 +58,13 @@
13361377
}
13371378
}
13381379
works: (#struct){
@@ -1353,7 +1394,7 @@ diff old new
13531394
}
13541395
}
13551396
}
1356-
@@ -110,8 +72,8 @@
1397+
@@ -110,8 +74,8 @@
13571398
#A: (#struct){
13581399
b: (int){ int }
13591400
q: (#struct){
@@ -1363,7 +1404,7 @@ diff old new
13631404
}
13641405
}
13651406
a: (_|_){
1366-
@@ -120,21 +82,17 @@
1407+
@@ -120,21 +84,17 @@
13671408
q: (_|_){
13681409
// [eval]
13691410
c: (int){ 2 }
@@ -1387,7 +1428,7 @@ diff old new
13871428
// ./in.cue:28:5
13881429
#A: (#struct){
13891430
}
1390-
@@ -142,8 +100,7 @@
1431+
@@ -142,8 +102,7 @@
13911432
// [eval]
13921433
Foo: (_|_){
13931434
// [eval] issue852.a.Foo: field not allowed:
@@ -1397,7 +1438,7 @@ diff old new
13971438
// ./in.cue:28:5
13981439
}
13991440
}
1400-
@@ -154,8 +111,8 @@
1441+
@@ -154,8 +113,8 @@
14011442
foo: (int){ int }
14021443
}
14031444
d: (#struct){
@@ -1407,7 +1448,7 @@ diff old new
14071448
}
14081449
}
14091450
issue3330: (struct){
1410-
@@ -211,11 +168,11 @@
1451+
@@ -211,11 +170,11 @@
14111452
g: (#struct){
14121453
}
14131454
}
@@ -1424,7 +1465,7 @@ diff old new
14241465
}
14251466
}
14261467
}
1427-
@@ -261,8 +218,7 @@
1468+
@@ -261,8 +220,7 @@
14281469
}
14291470
}
14301471
}
@@ -1434,7 +1475,7 @@ diff old new
14341475
embed: (struct){
14351476
err1: (struct){
14361477
#A: (#struct){
1437-
@@ -299,17 +255,15 @@
1478+
@@ -299,17 +257,15 @@
14381479
c: (int){ 2 }
14391480
}
14401481
}
@@ -1459,7 +1500,7 @@ diff old new
14591500
X: (struct){
14601501
a: (struct){
14611502
e: (int){ 1 }
1462-
@@ -317,24 +271,13 @@
1503+
@@ -317,24 +273,13 @@
14631504
b: (struct){
14641505
}
14651506
}
@@ -1491,7 +1532,7 @@ diff old new
14911532
}
14921533
}
14931534
#X: (#struct){
1494-
@@ -397,17 +340,11 @@
1535+
@@ -397,17 +342,11 @@
14951536
// [eval]
14961537
f: (_|_){
14971538
// [eval] nested.err1.x.b.f: field not allowed:
@@ -1511,7 +1552,7 @@ diff old new
15111552
}
15121553
}
15131554
v: (_|_){
1514-
@@ -414,27 +351,17 @@
1555+
@@ -414,27 +353,17 @@
15151556
// [eval]
15161557
c: (_|_){
15171558
// [eval]
@@ -1550,7 +1591,7 @@ diff old new
15501591
}
15511592
}
15521593
#V: (_|_){
1553-
@@ -441,25 +368,17 @@
1594+
@@ -441,25 +370,17 @@
15541595
// [eval]
15551596
c: (_|_){
15561597
// [eval]
@@ -1587,7 +1628,7 @@ diff old new
15871628
}
15881629
}
15891630
}
1590-
@@ -469,14 +388,14 @@
1631+
@@ -469,14 +390,14 @@
15911632
}
15921633
v: (#struct){
15931634
c: (#struct){
@@ -1606,7 +1647,7 @@ diff old new
16061647
}
16071648
}
16081649
}
1609-
@@ -499,19 +418,18 @@
1650+
@@ -499,19 +420,18 @@
16101651
// [eval]
16111652
g: (_|_){
16121653
// [eval] nested.err2.x.b.g: field not allowed:
@@ -1633,7 +1674,7 @@ diff old new
16331674
#x: (#struct){
16341675
y: (#struct){
16351676
z?: (#struct){
1636-
@@ -519,13 +437,23 @@
1677+
@@ -519,22 +439,39 @@
16371678
}
16381679
}
16391680
}
@@ -1644,6 +1685,9 @@ diff old new
16441685
- err2: (struct){
16451686
- name: (string){ "a" }
16461687
- age2: (int){ 5 }
1688+
- }
1689+
- }
1690+
- issue3332: (struct){
16471691
+ err1: (_|_){
16481692
+ // [eval]
16491693
+ name: (string){ "a" }
@@ -1661,9 +1705,28 @@ diff old new
16611705
+ // ./reroot.cue:147:8
16621706
+ // ./reroot.cue:149:3
16631707
+ }
1708+
+ }
1709+
+ }
1710+
+ issue3332: (_|_){
1711+
+ // [eval]
1712+
#def: (#struct){
1713+
field: (list){ list.MinItems(1) }
1714+
}
1715+
- use: (#struct){
1716+
- field: (#list){
1717+
- 0: (string){ "value" }
1718+
+ use: (_|_){
1719+
+ // [eval]
1720+
+ field: (_|_){
1721+
+ // [eval] issue3332.use.field.0: field not allowed:
1722+
+ // ./validation.cue:6:11
1723+
+ 0: (_|_){
1724+
+ // [eval] issue3332.use.field.0: field not allowed:
1725+
+ // ./validation.cue:6:11
1726+
+ }
1727+
}
16641728
}
16651729
}
1666-
}
16671730
-- diff/todo/p2 --
16681731
Positions / reordering
16691732

@@ -1963,3 +2026,16 @@ inline.err*.age*: fields are now correctly not allowed.
19632026
})
19642027
}
19652028
}
2029+
--- validation.cue
2030+
{
2031+
issue3332: {
2032+
#def: {
2033+
field: 〈import;list〉.MinItems(1)
2034+
}
2035+
use: (〈0;#def〉 & {
2036+
field: [
2037+
"value",
2038+
]
2039+
})
2040+
}
2041+
}

0 commit comments

Comments
 (0)