Skip to content

Commit 6912a11

Browse files
committed
cue: use fmt instead of MarhalJSON in TestUnifyAccept
This allows us to test non-concrete values as well, which we intend to so soon. Used CUE_UPDATE=1 to update the tests. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ic55738f34fb1ed3cebb08dd9f7c020a37f1e5d96 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1212212 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 2402ef3 commit 6912a11

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

cue/types_test.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -2340,13 +2340,19 @@ func TestUnifyAccept(t *testing.T) {
23402340
want: `"foo"`,
23412341
}, {
23422342
value: `#v: {a: "foo"}, #w: {b: 4}, #accept: {a: string, b: int}`,
2343-
want: `{"a":"foo","b":4}`,
2343+
want: `{
2344+
a: "foo"
2345+
b: 4
2346+
}`,
23442347
}, {
23452348
value: `#v: [string, 4], #w: ["foo", 4], #accept: [string, int, ...]`,
2346-
want: `["foo",4]`,
2349+
want: `["foo", 4]`,
23472350
}, {
23482351
value: `#v: {a: string, b: 1, _#hidden: int}, #w: {a: "foo"}, #accept: {...}`,
2349-
want: `{"a":"foo","b":1}`,
2352+
want: `{
2353+
a: "foo"
2354+
b: 1
2355+
}`,
23502356
}, {
23512357
// Issue #2325: let should not result in a closedness error.
23522358
value: `#accept: {
@@ -2364,7 +2370,9 @@ func TestUnifyAccept(t *testing.T) {
23642370
#w: {b:1}
23652371
#accept: {...}
23662372
`,
2367-
want: `{"b":1}`,
2373+
want: `{
2374+
b: 1
2375+
}`,
23682376
}}
23692377

23702378
matrix := cuetdtest.FullMatrix
@@ -2375,14 +2383,17 @@ func TestUnifyAccept(t *testing.T) {
23752383
matrix.Do(t, func(t *testing.T, m *cuetdtest.M) {
23762384
tdtest.Run(t, testCases, func(t *cuetest.T, tc *testCase) {
23772385
v := getValue(m, tc.value)
2386+
if err := v.Err(); err != nil {
2387+
t.Fatal(err)
2388+
}
23782389
x := v.LookupPath(cue.ParsePath("#v"))
23792390
y := v.LookupPath(cue.ParsePath("#w"))
23802391
a := v.LookupPath(cue.ParsePath("#accept"))
2381-
b, err := x.UnifyAccept(y, a).MarshalJSON()
2382-
if err != nil {
2392+
z := x.UnifyAccept(y, a)
2393+
if err := z.Err(); err != nil {
23832394
t.Fatal(err)
23842395
}
2385-
t.Equal(string(b), tc.want)
2396+
t.Equal(fmt.Sprint(z), tc.want)
23862397
})
23872398
})
23882399
}

0 commit comments

Comments
 (0)