cuelang.org/go@v0.13.0/pkg/encoding/yaml/testdata/validate.txtar (about) 1 -- in.cue -- 2 import "encoding/yaml" 3 4 #test: { 5 fn: _ 6 7 data1: "a: 2" 8 t1: [string]: data1 9 t1: ok1: fn({a!: int} | {b!: int}) // TODO: filter unsatisfied required fields. 10 t1: ok2: fn(close({a: int}) | close({b: int})) 11 12 #A: {a: int} 13 #B: {b: int} 14 t1: ok3: fn(#A | #B) 15 16 data2: "'foo'" 17 t2: [string]: data2 18 t2: ok1: fn(*int | string) 19 t2: ok2: fn(string) 20 } 21 22 validate: #test & { 23 fn: yaml.Validate 24 25 // TODO: fix this test: the second disjunct should be eliminated, so there 26 // should not be a concreteness error. 27 t1: _ 28 } 29 30 validatePartial: #test & { 31 fn: yaml.ValidatePartial 32 } 33 -- diff/todo -- 34 missing position 35 -- out/yaml -- 36 Errors: 37 #test.t1.ok1: cannot call non-function fn (type _): 38 ./in.cue:8:11 39 validate.t1.ok1: invalid value "a: 2" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: incomplete value {a:2} | {a:2,b!:int}: 40 ./in.cue:8:11 41 ./in.cue:6:9 42 ./in.cue:7:16 43 #test.t1.ok2: cannot call non-function fn (type _): 44 ./in.cue:9:11 45 #test.t1.ok3: cannot call non-function fn (type _): 46 ./in.cue:13:11 47 #test.t2.ok1: cannot call non-function fn (type _): 48 ./in.cue:17:11 49 #test.t2.ok2: cannot call non-function fn (type _): 50 ./in.cue:18:11 51 52 Result: 53 import "encoding/yaml" 54 55 #test: { 56 fn: _ 57 data1: "a: 2" 58 t1: { 59 ok1: _|_ // #test.t1.ok1: cannot call non-function fn (type _) 60 ok2: _|_ // #test.t1.ok2: cannot call non-function fn (type _) 61 ok3: _|_ // #test.t1.ok3: cannot call non-function fn (type _) 62 } 63 #A: { 64 a: int 65 } 66 #B: { 67 b: int 68 } 69 data2: "'foo'" 70 t2: { 71 ok1: _|_ // #test.t2.ok1: cannot call non-function fn (type _) 72 ok2: _|_ // #test.t2.ok2: cannot call non-function fn (type _) 73 } 74 } 75 validate: { 76 fn: yaml.Validate 77 data1: "a: 2" 78 79 // TODO: fix this test: the second disjunct should be eliminated, so there 80 // should not be a concreteness error. 81 t1: { 82 ok1: _|_ // validate.t1.ok1: invalid value "a: 2" (does not satisfy encoding/yaml.Validate): validate.t1.ok1: error in call to encoding/yaml.Validate: validate.t1.ok1: incomplete value {a:2} | {a:2,b!:int} 83 ok2: "a: 2" 84 ok3: "a: 2" 85 } 86 #A: { 87 a: int 88 } 89 #B: { 90 b: int 91 } 92 data2: "'foo'" 93 t2: { 94 ok1: "'foo'" 95 ok2: "'foo'" 96 } 97 } 98 validatePartial: { 99 fn: yaml.ValidatePartial 100 data1: "a: 2" 101 t1: { 102 ok1: "a: 2" 103 ok2: "a: 2" 104 ok3: "a: 2" 105 } 106 #A: { 107 a: int 108 } 109 #B: { 110 b: int 111 } 112 data2: "'foo'" 113 t2: { 114 ok1: "'foo'" 115 ok2: "'foo'" 116 } 117 }