Skip to content

Commit

Permalink
internal/core/adt: add tests for issue 3415
Browse files Browse the repository at this point in the history
Issue #3415

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I9bbc5e850aa437c1040987b056a88c99b33e9368
Dispatch-Trailer: {"type":"trybot","CL":1206122,"patchset":1,"ref":"refs/changes/22/1206122/1","targetBranch":"master"}
  • Loading branch information
mpvl authored and cueckoo committed Dec 19, 2024
1 parent a03ed2e commit 57af726
Showing 1 changed file with 141 additions and 7 deletions.
148 changes: 141 additions & 7 deletions cue/testdata/disjunctions/embed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,38 @@ nested: {
a: 1 | 2 | *(
(3 | 4 | *( 5 | 6 | *7)) & ( 3 | 4 | ( *7 | 8 )))
}
-- issue3415.cue --
issue3415: full: {
A: #A & {
i: {
_a + _b
_a: 1
_b: 10
}
}

#A: {
i: *0 | number
}
}
issue3415: reduced: {
a: {
1 + #b
#b: 10
}
a: *0 | number
}

-- out/eval/stats --
Leaks: 1
Freed: 416
Reused: 381
Leaks: 19
Freed: 430
Reused: 413
Allocs: 36
Retain: 1
Retain: 5

Unifications: 257
Conjuncts: 478
Disjuncts: 417
Unifications: 268
Conjuncts: 502
Disjuncts: 438
-- out/evalalpha --
(struct){
default: (struct){
Expand Down Expand Up @@ -233,6 +255,33 @@ Disjuncts: 417
nested: (struct){
a: (int){ |(*(int){ 7 }, (int){ 2 }, (int){ 3 }, (int){ 4 }, (int){ 1 }) }
}
issue3415: (struct){
full: (struct){
A: (#struct){
i: (number){ |(*(int){
0
_a: (int){ 1 }
_b: (int){ 10 }
}, (number){
number
_a: (int){ 1 }
_b: (int){ 10 }
}) }
}
#A: (#struct){
i: (number){ |(*(int){ 0 }, (number){ number }) }
}
}
reduced: (struct){
a: (number){ |(*(int){
0
#b: (int){ 10 }
}, (number){
number
#b: (int){ 10 }
}) }
}
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
Expand All @@ -256,6 +305,45 @@ diff old new
a: (string){ "foo" }
e: (string){ "bar" }
}, (#struct){
@@ -163,11 +163,15 @@
issue3415: (struct){
full: (struct){
A: (#struct){
- i: (int){
- 11
- _a: (int){ 1 }
- _b: (int){ 10 }
- }
+ i: (number){ |(*(int){
+ 0
+ _a: (int){ 1 }
+ _b: (int){ 10 }
+ }, (number){
+ number
+ _a: (int){ 1 }
+ _b: (int){ 10 }
+ }) }
}
#A: (#struct){
i: (number){ |(*(int){ 0 }, (number){ number }) }
@@ -174,10 +178,13 @@
}
}
reduced: (struct){
- a: (int){
- 11
- #b: (int){ 10 }
- }
+ a: (number){ |(*(int){
+ 0
+ #b: (int){ 10 }
+ }, (number){
+ number
+ #b: (int){ 10 }
+ }) }
}
}
}
-- diff/explanation --
The old algorithm was incorrect: the default value should not be carried:
only {b: string} of the first disjunction can be part of the result. As it
Expand Down Expand Up @@ -424,6 +512,26 @@ default either.
nested: (struct){
a: (int){ |(*(int){ 7 }, (int){ 2 }, (int){ 3 }, (int){ 4 }, (int){ 1 }) }
}
issue3415: (struct){
full: (struct){
A: (#struct){
i: (int){
11
_a: (int){ 1 }
_b: (int){ 10 }
}
}
#A: (#struct){
i: (number){ |(*(int){ 0 }, (number){ number }) }
}
}
reduced: (struct){
a: (int){
11
#b: (int){ 10 }
}
}
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -515,3 +623,29 @@ default either.
a: (1|2|*((3|4|*(5|6|*7)) & (3|4|(*7|8))))
}
}
--- issue3415.cue
{
issue3415: {
full: {
A: (〈0;#A〉 & {
i: {
(〈0;_a〉 + 〈0;_b〉)
_a: 1
_b: 10
}
})
#A: {
i: (*0|number)
}
}
}
issue3415: {
reduced: {
a: {
(1 + 〈0;#b〉)
#b: 10
}
a: (*0|number)
}
}
}

0 comments on commit 57af726

Please sign in to comment.