Skip to content

Commit

Permalink
internal/core/dep: add in tests for new evaluator
Browse files Browse the repository at this point in the history
Add todos where appropriate. One tests has a fatal error
and has been explicitly excluded.

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Id6ffe084febf1b70c91a03cfce0c9da22db9199f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194180
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed May 3, 2024
1 parent 1e843cb commit cb2410c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/core/dep/dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"text/tabwriter"

"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
"cuelang.org/go/cue/format"
"cuelang.org/go/internal/core/adt"
"cuelang.org/go/internal/core/debug"
"cuelang.org/go/internal/core/dep"
"cuelang.org/go/internal/core/eval"
"cuelang.org/go/internal/cuetdtest"
"cuelang.org/go/internal/cuetxtar"
"cuelang.org/go/internal/value"
)
Expand All @@ -36,12 +36,17 @@ type visitFunc func(*adt.OpContext, *adt.ImportReference, *adt.Vertex, dep.Visit

func TestVisit(t *testing.T) {
test := cuetxtar.TxTarTest{
Root: "./testdata",
Name: "dependencies",
Root: "./testdata",
Name: "dependencies",
Matrix: cuetdtest.SmallMatrix,

ToDo: map[string]string{
"dependencies-v3/inline": "error",
},
}

test.Run(t, func(t *cuetxtar.Test) {
val := cuecontext.New().BuildInstance(t.Instance())
val := t.Context().BuildInstance(t.Instance())
if val.Err() != nil {
t.Fatal(val.Err())
}
Expand Down
18 changes: 18 additions & 0 deletions internal/core/dep/testdata/dynamic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ line reference path of resulting vertex
-- out/dependencies/all --
line reference path of resulting vertex
21: middle => middle
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
21: middle => middle
21: x => **non-rooted**
21: x => **non-rooted**
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -1,4 +1,4 @@
line reference path of resulting vertex
21: middle => middle
-21: x => middle.la1
-21: x => middle.la2
+21: x => **non-rooted**
+21: x => **non-rooted**
-- diff/dependencies/todo/p1 --
middle.la*: now replaced with "non-rooted"
-- out/dependencies/dynamic --
line reference path of resulting vertex
21: middle => middle
Expand Down
26 changes: 26 additions & 0 deletions internal/core/dep/testdata/structcomprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ line reference path of resulting vertex
5: e => e
5: d => d
8: f.g => f.g
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
2: c => c
5: e => e
8: f.g => f.g
5: x => **non-rooted**
5: d => d
5: x => **non-rooted**
5: d => d
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -2,7 +2,7 @@
2: c => c
5: e => e
8: f.g => f.g
-5: x => c[0]
-5: d => d
-5: x => c[1]
+5: x => **non-rooted**
+5: d => d
+5: x => **non-rooted**
5: d => d
-- diff/dependencies/todo/p1 --
Some values now marked as non-rooted.
-- out/dependencies/dynamic --
line reference path of resulting vertex
2: c => c
Expand Down
38 changes: 38 additions & 0 deletions internal/core/dep/testdata/topcomprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,44 @@ a: {
}
-- out/dependencies/field --
line reference path of resulting vertex
-- out/dependencies-v3/all --
line reference path of resulting vertex
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
4: key => **non-rooted**
2: key => **non-rooted**
11: key => **non-rooted**
12: value => **non-rooted**
9: key => **non-rooted**
-- diff/-out/dependencies-v3/all<==>+out/dependencies/all --
diff old new
--- old
+++ new
@@ -2,4 +2,3 @@
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
-3: value => **non-rooted**
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -1,9 +1,6 @@
line reference path of resulting vertex
4: key => **non-rooted**
-5: value => **non-rooted**
+2: key => **non-rooted**
11: key => **non-rooted**
12: value => **non-rooted**
-2: key => **non-rooted**
-3: value => **non-rooted**
9: key => **non-rooted**
-10: value => **non-rooted**
-- diff/dependencies/todo/p1 --
Missing line items.
-- out/dependencies/all --
line reference path of resulting vertex
4: key => **non-rooted**
Expand Down

0 comments on commit cb2410c

Please sign in to comment.