Skip to content

Commit e65a5e0

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

File tree

1 file changed

+216
-12
lines changed

1 file changed

+216
-12
lines changed

cue/testdata/eval/disjunctions.txtar

Lines changed: 216 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,37 @@ indexElimination: {
273273
z: [for i, v in y {bits.Set(*z[i-1] | 0, len(y)-i-1, v)}][3]
274274
}
275275
}
276+
-- issue3899.cue --
277+
issue3899: reduced: p1: {
278+
b: c + "" | string
279+
c?: string
280+
}
281+
issue3899: reduced: p1: {
282+
c?: string
283+
b: c + "" | string
284+
}
285+
issue3899: full: {
286+
out: #Schema & {
287+
name: "foo"
288+
}
289+
#Schema: {
290+
_versions: foo: "123"
291+
spec: limits: true
292+
name!: string
293+
spec: image: string | *"\(name)"
294+
deployImage: _versions[spec.image]
295+
}
296+
}
276297
-- out/eval/stats --
277298
Leaks: 36
278-
Freed: 709
279-
Reused: 695
299+
Freed: 739
300+
Reused: 725
280301
Allocs: 50
281-
Retain: 77
302+
Retain: 95
282303

283-
Unifications: 408
284-
Conjuncts: 1394
285-
Disjuncts: 756
304+
Unifications: 430
305+
Conjuncts: 1449
306+
Disjuncts: 803
286307
-- out/evalalpha --
287308
Errors:
288309
f: 2 errors in empty disjunction:
@@ -298,6 +319,9 @@ issue3606.data: conflicting values string and {notAllowed:true} (mismatched type
298319
./dependencies.cue:6:6
299320
issue3606.data.notAllowed: field not allowed:
300321
./dependencies.cue:3:3
322+
issue3899.full.#Schema.deployImage: invalid index spec.image (invalid type _):
323+
./issue3899.cue:18:18
324+
./issue3899.cue:18:28
301325

302326
Result:
303327
(_|_){
@@ -699,6 +723,45 @@ Result:
699723
}) }
700724
}
701725
}
726+
issue3899: (_|_){
727+
// [eval]
728+
reduced: (struct){
729+
p1: (struct){
730+
b: (_){ |((_){ _ }, (string){ string }) }
731+
c?: (string){ string }
732+
}
733+
}
734+
full: (_|_){
735+
// [eval]
736+
out: (#struct){
737+
name: (string){ "foo" }
738+
_versions: (#struct){
739+
foo: (string){ "123" }
740+
}
741+
spec: (#struct){
742+
limits: (bool){ true }
743+
image: (string){ |(*(string){ "foo" }, (string){ string }) }
744+
}
745+
deployImage: (string){ "123" }
746+
}
747+
#Schema: (_|_){
748+
// [eval]
749+
_versions: (#struct){
750+
foo: (string){ "123" }
751+
}
752+
spec: (#struct){
753+
limits: (bool){ true }
754+
image: (_){ |(*(_){ _ }, (string){ string }) }
755+
}
756+
name!: (string){ string }
757+
deployImage: (_|_){
758+
// [eval] issue3899.full.#Schema.deployImage: invalid index spec.image (invalid type _):
759+
// ./issue3899.cue:18:18
760+
// ./issue3899.cue:18:28
761+
}
762+
}
763+
}
764+
}
702765
}
703766
-- diff/-out/evalalpha<==>+out/eval --
704767
diff old new
@@ -716,16 +779,19 @@ diff old new
716779
./in.cue:15:27
717780
issue3606.data: 2 errors in empty disjunction:
718781
issue3606.data: conflicting values string and {notAllowed:true} (mismatched types string and struct):
719-
@@ -14,8 +12,6 @@
782+
@@ -14,8 +12,9 @@
720783
./dependencies.cue:6:6
721784
issue3606.data.notAllowed: field not allowed:
722785
./dependencies.cue:3:3
723786
- ./dependencies.cue:4:6
724787
- ./dependencies.cue:6:15
788+
+issue3899.full.#Schema.deployImage: invalid index spec.image (invalid type _):
789+
+ ./issue3899.cue:18:18
790+
+ ./issue3899.cue:18:28
725791

726792
Result:
727793
(_|_){
728-
@@ -29,14 +25,7 @@
794+
@@ -29,14 +28,7 @@
729795
// ./dependencies.cue:6:6
730796
// issue3606.data.notAllowed: field not allowed:
731797
// ./dependencies.cue:3:3
@@ -741,7 +807,7 @@ diff old new
741807
}
742808
#S: ((string|struct)){ |((string){ string }, (#struct){
743809
}) }
744-
@@ -144,19 +133,12 @@
810+
@@ -144,19 +136,12 @@
745811
// [eval] f: 2 errors in empty disjunction:
746812
// f.name: conflicting values "int" and "str":
747813
// ./in.cue:5:8
@@ -762,7 +828,7 @@ diff old new
762828
}
763829
e1: (struct){
764830
a: ((null|struct)){ |((null){ null }, (struct){
765-
@@ -268,8 +250,8 @@
831+
@@ -268,8 +253,8 @@
766832
e: (struct){
767833
foobar: (#struct){
768834
b: (#struct){
@@ -772,7 +838,7 @@ diff old new
772838
}
773839
}
774840
}
775-
@@ -279,10 +261,7 @@
841+
@@ -279,10 +264,7 @@
776842
x: (int){ 0 }
777843
}
778844
inList1: (struct){
@@ -784,7 +850,7 @@ diff old new
784850
}
785851
inList2: (struct){
786852
x: (int){ 0 }
787-
@@ -402,7 +381,7 @@
853+
@@ -402,7 +384,7 @@
788854
let Ok#2 = (bool){ true }
789855
}, (#struct){
790856
_ok: (bool){ true }
@@ -793,6 +859,70 @@ diff old new
793859
x: (bool){ true }
794860
}) }
795861
bar: (#struct){ |((#struct){
862+
@@ -434,37 +416,41 @@
863+
}) }
864+
}
865+
}
866+
- issue3899: (struct){
867+
- reduced: (struct){
868+
- p1: (struct){
869+
- b: (string){ string }
870+
+ issue3899: (_|_){
871+
+ // [eval]
872+
+ reduced: (struct){
873+
+ p1: (struct){
874+
+ b: (_){ |((_){ _ }, (string){ string }) }
875+
c?: (string){ string }
876+
}
877+
}
878+
- full: (struct){
879+
- out: (#struct){
880+
- _versions: (#struct){
881+
- foo: (string){ "123" }
882+
- }
883+
- spec: (#struct){
884+
- limits: (bool){ true }
885+
- image: (string){ |(*(string){ "foo" }, (string){ string }) }
886+
- }
887+
+ full: (_|_){
888+
+ // [eval]
889+
+ out: (#struct){
890+
name: (string){ "foo" }
891+
+ _versions: (#struct){
892+
+ foo: (string){ "123" }
893+
+ }
894+
+ spec: (#struct){
895+
+ limits: (bool){ true }
896+
+ image: (string){ |(*(string){ "foo" }, (string){ string }) }
897+
+ }
898+
deployImage: (string){ "123" }
899+
}
900+
- #Schema: (#struct){
901+
- _versions: (#struct){
902+
- foo: (string){ "123" }
903+
- }
904+
- spec: (#struct){
905+
- limits: (bool){ true }
906+
- image: (string){ string }
907+
+ #Schema: (_|_){
908+
+ // [eval]
909+
+ _versions: (#struct){
910+
+ foo: (string){ "123" }
911+
+ }
912+
+ spec: (#struct){
913+
+ limits: (bool){ true }
914+
+ image: (_){ |(*(_){ _ }, (string){ string }) }
915+
}
916+
name!: (string){ string }
917+
deployImage: (_|_){
918+
- // [incomplete] issue3899.full.#Schema.deployImage: invalid non-ground value string (must be concrete string):
919+
- // ./issue3899.cue:17:18
920+
+ // [eval] issue3899.full.#Schema.deployImage: invalid index spec.image (invalid type _):
921+
+ // ./issue3899.cue:18:18
922+
+ // ./issue3899.cue:18:28
923+
}
924+
}
925+
}
796926
-- diff/todo/p3 --
797927
Missing error positions.
798928
It is probably okay to show name and val fields with original values, as long
@@ -1235,6 +1365,41 @@ Result:
12351365
}) }
12361366
}
12371367
}
1368+
issue3899: (struct){
1369+
reduced: (struct){
1370+
p1: (struct){
1371+
b: (string){ string }
1372+
c?: (string){ string }
1373+
}
1374+
}
1375+
full: (struct){
1376+
out: (#struct){
1377+
_versions: (#struct){
1378+
foo: (string){ "123" }
1379+
}
1380+
spec: (#struct){
1381+
limits: (bool){ true }
1382+
image: (string){ |(*(string){ "foo" }, (string){ string }) }
1383+
}
1384+
name: (string){ "foo" }
1385+
deployImage: (string){ "123" }
1386+
}
1387+
#Schema: (#struct){
1388+
_versions: (#struct){
1389+
foo: (string){ "123" }
1390+
}
1391+
spec: (#struct){
1392+
limits: (bool){ true }
1393+
image: (string){ string }
1394+
}
1395+
name!: (string){ string }
1396+
deployImage: (_|_){
1397+
// [incomplete] issue3899.full.#Schema.deployImage: invalid non-ground value string (must be concrete string):
1398+
// ./issue3899.cue:17:18
1399+
}
1400+
}
1401+
}
1402+
}
12381403
}
12391404
-- out/compile --
12401405
--- dependencies.cue
@@ -1722,3 +1887,42 @@ Result:
17221887
}
17231888
}
17241889
}
1890+
--- issue3899.cue
1891+
{
1892+
issue3899: {
1893+
reduced: {
1894+
p1: {
1895+
b: ((〈0;c〉 + "")|string)
1896+
c?: string
1897+
}
1898+
}
1899+
}
1900+
issue3899: {
1901+
reduced: {
1902+
p1: {
1903+
c?: string
1904+
b: ((〈0;c〉 + "")|string)
1905+
}
1906+
}
1907+
}
1908+
issue3899: {
1909+
full: {
1910+
out: (〈0;#Schema〉 & {
1911+
name: "foo"
1912+
})
1913+
#Schema: {
1914+
_versions: {
1915+
foo: "123"
1916+
}
1917+
spec: {
1918+
limits: true
1919+
}
1920+
name!: string
1921+
spec: {
1922+
image: (string|*"\(〈1;name〉)")
1923+
}
1924+
deployImage: 〈0;_versions〉[〈0;spec〉.image]
1925+
}
1926+
}
1927+
}
1928+
}

0 commit comments

Comments
 (0)