Skip to content

Commit

Permalink
cue: add a regression test for a default elimination bug fixed in evalv3
Browse files Browse the repository at this point in the history
While here, move the extremely similar regression test from #2916
out of a cmd/cue testscript and into cue/testdata.
The txtar tests in cue/testdata are better suited for evaluator tests
as they test all evaluator versions, diff between them, and also include
other information such as evaluator stats and compiler debugging info.

Closes #3157.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Icdb61cc89178b8236ea9ba8ad42c087a798c66ff
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200094
Reviewed-by: Matthew Sackman <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Aug 28, 2024
1 parent 8908d06 commit dcfc2d4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 50 deletions.
44 changes: 0 additions & 44 deletions cmd/cue/cmd/testdata/script/export_issue2916.txtar

This file was deleted.

65 changes: 59 additions & 6 deletions cue/testdata/disjunctions/errors.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,26 @@ explicitDefaultError: {
if a != "" {
}
}

issue2916: {
b: _
[_]: c: uint | *1
[string]: c: >=3 | *3
}
issue3157: {
foo: *42 | _
foo: *43 | bool
}
-- out/eval/stats --
Leaks: 0
Freed: 40
Reused: 32
Allocs: 8
Freed: 57
Reused: 48
Allocs: 9
Retain: 0

Unifications: 28
Conjuncts: 56
Disjuncts: 40
Unifications: 33
Conjuncts: 77
Disjuncts: 57
-- out/evalalpha --
Errors:
issue516.x.match: field not allowed:
Expand Down Expand Up @@ -112,6 +122,14 @@ Result:
// ./in.cue:28:5
a: (string){ string }
}
issue2916: (struct){
b: (struct){
c: (int){ |((int){ &(>=3, int) }, (int){ 3 }) }
}
}
issue3157: (struct){
foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
Expand Down Expand Up @@ -182,6 +200,19 @@ diff old new
metrics: (struct){
foo: (struct){
}
@@ -86,10 +70,10 @@
}
issue2916: (struct){
b: (struct){
- c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
+ c: (int){ |((int){ &(>=3, int) }, (int){ 3 }) }
}
}
issue3157: (struct){
- foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
+ foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
}
}
-- diff/todo/p1 --
issue570.results.result: Spurious error: field not allowed
This is probably due to the disjunction in the #Output field.
Expand All @@ -192,6 +223,7 @@ Missing error positions.
The additional "field not allowed" error is correct and a message corresponding
to one of the conjuncts failing.
issue516.x.match: changes are okay and arguably better.
issue2916 and issue3157: the old evaluator incorrectly kept a default in the output.
-- out/eval --
Errors:
issue516.x: 2 errors in empty disjunction:
Expand Down Expand Up @@ -279,6 +311,14 @@ Result:
// ./in.cue:28:5
a: (string){ string }
}
issue2916: (struct){
b: (struct){
c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
}
}
issue3157: (struct){
foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -321,4 +361,17 @@ Result:
a: (string|*_|_(explicit error (_|_ literal) in source))
if (〈0;a〉 != "") {}
}
issue2916: {
b: _
[_]: {
c: (&(int, >=0)|*1)
}
[string]: {
c: (>=3|*3)
}
}
issue3157: {
foo: (*42|_)
foo: (*43|bool)
}
}

0 comments on commit dcfc2d4

Please sign in to comment.