Skip to content

Commit

Permalink
internal/core/adt: add tests for let
Browse files Browse the repository at this point in the history
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
mpvl committed Sep 14, 2022
1 parent 739713c commit 7c7056c
Showing 1 changed file with 147 additions and 0 deletions.
147 changes: 147 additions & 0 deletions cue/testdata/eval/letjoin.txtar
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〉)
}
}

0 comments on commit 7c7056c

Please sign in to comment.