-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue: add regression test for a cycle error position bug fixed in evalv3
The old evaluator correctly spotted the cycle error in this case, but failed to provide any position. The new evaluator gets it right. Closes #3118. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I6af62a26e10319a6b949aff4ddf8094c646311bf Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200092 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
- Loading branch information
Showing
1 changed file
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,329 @@ | ||
-- in.cue -- | ||
#TimeSpan: { | ||
start: float | ||
duration: float | ||
end: float | ||
|
||
start: end - duration | ||
duration: end - start | ||
end: start + duration | ||
|
||
start: <=end | ||
} | ||
|
||
examples: [string]: #TimeSpan | ||
|
||
examples: eg1: { | ||
start: 10.0 | ||
duration: 2.1 | ||
} | ||
|
||
examples: eg2: { | ||
start: 10.0 | ||
} | ||
|
||
examples: eg3: { | ||
end: 10.0 | ||
} | ||
-- out/evalalpha/stats -- | ||
Leaks: 19 | ||
Freed: 0 | ||
Reused: 0 | ||
Allocs: 19 | ||
Retain: 0 | ||
|
||
Unifications: 19 | ||
Conjuncts: 98 | ||
Disjuncts: 0 | ||
-- diff/-out/evalalpha/stats<==>+out/eval/stats -- | ||
diff old new | ||
--- old | ||
+++ new | ||
@@ -1,9 +1,9 @@ | ||
-Leaks: 0 | ||
-Freed: 18 | ||
-Reused: 12 | ||
-Allocs: 6 | ||
-Retain: 269 | ||
+Leaks: 19 | ||
+Freed: 0 | ||
+Reused: 0 | ||
+Allocs: 19 | ||
+Retain: 0 | ||
|
||
-Unifications: 18 | ||
-Conjuncts: 354 | ||
-Disjuncts: 19 | ||
+Unifications: 19 | ||
+Conjuncts: 98 | ||
+Disjuncts: 0 | ||
-- out/eval/stats -- | ||
Leaks: 0 | ||
Freed: 18 | ||
Reused: 12 | ||
Allocs: 6 | ||
Retain: 269 | ||
|
||
Unifications: 18 | ||
Conjuncts: 354 | ||
Disjuncts: 19 | ||
-- out/evalalpha -- | ||
(struct){ | ||
#TimeSpan: (#struct){ | ||
start: (_|_){ | ||
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// #TimeSpan.start: non-concrete value float in operand to -: | ||
// ./in.cue:6:12 | ||
// ./in.cue:4:12 | ||
// #TimeSpan.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
duration: (_|_){ | ||
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// #TimeSpan.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
end: (_|_){ | ||
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// #TimeSpan.start: non-concrete value float in operand to -: | ||
// ./in.cue:6:12 | ||
// ./in.cue:4:12 | ||
// #TimeSpan.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
} | ||
examples: (struct){ | ||
eg1: (#struct){ | ||
start: (float){ 10.0 } | ||
duration: (float){ 2.1 } | ||
end: (float){ 12.1 } | ||
} | ||
eg2: (#struct){ | ||
start: (_|_){ | ||
// [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// examples.eg2.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
duration: (_|_){ | ||
// [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// examples.eg2.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
end: (_|_){ | ||
// [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
// ./in.cue:10:11 | ||
// examples.eg2.duration: non-concrete value float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:4:12 | ||
} | ||
} | ||
eg3: (#struct){ | ||
end: (_|_){ | ||
// [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:10:9 | ||
} | ||
start: (_|_){ | ||
// [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:10:9 | ||
} | ||
duration: (_|_){ | ||
// [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
// ./in.cue:7:12 | ||
// ./in.cue:10:9 | ||
} | ||
} | ||
} | ||
} | ||
-- diff/explanation -- | ||
the new evaluator includes positions with the cycle error and the old evaluator does not. | ||
-- diff/-out/evalalpha<==>+out/eval -- | ||
diff old new | ||
--- old | ||
+++ new | ||
@@ -1,15 +1,31 @@ | ||
(struct){ | ||
#TimeSpan: (#struct){ | ||
start: (_|_){ | ||
- // [cycle] cycle error | ||
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // #TimeSpan.start: non-concrete value float in operand to -: | ||
+ // ./in.cue:6:12 | ||
+ // ./in.cue:4:12 | ||
+ // #TimeSpan.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
} | ||
duration: (_|_){ | ||
- // [cycle] cycle error: | ||
- // ./in.cue:7:12 | ||
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // #TimeSpan.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
} | ||
end: (_|_){ | ||
- // [cycle] cycle error: | ||
- // ./in.cue:8:12 | ||
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // #TimeSpan.start: non-concrete value float in operand to -: | ||
+ // ./in.cue:6:12 | ||
+ // ./in.cue:4:12 | ||
+ // #TimeSpan.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
} | ||
} | ||
examples: (struct){ | ||
@@ -20,26 +36,42 @@ | ||
} | ||
eg2: (#struct){ | ||
start: (_|_){ | ||
- // [cycle] cycle error | ||
- } | ||
- duration: (_|_){ | ||
- // [cycle] cycle error: | ||
- // ./in.cue:7:12 | ||
- } | ||
- end: (_|_){ | ||
- // [cycle] cycle error | ||
+ // [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // examples.eg2.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
+ } | ||
+ duration: (_|_){ | ||
+ // [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // examples.eg2.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
+ } | ||
+ end: (_|_){ | ||
+ // [incomplete] examples.eg2.start: non-concrete value end for bound <=: | ||
+ // ./in.cue:10:11 | ||
+ // examples.eg2.duration: non-concrete value float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:4:12 | ||
} | ||
} | ||
eg3: (#struct){ | ||
end: (_|_){ | ||
- // [cycle] cycle error: | ||
- // ./in.cue:8:12 | ||
- } | ||
- start: (_|_){ | ||
- // [cycle] cycle error | ||
- } | ||
- duration: (_|_){ | ||
- // [cycle] cycle error | ||
+ // [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:10:9 | ||
+ } | ||
+ start: (_|_){ | ||
+ // [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:10:9 | ||
+ } | ||
+ duration: (_|_){ | ||
+ // [incomplete] examples.eg3.duration: non-concrete value <=10.0 & float in operand to -: | ||
+ // ./in.cue:7:12 | ||
+ // ./in.cue:10:9 | ||
} | ||
} | ||
} | ||
-- out/eval -- | ||
(struct){ | ||
#TimeSpan: (#struct){ | ||
start: (_|_){ | ||
// [cycle] cycle error | ||
} | ||
duration: (_|_){ | ||
// [cycle] cycle error: | ||
// ./in.cue:7:12 | ||
} | ||
end: (_|_){ | ||
// [cycle] cycle error: | ||
// ./in.cue:8:12 | ||
} | ||
} | ||
examples: (struct){ | ||
eg1: (#struct){ | ||
start: (float){ 10.0 } | ||
duration: (float){ 2.1 } | ||
end: (float){ 12.1 } | ||
} | ||
eg2: (#struct){ | ||
start: (_|_){ | ||
// [cycle] cycle error | ||
} | ||
duration: (_|_){ | ||
// [cycle] cycle error: | ||
// ./in.cue:7:12 | ||
} | ||
end: (_|_){ | ||
// [cycle] cycle error | ||
} | ||
} | ||
eg3: (#struct){ | ||
end: (_|_){ | ||
// [cycle] cycle error: | ||
// ./in.cue:8:12 | ||
} | ||
start: (_|_){ | ||
// [cycle] cycle error | ||
} | ||
duration: (_|_){ | ||
// [cycle] cycle error | ||
} | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
#TimeSpan: { | ||
start: float | ||
duration: float | ||
end: float | ||
start: (〈0;end〉 - 〈0;duration〉) | ||
duration: (〈0;end〉 - 〈0;start〉) | ||
end: (〈0;start〉 + 〈0;duration〉) | ||
start: <=〈0;end〉 | ||
} | ||
examples: { | ||
[string]: 〈1;#TimeSpan〉 | ||
} | ||
examples: { | ||
eg1: { | ||
start: 10.0 | ||
duration: 2.1 | ||
} | ||
} | ||
examples: { | ||
eg2: { | ||
start: 10.0 | ||
} | ||
} | ||
examples: { | ||
eg3: { | ||
end: 10.0 | ||
} | ||
} | ||
} |