Skip to content

Commit

Permalink
internal/core/adt: add tests for structure sharing
Browse files Browse the repository at this point in the history
The two added tests are broken now, but will be fixed
in a subsequent CL.

Issue #2854

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ida4c704ce6f5f9a314508378197e03c1b6f08fd5
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193673
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Apr 23, 2024
1 parent 8087ff7 commit 3a90b84
Showing 1 changed file with 170 additions and 23 deletions.
193 changes: 170 additions & 23 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,25 @@ allArcsSuccess: p2: {
}
}

structShare: ok1: {
a: [string]: E
E: {}

a: {
if true {
d: e: true // resolves
}
}
}

structShare: err1: {
x: [string]: x.#E
x: #E: {}
if true {
x: d: e: true
}
}

-- issue2208.cue --
voidErrorIncomplete: {
#Schema: [string]: {
Expand Down Expand Up @@ -1261,6 +1280,20 @@ Result:
}
}
}
structShare: (struct){
ok1: (struct){
a: (struct){
}
E: (struct){
}
}
err1: (struct){
x: (struct){
#E: (#struct){
}
}
}
}
unity: (struct){
success1: (struct){
#Config: (#struct){
Expand Down Expand Up @@ -1384,7 +1417,7 @@ Result:
diff old new
--- old
+++ new
@@ -1,24 +1,13 @@
@@ -1,29 +1,13 @@
Errors:
+noStackOverflowStructCycle.#list.tail: structural cycle
+noStackOverflowStructCycle.list.tail: structural cycle
Expand All @@ -1410,10 +1443,15 @@ diff old new
- ./in.cue:189:4
- ./in.cue:190:8
- ./in.cue:195:7
-structShare.err1.x.d.e: field not allowed:
- ./in.cue:575:15
- ./in.cue:576:9
- ./in.cue:577:2
- ./in.cue:578:9
fieldMismatch.a: cannot combine regular field "x" with 2:
./in.cue:139:7
./in.cue:137:3
@@ -63,8 +52,8 @@
@@ -68,8 +52,8 @@
}
fail: (struct){
a: (_|_){
Expand All @@ -1424,7 +1462,7 @@ diff old new
}
}
embed: (_|_){
@@ -73,10 +62,7 @@
@@ -78,10 +62,7 @@
// [eval]
p: (_|_){
// [eval] embed.fail1.p: field not allowed:
Expand All @@ -1436,7 +1474,7 @@ diff old new
// ./in.cue:46:4
// ./in.cue:49:9
}
@@ -97,10 +83,7 @@
@@ -102,10 +83,7 @@
// [eval]
p: (_|_){
// [eval] embed.fail4.p: field not allowed:
Expand All @@ -1448,15 +1486,15 @@ diff old new
// ./in.cue:74:4
q: (int){ 1 }
}
@@ -125,7 +108,6 @@
@@ -130,7 +108,6 @@
// [incomplete] embed.incomplete7.p: non-concrete value int in operand to +:
// ./in.cue:93:6
// ./in.cue:94:6
- // ./in.cue:95:3
}
q: (int){ int }
}
@@ -180,8 +162,7 @@
@@ -185,8 +162,7 @@
}
}
}
Expand All @@ -1466,7 +1504,7 @@ diff old new
t1: (struct){
#a: (_|_){
// [incomplete] provideIncompleteSuccess.t1.#a: incomplete bool: bool:
@@ -189,16 +170,15 @@
@@ -194,16 +170,15 @@
b: (bool){ bool }
}
x: (#struct){
Expand All @@ -1490,7 +1528,7 @@ diff old new
#a: (#struct){
c: (int){ 4 }
b: (bool){ true }
@@ -205,17 +185,8 @@
@@ -210,17 +185,8 @@
}
#c: (#struct){
}
Expand All @@ -1510,15 +1548,16 @@ diff old new
}
b: (bool){ true }
}
@@ -245,17 +216,22 @@
@@ -250,17 +216,22 @@
}
cyclicError: (struct){
a: (_|_){
- // [cycle] cycle error
- x: (_|_){
- // [cycle] cycle error
+ // [incomplete] cyclicError.a: incomplete bool: bool:
+ // ./in.cue:232:6
x: (_|_){
- // [cycle] cycle error
+ x: (_|_){
+ // [incomplete] cyclicError.a: incomplete bool: bool:
+ // ./in.cue:232:6
}
Expand All @@ -1537,7 +1576,7 @@ diff old new
}
}
midwayReferences: (struct){
@@ -392,7 +368,7 @@
@@ -397,7 +368,7 @@
E: (#struct){
e: (bool){ bool }
f: (_|_){
Expand All @@ -1546,7 +1585,7 @@ diff old new
// ./in.cue:389:7
}
}
@@ -412,17 +388,10 @@
@@ -417,17 +388,10 @@
}
}
E: (_|_){
Expand All @@ -1565,7 +1604,7 @@ diff old new
}
}
derefDisj2: (struct){
@@ -433,17 +402,10 @@
@@ -438,17 +402,10 @@
}
}
E: (_|_){
Expand All @@ -1584,7 +1623,48 @@ diff old new
}
}
bulk1: (struct){
@@ -562,13 +524,13 @@
@@ -550,33 +507,17 @@
}
}
}
- structShare: (_|_){
- // [eval]
+ structShare: (struct){
ok1: (struct){
a: (struct){
- d: (struct){
- e: (bool){ true }
- }
- }
- E: (struct){
- }
- }
- err1: (_|_){
- // [eval]
- x: (_|_){
- // [eval]
+ }
+ E: (struct){
+ }
+ }
+ err1: (struct){
+ x: (struct){
#E: (#struct){
}
- d: (_|_){
- // [eval]
- e: (_|_){
- // [eval] structShare.err1.x.d.e: field not allowed:
- // ./in.cue:575:15
- // ./in.cue:576:9
- // ./in.cue:577:2
- // ./in.cue:578:9
- }
- }
}
}
}
@@ -597,13 +538,13 @@
}
envs: (struct){
e1: (#struct){
Expand All @@ -1602,7 +1682,7 @@ diff old new
}
}
}
@@ -590,7 +552,7 @@
@@ -625,7 +566,7 @@
y: (int){ 1 }
}
a: (struct){
Expand All @@ -1611,7 +1691,7 @@ diff old new
}
}
nestedWithEmbeddingOK: (struct){
@@ -605,9 +567,7 @@
@@ -640,9 +581,7 @@
_c: (struct){
y: (int){ 1 }
}
Expand Down Expand Up @@ -1646,14 +1726,14 @@ diff old new
+Disjuncts: 22
-- out/eval/stats --
Leaks: 15
Freed: 394
Reused: 388
Freed: 405
Reused: 399
Allocs: 21
Retain: 100
Retain: 101

Unifications: 395
Conjuncts: 636
Disjuncts: 464
Unifications: 406
Conjuncts: 652
Disjuncts: 476
-- diff/todo/p1 --
embed.fail1.p: error not propagated to parent.
provideIncompleteSuccess.t2.a.c.d: missing error.
Expand Down Expand Up @@ -1687,6 +1767,11 @@ provideIncompleteSuccess.t2.a.c.d: field not allowed:
./in.cue:189:4
./in.cue:190:8
./in.cue:195:7
structShare.err1.x.d.e: field not allowed:
./in.cue:575:15
./in.cue:576:9
./in.cue:577:2
./in.cue:578:9
fieldMismatch.a: cannot combine regular field "x" with 2:
./in.cue:139:7
./in.cue:137:3
Expand Down Expand Up @@ -2213,6 +2298,36 @@ Result:
}
}
}
structShare: (_|_){
// [eval]
ok1: (struct){
a: (struct){
d: (struct){
e: (bool){ true }
}
}
E: (struct){
}
}
err1: (_|_){
// [eval]
x: (_|_){
// [eval]
#E: (#struct){
}
d: (_|_){
// [eval]
e: (_|_){
// [eval] structShare.err1.x.d.e: field not allowed:
// ./in.cue:575:15
// ./in.cue:576:9
// ./in.cue:577:2
// ./in.cue:578:9
}
}
}
}
}
unity: (struct){
success1: (struct){
#Config: (#struct){
Expand Down Expand Up @@ -3009,6 +3124,38 @@ Result:
}
}
}
structShare: {
ok1: {
a: {
[string]: 〈1;E〉
}
E: {}
a: {
if true {
d: {
e: true
}
}
}
}
}
structShare: {
err1: {
x: {
[string]: 〈1;x〉.#E
}
x: {
#E: {}
}
if true {
x: {
d: {
e: true
}
}
}
}
}
}
--- issue1759.cue
{
Expand Down

0 comments on commit 3a90b84

Please sign in to comment.