Skip to content

Commit dcfc2d4

Browse files
committed
cue: add a regression test for a default elimination bug fixed in evalv3
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]>
1 parent 8908d06 commit dcfc2d4

File tree

2 files changed

+59
-50
lines changed

2 files changed

+59
-50
lines changed

cmd/cue/cmd/testdata/script/export_issue2916.txtar

-44
This file was deleted.

cue/testdata/disjunctions/errors.txtar

+59-6
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,26 @@ explicitDefaultError: {
3131
if a != "" {
3232
}
3333
}
34+
35+
issue2916: {
36+
b: _
37+
[_]: c: uint | *1
38+
[string]: c: >=3 | *3
39+
}
40+
issue3157: {
41+
foo: *42 | _
42+
foo: *43 | bool
43+
}
3444
-- out/eval/stats --
3545
Leaks: 0
36-
Freed: 40
37-
Reused: 32
38-
Allocs: 8
46+
Freed: 57
47+
Reused: 48
48+
Allocs: 9
3949
Retain: 0
4050

41-
Unifications: 28
42-
Conjuncts: 56
43-
Disjuncts: 40
51+
Unifications: 33
52+
Conjuncts: 77
53+
Disjuncts: 57
4454
-- out/evalalpha --
4555
Errors:
4656
issue516.x.match: field not allowed:
@@ -112,6 +122,14 @@ Result:
112122
// ./in.cue:28:5
113123
a: (string){ string }
114124
}
125+
issue2916: (struct){
126+
b: (struct){
127+
c: (int){ |((int){ &(>=3, int) }, (int){ 3 }) }
128+
}
129+
}
130+
issue3157: (struct){
131+
foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
132+
}
115133
}
116134
-- diff/-out/evalalpha<==>+out/eval --
117135
diff old new
@@ -182,6 +200,19 @@ diff old new
182200
metrics: (struct){
183201
foo: (struct){
184202
}
203+
@@ -86,10 +70,10 @@
204+
}
205+
issue2916: (struct){
206+
b: (struct){
207+
- c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
208+
+ c: (int){ |((int){ &(>=3, int) }, (int){ 3 }) }
209+
}
210+
}
211+
issue3157: (struct){
212+
- foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
213+
+ foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
214+
}
215+
}
185216
-- diff/todo/p1 --
186217
issue570.results.result: Spurious error: field not allowed
187218
This is probably due to the disjunction in the #Output field.
@@ -192,6 +223,7 @@ Missing error positions.
192223
The additional "field not allowed" error is correct and a message corresponding
193224
to one of the conjuncts failing.
194225
issue516.x.match: changes are okay and arguably better.
226+
issue2916 and issue3157: the old evaluator incorrectly kept a default in the output.
195227
-- out/eval --
196228
Errors:
197229
issue516.x: 2 errors in empty disjunction:
@@ -279,6 +311,14 @@ Result:
279311
// ./in.cue:28:5
280312
a: (string){ string }
281313
}
314+
issue2916: (struct){
315+
b: (struct){
316+
c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
317+
}
318+
}
319+
issue3157: (struct){
320+
foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
321+
}
282322
}
283323
-- out/compile --
284324
--- in.cue
@@ -321,4 +361,17 @@ Result:
321361
a: (string|*_|_(explicit error (_|_ literal) in source))
322362
if (〈0;a〉 != "") {}
323363
}
364+
issue2916: {
365+
b: _
366+
[_]: {
367+
c: (&(int, >=0)|*1)
368+
}
369+
[string]: {
370+
c: (>=3|*3)
371+
}
372+
}
373+
issue3157: {
374+
foo: (*42|_)
375+
foo: (*43|bool)
376+
}
324377
}

0 commit comments

Comments
 (0)