Skip to content

Commit

Permalink
cue: add test cases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mpvl committed Jul 17, 2020
1 parent f0f62b8 commit 1784fca
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cue/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func TestValueType(t *testing.T) {
incompleteKind: ListKind,
concrete: true,
closed: true,
}, {
value: `v: [...int]`,
kind: BottomKind,
incompleteKind: ListKind,
concrete: false,
}, {
value: `v: {a: int, b: [1][a]}.b`,
kind: BottomKind,
Expand Down Expand Up @@ -2384,6 +2389,22 @@ func TestPathCorrection(t *testing.T) {
return a[0]
},
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: {
Expand Down Expand Up @@ -2724,6 +2745,15 @@ func TestExpr(t *testing.T) {
}, {
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) {
Expand Down

0 comments on commit 1784fca

Please sign in to comment.