-
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.
internal/core/adt: add tests for let
These are used to ensure non-changing semantics when moving to the new let ref implemenation. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ia9342631bcb06c6b4a14e437268533248fa0fb14 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/543360 Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
1 changed file
with
147 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,147 @@ | ||
-- in.cue -- | ||
// Test that an error in a let that is merged with itself from two different | ||
// origins does not result in an error as long as the error is not referenced | ||
// outside the let. | ||
t1: { | ||
x: { | ||
a: int | ||
y: { | ||
let X = { | ||
b: a | ||
c: 1 | ||
} | ||
v: X.c | ||
} | ||
} | ||
|
||
x1: x | ||
x1: a: 1 | ||
|
||
x2: x | ||
x2: a: 2 | ||
|
||
xy: x1.y & x2.y | ||
} | ||
|
||
t2: { | ||
x: { | ||
a: {} | ||
y: { | ||
let X = { | ||
b: a | ||
c: 1 | ||
} | ||
v: X.c | ||
} | ||
} | ||
|
||
x1: x | ||
x1: a: q: 1 | ||
|
||
x2: x | ||
x2: a: r: 2 | ||
|
||
xy: x1 & x2 | ||
} | ||
-- out/eval -- | ||
(struct){ | ||
t1: (struct){ | ||
x: (struct){ | ||
a: (int){ int } | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
x1: (struct){ | ||
a: (int){ 1 } | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
x2: (struct){ | ||
a: (int){ 2 } | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
xy: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
t2: (struct){ | ||
x: (struct){ | ||
a: (struct){ | ||
} | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
x1: (struct){ | ||
a: (struct){ | ||
q: (int){ 1 } | ||
} | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
x2: (struct){ | ||
a: (struct){ | ||
r: (int){ 2 } | ||
} | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
xy: (struct){ | ||
a: (struct){ | ||
q: (int){ 1 } | ||
r: (int){ 2 } | ||
} | ||
y: (struct){ | ||
v: (int){ 1 } | ||
} | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
t1: { | ||
x: { | ||
a: int | ||
y: { | ||
v: 〈0;let X〉.c | ||
} | ||
} | ||
x1: 〈0;x〉 | ||
x1: { | ||
a: 1 | ||
} | ||
x2: 〈0;x〉 | ||
x2: { | ||
a: 2 | ||
} | ||
xy: (〈0;x1〉.y & 〈0;x2〉.y) | ||
} | ||
t2: { | ||
x: { | ||
a: {} | ||
y: { | ||
v: 〈0;let X〉.c | ||
} | ||
} | ||
x1: 〈0;x〉 | ||
x1: { | ||
a: { | ||
q: 1 | ||
} | ||
} | ||
x2: 〈0;x〉 | ||
x2: { | ||
a: { | ||
r: 2 | ||
} | ||
} | ||
xy: (〈0;x1〉 & 〈0;x2〉) | ||
} | ||
} |