this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue: add test case for decoding incomplete value

We should be able to decode incomplete values
into Go structs, because those values might yet
become complete.

This shows that it's an error currently. A subsequent
CL will fix that.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I55cd0f92c92d663580bc90e40d54a230c7b73fea
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229424
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+23
+23
cue/decode_test.go
··· 383 383 }) 384 384 } 385 385 386 + func TestDecodeIncompleteValueIntoCUEValue(t *testing.T) { 387 + cuetdtest.FullMatrix.Do(t, func(t *testing.T, m *cuetdtest.M) { 388 + // We should be able to decode into a CUE value so we can 389 + // decode partially incomplete values into Go. 390 + // This test doesn't fit within the table used by TestDecode 391 + // because cue values aren't easily comparable with cmp.Diff. 392 + var st struct { 393 + Field cue.Value `json:"field"` 394 + } 395 + err := getValue(m, ` 396 + field: { 397 + #x: _ 398 + a: #x.b 399 + } 400 + field: string | { 401 + #x!: {...} 402 + ... 403 + } 404 + `).Decode(&st) 405 + qt.Assert(t, qt.ErrorMatches(err, `field: 2 errors in empty disjunction:.*`)) 406 + }) 407 + } 408 + 386 409 type StructWithFloat struct { 387 410 Value *big.Float 388 411 }