cue: add test cases
Change-Id: I175bbe23fb76968dd530a292f2400c8d23039097
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6565
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/types_test.go b/cue/types_test.go
index 4a2c005..b615158 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -165,6 +165,11 @@
concrete: true,
closed: true,
}, {
+ value: `v: [...int]`,
+ kind: BottomKind,
+ incompleteKind: ListKind,
+ concrete: false,
+ }, {
value: `v: {a: int, b: [1][a]}.b`,
kind: BottomKind,
concrete: false,
@@ -2386,6 +2391,22 @@
want: "T",
}, {
input: `
+ #S: {
+ b?: [...#T]
+ b?: [...#T]
+ }
+ #T: int
+ `,
+ lookup: func(i *Instance) Value {
+ v := i.LookupDef("#S")
+ f, _ := v.LookupField("b")
+ v, _ = f.Value.Elem()
+ _, a := v.Expr()
+ return a[0]
+ },
+ want: "#T",
+ }, {
+ input: `
#a: {
#T: {b: 3}
close({}) | close({c: #T}) | close({d: string})
@@ -2724,6 +2745,15 @@
}, {
input: `v: "Hello, \(x)! Welcome to \(place)", place: string, x: string`,
want: `\()("Hello, " .(<0> "x") "! Welcome to " .(<0> "place") "")`,
+ }, {
+ input: `v: { a, b: 1 }, a: 2`,
+ want: `&(<0>{b: 1} .(<0> "a"))`,
+ }, {
+ input: `v: { {c: a}, b: a }, a: int`,
+ want: `&(<0>{b: <1>.a} <0>{c: <1>.a})`,
+ }, {
+ input: `v: [...number] | *[1, 2, 3]`,
+ want: `([, ...number] | *[1,2,3])`,
}}
for _, tc := range testCases {
t.Run(tc.input, func(t *testing.T) {