this repo has no description
0
fork

Configure Feed

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

cue/testdata: convert definitions/ and comprehensions/ tests

Convert remaining definitions/ test files to inline @test annotation
format. The comprehensions/iferror.txtar gets corrected error positions
(line offsets shifted after adding the _name test field), and
definitions/comprehensions.txtar is fully converted.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ic8294c43a5ef7c038c4691e7ec076925ac6b540a
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235358
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+1217 -6434
+56 -234
cue/testdata/comprehensions/iferror.txtar
··· 1 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 2 1 -- in.cue -- 3 2 a: {b: 2, c: int} 4 3 ··· 6 5 if a.b { 7 6 2 8 7 } 8 + @test(err, code=eval, contains="cannot use 2 (type int) as type bool", pos=[1:2, -2:8]) 9 9 } 10 10 11 11 wrongType: { 12 12 if a.c { 13 13 2 14 14 } 15 + @test(err, code=eval, contains="cannot use int (type int) as type bool", pos=[1:2, -9:14]) 15 16 } 16 17 17 - incomplete: { 18 + incomplete: err1: { 18 19 if a.d { 19 20 2 20 21 } 22 + @test(err, code=incomplete, contains="undefined field: d", pos=[1:7]) 21 23 } 22 - 23 - incomplete: { 24 + incomplete: err2: { 24 25 list: [1, 2, 3] 25 26 for x in list if a.d { 26 27 x 27 28 } 29 + @test(err, code=incomplete, contains="undefined field: d", pos=[2:21]) 28 30 } 29 31 30 - // Issue #809 32 + // issue809: Tests that comprehension guards using `!= _|_` work correctly 33 + // when the guarded field has a default value. In both cases below the field 34 + // being tested is non-bottom (it carries a default), so the guard should 35 + // pass and the comprehension should yield the entry. 36 + // https://cuelang.org/issue/809 31 37 useDefault: { 32 38 a: { 33 39 x: *"foo" | string ··· 48 54 foo: [ 49 55 for _, a in s if a.b != _|_ {a}, 50 56 ] 57 + 58 + @test(eq, { 59 + #A: { 60 + a: string 61 + b: string 62 + } 63 + s: bar: { 64 + a: "bar" 65 + b: *"bar" | string 66 + } 67 + foo: [{ 68 + a: "bar" 69 + b: *"bar" | string 70 + }] 71 + }) 51 72 } 52 73 } 53 74 ··· 71 92 patchs: _ 72 93 } 73 94 } 95 + @test(err, code=eval, contains="conflicting values", pos=[9:8, 11:11, 12:3]) 74 96 } 97 + -- out/errors.txt -- 98 + [eval] wrongConcreteType: cannot use 2 (type int) as type bool: 99 + ./in.cue:4:2 100 + ./in.cue:1:8 101 + [eval] wrongType: cannot use int (type int) as type bool: 102 + ./in.cue:11:2 103 + ./in.cue:1:14 104 + [incomplete] incomplete.err1: undefined field: d: 105 + ./in.cue:18:7 106 + [incomplete] incomplete.err2: undefined field: d: 107 + ./in.cue:25:21 108 + [eval] issue1972.err1: conflicting values {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} and [...{}] (mismatched types struct and list): 109 + ./in.cue:86:8 110 + ./in.cue:88:11 111 + ./in.cue:89:3 75 112 -- out/compile -- 76 113 --- in.cue 77 114 { ··· 90 127 } 91 128 } 92 129 incomplete: { 93 - if 〈1;a〉.d { 94 - 2 130 + err1: { 131 + if 〈2;a〉.d { 132 + 2 133 + } 95 134 } 96 135 } 97 136 incomplete: { 98 - list: [ 99 - 1, 100 - 2, 101 - 3, 102 - ] 103 - for _, x in 〈0;list〉 if 〈2;a〉.d { 104 - 〈1;x〉 137 + err2: { 138 + list: [ 139 + 1, 140 + 2, 141 + 3, 142 + ] 143 + for _, x in 〈0;list〉 if 〈3;a〉.d { 144 + 〈1;x〉 145 + } 105 146 } 106 147 } 107 148 useDefault: { ··· 163 204 Notifications: 2 164 205 165 206 NumCloseIDs: 26 166 - -- out/evalalpha -- 167 - Errors: 168 - issue1972.err1: conflicting values {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} and [...{}] (mismatched types struct and list): 169 - ./in.cue:64:8 170 - ./in.cue:66:11 171 - ./in.cue:67:3 172 - wrongConcreteType: cannot use 2 (type int) as type bool: 173 - ./in.cue:4:2 174 - ./in.cue:1:8 175 - wrongType: cannot use int (type int) as type bool: 176 - ./in.cue:10:2 177 - ./in.cue:1:14 178 - 179 - Result: 180 - (_|_){ 181 - // [eval] 182 - a: (struct){ 183 - b: (int){ 2 } 184 - c: (int){ int } 185 - } 186 - wrongConcreteType: (_|_){ 187 - // [eval] wrongConcreteType: cannot use 2 (type int) as type bool: 188 - // ./in.cue:4:2 189 - // ./in.cue:1:8 190 - } 191 - wrongType: (_|_){ 192 - // [eval] wrongType: cannot use int (type int) as type bool: 193 - // ./in.cue:10:2 194 - // ./in.cue:1:14 195 - } 196 - incomplete: (_|_){ 197 - // [incomplete] incomplete: undefined field: d: 198 - // ./in.cue:16:7 199 - // incomplete: undefined field: d: 200 - // ./in.cue:23:21 201 - list: (#list){ 202 - 0: (int){ 1 } 203 - 1: (int){ 2 } 204 - 2: (int){ 3 } 205 - } 206 - } 207 - useDefault: (struct){ 208 - a: (struct){ 209 - x: (string){ |(*(string){ "foo" }, (string){ string }) } 210 - y: (string){ |(*(string){ "foo" }, (string){ string }) } 211 - } 212 - issue809: (struct){ 213 - #A: (#struct){ 214 - a: (string){ string } 215 - b: (string){ string } 216 - } 217 - s: (struct){ 218 - bar: (#struct){ 219 - a: (string){ "bar" } 220 - b: (string){ |(*(string){ "bar" }, (string){ string }) } 221 - } 222 - } 223 - foo: (#list){ 224 - 0: (#struct){ 225 - a: (string){ "bar" } 226 - b: (string){ |(*(string){ "bar" }, (string){ string }) } 227 - } 228 - } 229 - } 230 - } 231 - issue1972: (_|_){ 232 - // [eval] 233 - err1: (_|_){ 234 - // [eval] issue1972.err1: conflicting values {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} and [...{}] (mismatched types struct and list): 235 - // ./in.cue:64:8 236 - // ./in.cue:66:11 237 - // ./in.cue:67:3 238 - #patchs: (_|_){// [] 239 - } 240 - #someCondition: (_){ _ } 241 - someCondition: (_){ _ } 242 - patchs: (_|_){// [ 243 - // ...{}, 244 - // ][e] & if 〈0;someCondition〉 _ 245 - } 246 - } 247 - } 248 - } 249 - -- diff/-out/evalalpha<==>+out/eval -- 250 - diff old new 251 - --- old 252 - +++ new 253 - @@ -1,7 +1,8 @@ 254 - Errors: 255 - -issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct): 256 - - ./in.cue:54:12 257 - - ./in.cue:61:8 258 - +issue1972.err1: conflicting values {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} and [...{}] (mismatched types struct and list): 259 - + ./in.cue:64:8 260 - + ./in.cue:66:11 261 - + ./in.cue:67:3 262 - wrongConcreteType: cannot use 2 (type int) as type bool: 263 - ./in.cue:4:2 264 - ./in.cue:1:8 265 - @@ -8,8 +9,6 @@ 266 - wrongType: cannot use int (type int) as type bool: 267 - ./in.cue:10:2 268 - ./in.cue:1:14 269 - -issue1972.err1: invalid list index someCondition (type string): 270 - - ./in.cue:65:6 271 - 272 - Result: 273 - (_|_){ 274 - @@ -66,17 +65,18 @@ 275 - issue1972: (_|_){ 276 - // [eval] 277 - err1: (_|_){ 278 - - // [eval] issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct): 279 - - // ./in.cue:54:12 280 - - // ./in.cue:61:8 281 - - // issue1972.err1: invalid list index someCondition (type string): 282 - - // ./in.cue:65:6 283 - - #patchs: (#list){ 284 - - } 285 - - someCondition: (_){ _ } 286 - - patchs: (list){ 287 - + // [eval] issue1972.err1: conflicting values {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} and [...{}] (mismatched types struct and list): 288 - + // ./in.cue:64:8 289 - + // ./in.cue:66:11 290 - + // ./in.cue:67:3 291 - + #patchs: (_|_){// [] 292 - } 293 - #someCondition: (_){ _ } 294 - + someCondition: (_){ _ } 295 - + patchs: (_|_){// [ 296 - + // ...{}, 297 - + // ][e] & if 〈0;someCondition〉 _ 298 - + } 299 - } 300 - } 301 - } 302 - -- diff/todo/p2 -- 207 + -- out/diff-v2-v3.txt -- 303 208 issue1972: "field not allowed" are somewhat correct (it is also a list), but 304 209 are already covered by the other error message and should be elided. 305 210 This may lead to a large number of errors otherwise. 306 - -- out/eval -- 307 - Errors: 308 - issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct): 309 - ./in.cue:54:12 310 - ./in.cue:61:8 311 - wrongConcreteType: cannot use 2 (type int) as type bool: 312 - ./in.cue:4:2 313 - ./in.cue:1:8 314 - wrongType: cannot use int (type int) as type bool: 315 - ./in.cue:10:2 316 - ./in.cue:1:14 317 - issue1972.err1: invalid list index someCondition (type string): 318 - ./in.cue:65:6 319 - 320 - Result: 321 - (_|_){ 322 - // [eval] 323 - a: (struct){ 324 - b: (int){ 2 } 325 - c: (int){ int } 326 - } 327 - wrongConcreteType: (_|_){ 328 - // [eval] wrongConcreteType: cannot use 2 (type int) as type bool: 329 - // ./in.cue:4:2 330 - // ./in.cue:1:8 331 - } 332 - wrongType: (_|_){ 333 - // [eval] wrongType: cannot use int (type int) as type bool: 334 - // ./in.cue:10:2 335 - // ./in.cue:1:14 336 - } 337 - incomplete: (_|_){ 338 - // [incomplete] incomplete: undefined field: d: 339 - // ./in.cue:16:7 340 - // incomplete: undefined field: d: 341 - // ./in.cue:23:21 342 - list: (#list){ 343 - 0: (int){ 1 } 344 - 1: (int){ 2 } 345 - 2: (int){ 3 } 346 - } 347 - } 348 - useDefault: (struct){ 349 - a: (struct){ 350 - x: (string){ |(*(string){ "foo" }, (string){ string }) } 351 - y: (string){ |(*(string){ "foo" }, (string){ string }) } 352 - } 353 - issue809: (struct){ 354 - #A: (#struct){ 355 - a: (string){ string } 356 - b: (string){ string } 357 - } 358 - s: (struct){ 359 - bar: (#struct){ 360 - a: (string){ "bar" } 361 - b: (string){ |(*(string){ "bar" }, (string){ string }) } 362 - } 363 - } 364 - foo: (#list){ 365 - 0: (#struct){ 366 - a: (string){ "bar" } 367 - b: (string){ |(*(string){ "bar" }, (string){ string }) } 368 - } 369 - } 370 - } 371 - } 372 - issue1972: (_|_){ 373 - // [eval] 374 - err1: (_|_){ 375 - // [eval] issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct): 376 - // ./in.cue:54:12 377 - // ./in.cue:61:8 378 - // issue1972.err1: invalid list index someCondition (type string): 379 - // ./in.cue:65:6 380 - #patchs: (#list){ 381 - } 382 - someCondition: (_){ _ } 383 - patchs: (list){ 384 - } 385 - #someCondition: (_){ _ } 386 - } 387 - } 388 - }
+12 -199
cue/testdata/definitions/026_combined_definitions.txtar
··· 1 1 #name: combined definitions 2 2 #evalPartial 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 3 -- in.cue -- 5 4 // Allow combining of structs within a definition 6 5 #D1: { ··· 9 8 #def: {a: "A"} 10 9 #def: {b: "B"} 11 10 } 12 - 13 - d1: #D1 & {env: c: "C"} 14 - 11 + d1: #D1 & {env: c: "C" } @test(err, at=env.c, code=eval, contains="field not allowed", pos=[0:17]) 15 12 #D2: { 16 13 a: int 17 14 } 18 15 #D2: { 19 16 b: int 20 - } 21 - 17 + } @test(eq, {a: int, b: int}) 22 18 #D3: { 23 19 env: a: "A" 24 20 } 25 21 #D3: { 26 22 env: b: "B" 27 - } 28 - 23 + } @test(eq, { env: { a: "A", b: "B" } }) 29 24 #D4: { 30 25 env: #DC 31 - env: b: int 26 + env: b: int @test(err, code=eval, contains="field not allowed", pos=[0:7]) 32 27 } 33 - 34 28 #DC: {a: int} 29 + -- out/errors.txt -- 30 + [eval] d1.env.c: field not allowed: 31 + ./in.cue:8:17 32 + [eval] #D4.env.b: field not allowed: 33 + ./in.cue:23:7 35 34 -- out/compile -- 36 35 --- in.cue 37 36 { ··· 86 85 Reused: 17 87 86 Allocs: 12 88 87 Retain: 0 89 - 90 88 Unifications: 29 91 89 Conjuncts: 41 92 90 Disjuncts: 0 93 - 94 91 NumCloseIDs: 2 95 - -- out/evalalpha -- 96 - Errors: 97 - #D4.env.b: field not allowed: 98 - ./in.cue:27:7 99 - d1.env.c: field not allowed: 100 - ./in.cue:9:17 101 - 102 - Result: 103 - (_|_){ 104 - // [eval] 105 - #D1: (#struct){ 106 - env: (#struct){ 107 - a: (string){ "A" } 108 - b: (string){ "B" } 109 - } 110 - #def: (#struct){ 111 - a: (string){ "A" } 112 - b: (string){ "B" } 113 - } 114 - } 115 - d1: (_|_){ 116 - // [eval] 117 - env: (_|_){ 118 - // [eval] 119 - c: (_|_){ 120 - // [eval] d1.env.c: field not allowed: 121 - // ./in.cue:9:17 122 - } 123 - a: (string){ "A" } 124 - b: (string){ "B" } 125 - } 126 - #def: (#struct){ 127 - a: (string){ "A" } 128 - b: (string){ "B" } 129 - } 130 - } 131 - #D2: (#struct){ 132 - a: (int){ int } 133 - b: (int){ int } 134 - } 135 - #D3: (#struct){ 136 - env: (#struct){ 137 - a: (string){ "A" } 138 - b: (string){ "B" } 139 - } 140 - } 141 - #D4: (_|_){ 142 - // [eval] 143 - env: (_|_){ 144 - // [eval] 145 - b: (_|_){ 146 - // [eval] #D4.env.b: field not allowed: 147 - // ./in.cue:27:7 148 - } 149 - a: (int){ int } 150 - } 151 - } 152 - #DC: (#struct){ 153 - a: (int){ int } 154 - } 155 - } 156 - -- diff/-out/evalalpha<==>+out/eval -- 157 - diff old new 158 - --- old 159 - +++ new 160 - @@ -1,12 +1,7 @@ 161 - Errors: 162 - #D4.env.b: field not allowed: 163 - - ./in.cue:26:7 164 - ./in.cue:27:7 165 - - ./in.cue:30:6 166 - d1.env.c: field not allowed: 167 - - ./in.cue:3:7 168 - - ./in.cue:4:7 169 - - ./in.cue:9:5 170 - ./in.cue:9:17 171 - 172 - Result: 173 - @@ -26,15 +21,12 @@ 174 - // [eval] 175 - env: (_|_){ 176 - // [eval] 177 - - a: (string){ "A" } 178 - - b: (string){ "B" } 179 - c: (_|_){ 180 - // [eval] d1.env.c: field not allowed: 181 - - // ./in.cue:3:7 182 - - // ./in.cue:4:7 183 - - // ./in.cue:9:5 184 - // ./in.cue:9:17 185 - } 186 - + a: (string){ "A" } 187 - + b: (string){ "B" } 188 - } 189 - #def: (#struct){ 190 - a: (string){ "A" } 191 - @@ -55,13 +47,11 @@ 192 - // [eval] 193 - env: (_|_){ 194 - // [eval] 195 - - a: (int){ int } 196 - b: (_|_){ 197 - // [eval] #D4.env.b: field not allowed: 198 - - // ./in.cue:26:7 199 - // ./in.cue:27:7 200 - - // ./in.cue:30:6 201 - - } 202 - + } 203 - + a: (int){ int } 204 - } 205 - } 206 - #DC: (#struct){ 207 - -- diff/todo/p2 -- 208 - Missing positions 209 - -- diff/todo/p3 -- 210 - Reordering 211 - -- out/eval -- 212 - Errors: 213 - #D4.env.b: field not allowed: 214 - ./in.cue:26:7 215 - ./in.cue:27:7 216 - ./in.cue:30:6 217 - d1.env.c: field not allowed: 218 - ./in.cue:3:7 219 - ./in.cue:4:7 220 - ./in.cue:9:5 221 - ./in.cue:9:17 222 - 223 - Result: 224 - (_|_){ 225 - // [eval] 226 - #D1: (#struct){ 227 - env: (#struct){ 228 - a: (string){ "A" } 229 - b: (string){ "B" } 230 - } 231 - #def: (#struct){ 232 - a: (string){ "A" } 233 - b: (string){ "B" } 234 - } 235 - } 236 - d1: (_|_){ 237 - // [eval] 238 - env: (_|_){ 239 - // [eval] 240 - a: (string){ "A" } 241 - b: (string){ "B" } 242 - c: (_|_){ 243 - // [eval] d1.env.c: field not allowed: 244 - // ./in.cue:3:7 245 - // ./in.cue:4:7 246 - // ./in.cue:9:5 247 - // ./in.cue:9:17 248 - } 249 - } 250 - #def: (#struct){ 251 - a: (string){ "A" } 252 - b: (string){ "B" } 253 - } 254 - } 255 - #D2: (#struct){ 256 - a: (int){ int } 257 - b: (int){ int } 258 - } 259 - #D3: (#struct){ 260 - env: (#struct){ 261 - a: (string){ "A" } 262 - b: (string){ "B" } 263 - } 264 - } 265 - #D4: (_|_){ 266 - // [eval] 267 - env: (_|_){ 268 - // [eval] 269 - a: (int){ int } 270 - b: (_|_){ 271 - // [eval] #D4.env.b: field not allowed: 272 - // ./in.cue:26:7 273 - // ./in.cue:27:7 274 - // ./in.cue:30:6 275 - } 276 - } 277 - } 278 - #DC: (#struct){ 279 - a: (int){ int } 280 - } 281 - } 92 + -- out/diff-v2-v3.txt -- 93 + Missing positions: v3 reports fewer positions than v2 for "field not allowed" errors. 94 + Reordering: v3 outputs some fields in different order than v2.
+3 -28
cue/testdata/definitions/028_recursive_closing_starting_at_non-definition.txtar
··· 1 + 1 2 #name: recursive closing starting at non-definition 2 3 #evalPartial 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 4 -- in.cue -- 5 5 z: a: { 6 6 #B: { ··· 8 8 c: f: 1 9 9 } 10 10 } 11 - A: z & {a: {#B: {c: e: 2}}} 11 + A: z & {a: {#B: {c: e: 2}}} @test(eq, {a: #B: c: {e: 2, d: 1, f: 1}}) 12 + -- out/errors.txt -- 12 13 -- out/compile -- 13 14 --- in.cue 14 15 { ··· 40 41 Reused: 5 41 42 Allocs: 9 42 43 Retain: 0 43 - 44 44 Unifications: 14 45 45 Conjuncts: 21 46 46 Disjuncts: 0 47 - 48 47 NumCloseIDs: 1 49 - -- out/evalalpha -- 50 - (struct){ 51 - z: (struct){ 52 - a: (struct){ 53 - #B: (#struct){ 54 - c: (#struct){ 55 - d: (int){ 1 } 56 - f: (int){ 1 } 57 - } 58 - } 59 - } 60 - } 61 - A: (struct){ 62 - a: (struct){ 63 - #B: (#struct){ 64 - c: (#struct){ 65 - e: (int){ 2 } 66 - d: (int){ 1 } 67 - f: (int){ 1 } 68 - } 69 - } 70 - } 71 - } 72 - }
+25 -121
cue/testdata/definitions/032_definitions_with_embedding.txtar
··· 1 - #name: definitions with embedding 2 - #evalPartial 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 1 -- in.cue -- 5 2 #E: { 6 3 a: {b: int} ··· 10 7 #E 11 8 a: {c: int} 12 9 b: 3 13 - } 10 + } @test(eq, { 11 + a: {b: int, c: int} 12 + b: 3 13 + }) 14 14 15 15 // adding a field to a nested struct that is closed. 16 - #e1: #S & {a: d: 4} 16 + #e1: #S & {a: d: 4} @test(err, at=a.d, code=eval, 17 + contains="field not allowed", pos=[0:15]) 17 18 18 19 // literal struct not closed until after unification. 19 - #v1: #S & {a: c: 4} 20 + #v1: #S & {a: c: 4} @test(eq, {a: {b: int, c: 4}, b: 3}) 21 + -- out/errors.txt -- 22 + [eval] #e1.a.d: field not allowed: 23 + ./in.cue:15:15 24 + -- out/eval/stats -- 25 + Leaks: 0 26 + Freed: 20 27 + Reused: 10 28 + Allocs: 10 29 + Retain: 0 30 + 31 + Unifications: 20 32 + Conjuncts: 36 33 + Disjuncts: 0 34 + 35 + NumCloseIDs: 11 20 36 -- out/compile -- 21 37 --- in.cue 22 38 { ··· 43 59 } 44 60 }) 45 61 } 46 - -- out/eval/stats -- 47 - Leaks: 0 48 - Freed: 20 49 - Reused: 10 50 - Allocs: 10 51 - Retain: 0 52 - 53 - Unifications: 20 54 - Conjuncts: 36 55 - Disjuncts: 0 56 - 57 - NumCloseIDs: 11 62 + -- out/diff-v2-v3.txt -- 63 + Reordering / missing positions. 64 + Verdict: worsening -- v3 reports fewer error positions; field reordering. 58 65 -- out/evalalpha -- 59 66 Errors: 60 67 #e1.a.d: field not allowed: ··· 96 103 b: (int){ 3 } 97 104 } 98 105 } 99 - -- diff/-out/evalalpha<==>+out/eval -- 100 - diff old new 101 - --- old 102 - +++ new 103 - @@ -1,9 +1,5 @@ 104 - Errors: 105 - #e1.a.d: field not allowed: 106 - - ./in.cue:2:5 107 - - ./in.cue:6:2 108 - - ./in.cue:7:5 109 - - ./in.cue:12:6 110 - ./in.cue:12:15 111 - 112 - Result: 113 - @@ -16,8 +12,8 @@ 114 - } 115 - #S: (#struct){ 116 - a: (#struct){ 117 - - b: (int){ int } 118 - - c: (int){ int } 119 - + c: (int){ int } 120 - + b: (int){ int } 121 - } 122 - b: (int){ 3 } 123 - } 124 - @@ -25,23 +21,19 @@ 125 - // [eval] 126 - a: (_|_){ 127 - // [eval] 128 - - b: (int){ int } 129 - - c: (int){ int } 130 - d: (_|_){ 131 - // [eval] #e1.a.d: field not allowed: 132 - - // ./in.cue:2:5 133 - - // ./in.cue:6:2 134 - - // ./in.cue:7:5 135 - - // ./in.cue:12:6 136 - // ./in.cue:12:15 137 - } 138 - + c: (int){ int } 139 - + b: (int){ int } 140 - } 141 - b: (int){ 3 } 142 - } 143 - #v1: (#struct){ 144 - a: (#struct){ 145 - - b: (int){ int } 146 - c: (int){ 4 } 147 - + b: (int){ int } 148 - } 149 - b: (int){ 3 } 150 - } 151 - -- diff/todo/p2 -- 152 - Reordering / missing positions. 153 - -- out/eval -- 154 - Errors: 155 - #e1.a.d: field not allowed: 156 - ./in.cue:2:5 157 - ./in.cue:6:2 158 - ./in.cue:7:5 159 - ./in.cue:12:6 160 - ./in.cue:12:15 161 - 162 - Result: 163 - (_|_){ 164 - // [eval] 165 - #E: (#struct){ 166 - a: (#struct){ 167 - b: (int){ int } 168 - } 169 - } 170 - #S: (#struct){ 171 - a: (#struct){ 172 - b: (int){ int } 173 - c: (int){ int } 174 - } 175 - b: (int){ 3 } 176 - } 177 - #e1: (_|_){ 178 - // [eval] 179 - a: (_|_){ 180 - // [eval] 181 - b: (int){ int } 182 - c: (int){ int } 183 - d: (_|_){ 184 - // [eval] #e1.a.d: field not allowed: 185 - // ./in.cue:2:5 186 - // ./in.cue:6:2 187 - // ./in.cue:7:5 188 - // ./in.cue:12:6 189 - // ./in.cue:12:15 190 - } 191 - } 192 - b: (int){ 3 } 193 - } 194 - #v1: (#struct){ 195 - a: (#struct){ 196 - b: (int){ int } 197 - c: (int){ 4 } 198 - } 199 - b: (int){ 3 } 200 - } 201 - }
+30 -112
cue/testdata/definitions/033_Issue_#153.txtar
··· 1 - #name: Issue #153 2 - #evalFull 3 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 1 + # Tests that a comprehension-generated struct merged into a list element 2 + # constrained by a closed definition correctly rejects fields not declared 3 + # in the definition. Fields introduced via comprehension inside a list 4 + # literal should still be subject to closedness checks. 5 + # Issue: https://cuelang.org/issue/153 4 6 -- in.cue -- 5 7 Foo: { 6 8 listOfCloseds: [...#Closed] ··· 11 13 } 12 14 13 15 Junk: { 14 - b: 2 16 + b: 2 @test(eq, 2) 15 17 } 16 18 17 19 Foo & { ··· 21 23 } 22 24 }] 23 25 } 26 + @test(eq, { 27 + Foo: listOfCloseds: [] 28 + #Closed: a: int | *0 29 + Junk: b: 2 30 + listOfCloseds: _|_ @test(err, at=0.b, code=eval, 31 + hint="considerably more positions could be useful", 32 + contains="field not allowed", pos=[16:4]) 33 + }) 34 + -- out/errors.txt -- 35 + [eval] listOfCloseds.0.b: field not allowed: 36 + ./in.cue:16:4 37 + -- out/eval/stats -- 38 + Leaks: 0 39 + Freed: 15 40 + Reused: 5 41 + Allocs: 10 42 + Retain: 0 43 + Unifications: 11 44 + Conjuncts: 22 45 + Disjuncts: 4 46 + Notifications: 1 47 + NumCloseIDs: 5 24 48 -- out/compile -- 25 49 --- in.cue 26 50 { ··· 45 69 ] 46 70 }) 47 71 } 48 - -- out/eval/stats -- 49 - Leaks: 0 50 - Freed: 15 51 - Reused: 5 52 - Allocs: 10 53 - Retain: 0 54 - 55 - Unifications: 11 56 - Conjuncts: 22 57 - Disjuncts: 4 58 - Notifications: 1 59 - 60 - NumCloseIDs: 5 61 - -- out/evalalpha -- 62 - Errors: 72 + -- out/diff-v2-v3.txt -- 73 + missing error positions: v3 reports fewer positions than v2. 63 74 listOfCloseds.0.b: field not allowed: 64 - ./in.cue:16:4 65 - 66 - Result: 67 - (_|_){ 68 - // [eval] 69 - Foo: (struct){ 70 - listOfCloseds: (list){ 71 - } 72 - } 73 - #Closed: (#struct){ 74 - a: (int){ |(*(int){ 0 }, (int){ int }) } 75 - } 76 - Junk: (struct){ 77 - b: (int){ 2 } 78 - } 79 - listOfCloseds: (_|_){ 80 - // [eval] 81 - 0: (_|_){ 82 - // [eval] 83 - a: (int){ |(*(int){ 0 }, (int){ int }) } 84 - b: (_|_){ 85 - // [eval] listOfCloseds.0.b: field not allowed: 86 - // ./in.cue:16:4 87 - } 88 - } 89 - } 90 - } 91 - -- diff/-out/evalalpha<==>+out/eval -- 92 - diff old new 93 - --- old 94 - +++ new 95 - @@ -1,11 +1,5 @@ 96 - Errors: 97 - listOfCloseds.0.b: field not allowed: 98 75 - ./in.cue:2:18 99 76 - ./in.cue:2:21 100 77 - ./in.cue:5:10 ··· 102 79 - ./in.cue:14:18 103 80 - ./in.cue:15:3 104 81 ./in.cue:16:4 105 - 106 - Result: 107 - @@ -28,12 +22,6 @@ 108 - a: (int){ |(*(int){ 0 }, (int){ int }) } 109 - b: (_|_){ 110 - // [eval] listOfCloseds.0.b: field not allowed: 111 - - // ./in.cue:2:18 112 - - // ./in.cue:2:21 113 - - // ./in.cue:5:10 114 - - // ./in.cue:13:1 115 - - // ./in.cue:14:18 116 - - // ./in.cue:15:3 117 - // ./in.cue:16:4 118 - } 119 - } 120 - -- diff/todo/p3 -- 121 - missing error positions 122 - -- out/eval -- 123 - Errors: 124 - listOfCloseds.0.b: field not allowed: 125 - ./in.cue:2:18 126 - ./in.cue:2:21 127 - ./in.cue:5:10 128 - ./in.cue:13:1 129 - ./in.cue:14:18 130 - ./in.cue:15:3 131 - ./in.cue:16:4 132 - 133 - Result: 134 - (_|_){ 135 - // [eval] 136 - Foo: (struct){ 137 - listOfCloseds: (list){ 138 - } 139 - } 140 - #Closed: (#struct){ 141 - a: (int){ |(*(int){ 0 }, (int){ int }) } 142 - } 143 - Junk: (struct){ 144 - b: (int){ 2 } 145 - } 146 - listOfCloseds: (_|_){ 147 - // [eval] 148 - 0: (_|_){ 149 - // [eval] 150 - a: (int){ |(*(int){ 0 }, (int){ int }) } 151 - b: (_|_){ 152 - // [eval] listOfCloseds.0.b: field not allowed: 153 - // ./in.cue:2:18 154 - // ./in.cue:2:21 155 - // ./in.cue:5:10 156 - // ./in.cue:13:1 157 - // ./in.cue:14:18 158 - // ./in.cue:15:3 159 - // ./in.cue:16:4 160 - } 161 - } 162 - } 163 - }
+5 -16
cue/testdata/definitions/036_optionals_in_open_structs.txtar
··· 1 - #name: optionals in open structs 2 - #evalFull 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 1 -- in.cue -- 5 2 A: { 6 3 [=~"^[a-s]*$"]: int ··· 9 6 [=~"^[m-z]*$"]: int 10 7 } 11 8 #C: {A & B} 12 - c: #C & {aaa: 3} 9 + c: #C & {aaa: 3} @test(eq, { 10 + [=~"^[a-s]*$"]: int 11 + [=~"^[m-z]*$"]: int 12 + aaa: 3 13 + }) 13 14 -- out/compile -- 14 15 --- in.cue 15 16 { ··· 38 39 Disjuncts: 0 39 40 40 41 NumCloseIDs: 9 41 - -- out/evalalpha -- 42 - (struct){ 43 - A: (struct){ 44 - } 45 - B: (struct){ 46 - } 47 - #C: (#struct){ 48 - } 49 - c: (#struct){ 50 - aaa: (int){ 3 } 51 - } 52 - }
+13 -146
cue/testdata/definitions/037_closing_with_comprehensions.txtar
··· 1 1 #name: closing with comprehensions 2 2 #evalPartial 3 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 4 3 -- in.cue -- 5 - #A: {f1: int, f2: int} 4 + #A: {f1: int, f2: int} @test(eq, {f1: int, f2: int}) @test(closed) 6 5 7 6 for k, v in {f3: int} { 8 7 a: #A & {"\(k)": v} 9 8 } 9 + @test(err, at=a.f3, code=eval, contains="field not allowed", pos=[-2:11]) 10 10 11 11 #B: { 12 12 for k, v in {f1: int} { 13 13 "\(k)": v 14 14 } 15 - } 15 + } @test(eq, { f1: int }) 16 16 17 17 #C: { 18 18 f1: _ 19 19 for k, v in {f1: int} { 20 20 "\(k)": v 21 21 } 22 - } 22 + } @test(eq, { f1: int }) @test(closed) @test(allows=false, string) 23 23 24 24 #D: { 25 25 for k, v in {f1: int} { 26 26 "\(k)": v 27 27 } 28 28 ... 29 - } 29 + } @test(eq, { f1: int }) @test(closed) @test(allows, string) 30 30 31 31 #E: #A & { 32 32 for k, v in {f3: int} { 33 33 "\(k)": v 34 34 } 35 - } 35 + } @test(err, at=f3, code=eval, contains="field not allowed", pos=[2:3]) 36 + -- out/errors.txt -- 37 + [eval] a.f3: field not allowed: 38 + ./in.cue:4:11 39 + [eval] #E.f3: field not allowed: 40 + ./in.cue:30:3 36 41 -- out/compile -- 37 42 --- in.cue 38 43 { ··· 90 95 Disjuncts: 0 91 96 92 97 NumCloseIDs: 16 93 - -- out/evalalpha -- 94 - Errors: 95 - #E.f3: field not allowed: 96 - ./in.cue:29:3 97 - a.f3: field not allowed: 98 - ./in.cue:4:11 99 - 100 - Result: 101 - (_|_){ 102 - // [eval] 103 - #A: (#struct){ 104 - f1: (int){ int } 105 - f2: (int){ int } 106 - } 107 - a: (_|_){ 108 - // [eval] 109 - f1: (int){ int } 110 - f2: (int){ int } 111 - f3: (_|_){ 112 - // [eval] a.f3: field not allowed: 113 - // ./in.cue:4:11 114 - } 115 - } 116 - #B: (#struct){ 117 - f1: (int){ int } 118 - } 119 - #C: (#struct){ 120 - f1: (int){ int } 121 - } 122 - #D: (#struct){ 123 - f1: (int){ int } 124 - } 125 - #E: (_|_){ 126 - // [eval] 127 - f1: (int){ int } 128 - f2: (int){ int } 129 - f3: (_|_){ 130 - // [eval] #E.f3: field not allowed: 131 - // ./in.cue:29:3 132 - } 133 - } 134 - } 135 - -- diff/-out/evalalpha<==>+out/eval -- 136 - diff old new 137 - --- old 138 - +++ new 139 - @@ -1,14 +1,7 @@ 140 - Errors: 141 - #E.f3: field not allowed: 142 - - ./in.cue:1:5 143 - - ./in.cue:27:5 144 - - ./in.cue:27:10 145 - - ./in.cue:28:2 146 - ./in.cue:29:3 147 - a.f3: field not allowed: 148 - - ./in.cue:1:5 149 - - ./in.cue:3:1 150 - - ./in.cue:4:5 151 - ./in.cue:4:11 152 - 153 - Result: 154 - @@ -24,9 +17,6 @@ 155 - f2: (int){ int } 156 - f3: (_|_){ 157 - // [eval] a.f3: field not allowed: 158 - - // ./in.cue:1:5 159 - - // ./in.cue:3:1 160 - - // ./in.cue:4:5 161 - // ./in.cue:4:11 162 - } 163 - } 164 - @@ -45,10 +35,6 @@ 165 - f2: (int){ int } 166 - f3: (_|_){ 167 - // [eval] #E.f3: field not allowed: 168 - - // ./in.cue:1:5 169 - - // ./in.cue:27:5 170 - - // ./in.cue:27:10 171 - - // ./in.cue:28:2 172 - // ./in.cue:29:3 173 - } 174 - } 175 - -- diff/todo/p2 -- 176 - error positions 177 - -- out/eval -- 178 - Errors: 179 - #E.f3: field not allowed: 180 - ./in.cue:1:5 181 - ./in.cue:27:5 182 - ./in.cue:27:10 183 - ./in.cue:28:2 184 - ./in.cue:29:3 185 - a.f3: field not allowed: 186 - ./in.cue:1:5 187 - ./in.cue:3:1 188 - ./in.cue:4:5 189 - ./in.cue:4:11 190 - 191 - Result: 192 - (_|_){ 193 - // [eval] 194 - #A: (#struct){ 195 - f1: (int){ int } 196 - f2: (int){ int } 197 - } 198 - a: (_|_){ 199 - // [eval] 200 - f1: (int){ int } 201 - f2: (int){ int } 202 - f3: (_|_){ 203 - // [eval] a.f3: field not allowed: 204 - // ./in.cue:1:5 205 - // ./in.cue:3:1 206 - // ./in.cue:4:5 207 - // ./in.cue:4:11 208 - } 209 - } 210 - #B: (#struct){ 211 - f1: (int){ int } 212 - } 213 - #C: (#struct){ 214 - f1: (int){ int } 215 - } 216 - #D: (#struct){ 217 - f1: (int){ int } 218 - } 219 - #E: (_|_){ 220 - // [eval] 221 - f1: (int){ int } 222 - f2: (int){ int } 223 - f3: (_|_){ 224 - // [eval] #E.f3: field not allowed: 225 - // ./in.cue:1:5 226 - // ./in.cue:27:5 227 - // ./in.cue:27:10 228 - // ./in.cue:28:2 229 - // ./in.cue:29:3 230 - } 231 - } 232 - } 98 + -- out/diff-v2-v3.txt -- 99 + Error positions: v3 reports fewer positions than v2 for the "field not allowed" errors (v2 includes definition site positions, v3 only reports the immediate error site).
+37 -160
cue/testdata/definitions/037_conjunction_of_optional_sets.txtar
··· 1 - #name: conjunction of optional sets 2 - #evalFull 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 1 -- in.cue -- 5 2 #A: { 6 3 [=~"^[a-s]*$"]: int ··· 9 6 [=~"^[m-z]*$"]: int 10 7 } 11 8 12 - #C: #A & #B 13 - c: #C & {aaa: 3} 9 + #C: #A & #B @test(allows, moo) @test(allows=false, QQQ) @test(eq, { 10 + [=~"^[a-s]*$"]: int 11 + [=~"^[m-z]*$"]: int 12 + }) 13 + c: #C 14 + c: {aaa: 3 } @test(err, code=eval, at=aaa, 15 + hint="positions missing", 16 + contains="field not allowed", pos=[in.cue:2:2, 0:5]) 14 17 15 18 #D: {#A & #B} 16 - d: #D & {aaa: 3} 17 - -- out/compile -- 18 - --- in.cue 19 - { 20 - #A: { 21 - [=~"^[a-s]*$"]: int 22 - } 23 - #B: { 24 - [=~"^[m-z]*$"]: int 25 - } 26 - #C: (〈0;#A〉 & 〈0;#B〉) 27 - c: (〈0;#C〉 & { 28 - aaa: 3 29 - }) 30 - #D: { 31 - (〈1;#A〉 & 〈1;#B〉) 32 - } 33 - d: (〈0;#D〉 & { 34 - aaa: 3 35 - }) 36 - } 19 + d: #D 20 + d: {aaa: 3 } @test(err, code=eval, at=aaa, 21 + hint="positions missing", 22 + contains="field not allowed", pos=[in.cue:2:2, 0:5]) 23 + -- out/errors.txt -- 24 + [eval] c.aaa: field not allowed: 25 + ./in.cue:2:2 26 + ./in.cue:13:5 27 + [eval] d.aaa: field not allowed: 28 + ./in.cue:2:2 29 + ./in.cue:19:5 37 30 -- out/eval/stats -- 38 31 Leaks: 0 39 32 Freed: 9 ··· 46 39 Disjuncts: 0 47 40 48 41 NumCloseIDs: 14 49 - -- out/evalalpha -- 50 - Errors: 51 - c.aaa: field not allowed: 52 - ./in.cue:2:2 53 - ./in.cue:9:11 54 - d.aaa: field not allowed: 55 - ./in.cue:2:2 56 - ./in.cue:12:10 57 - 58 - Result: 59 - (_|_){ 60 - // [eval] 61 - #A: (#struct){ 42 + -- out/compile -- 43 + --- in.cue 44 + { 45 + #A: { 46 + [=~"^[a-s]*$"]: int 62 47 } 63 - #B: (#struct){ 48 + #B: { 49 + [=~"^[m-z]*$"]: int 64 50 } 65 - #C: (#struct){ 51 + #C: (〈0;#A〉 & 〈0;#B〉) 52 + c: 〈0;#C〉 53 + c: { 54 + aaa: 3 66 55 } 67 - c: (_|_){ 68 - // [eval] 69 - aaa: (_|_){ 70 - // [eval] c.aaa: field not allowed: 71 - // ./in.cue:2:2 72 - // ./in.cue:9:11 73 - } 56 + #D: { 57 + (〈1;#A〉 & 〈1;#B〉) 74 58 } 75 - #D: (#struct){ 76 - } 77 - d: (_|_){ 78 - // [eval] 79 - aaa: (_|_){ 80 - // [eval] d.aaa: field not allowed: 81 - // ./in.cue:2:2 82 - // ./in.cue:12:10 83 - } 59 + d: 〈0;#D〉 60 + d: { 61 + aaa: 3 84 62 } 85 63 } 86 - -- diff/-out/evalalpha<==>+out/eval -- 87 - diff old new 88 - --- old 89 - +++ new 90 - @@ -1,18 +1,9 @@ 91 - Errors: 92 - c.aaa: field not allowed: 93 - ./in.cue:2:2 94 - - ./in.cue:4:5 95 - - ./in.cue:8:5 96 - - ./in.cue:8:10 97 - - ./in.cue:9:5 98 - ./in.cue:9:11 99 - d.aaa: field not allowed: 100 - ./in.cue:2:2 101 - - ./in.cue:4:5 102 - - ./in.cue:11:5 103 - - ./in.cue:11:6 104 - - ./in.cue:11:11 105 - - ./in.cue:12:4 106 - ./in.cue:12:10 107 - 108 - Result: 109 - @@ -29,10 +20,6 @@ 110 - aaa: (_|_){ 111 - // [eval] c.aaa: field not allowed: 112 - // ./in.cue:2:2 113 - - // ./in.cue:4:5 114 - - // ./in.cue:8:5 115 - - // ./in.cue:8:10 116 - - // ./in.cue:9:5 117 - // ./in.cue:9:11 118 - } 119 - } 120 - @@ -43,11 +30,6 @@ 121 - aaa: (_|_){ 122 - // [eval] d.aaa: field not allowed: 123 - // ./in.cue:2:2 124 - - // ./in.cue:4:5 125 - - // ./in.cue:11:5 126 - - // ./in.cue:11:6 127 - - // ./in.cue:11:11 128 - - // ./in.cue:12:4 129 - // ./in.cue:12:10 130 - } 131 - } 132 - -- diff/todo/p2 -- 133 - Missing positions. 134 - -- out/eval -- 135 - Errors: 136 - c.aaa: field not allowed: 137 - ./in.cue:2:2 138 - ./in.cue:4:5 139 - ./in.cue:8:5 140 - ./in.cue:8:10 141 - ./in.cue:9:5 142 - ./in.cue:9:11 143 - d.aaa: field not allowed: 144 - ./in.cue:2:2 145 - ./in.cue:4:5 146 - ./in.cue:11:5 147 - ./in.cue:11:6 148 - ./in.cue:11:11 149 - ./in.cue:12:4 150 - ./in.cue:12:10 151 - 152 - Result: 153 - (_|_){ 154 - // [eval] 155 - #A: (#struct){ 156 - } 157 - #B: (#struct){ 158 - } 159 - #C: (#struct){ 160 - } 161 - c: (_|_){ 162 - // [eval] 163 - aaa: (_|_){ 164 - // [eval] c.aaa: field not allowed: 165 - // ./in.cue:2:2 166 - // ./in.cue:4:5 167 - // ./in.cue:8:5 168 - // ./in.cue:8:10 169 - // ./in.cue:9:5 170 - // ./in.cue:9:11 171 - } 172 - } 173 - #D: (#struct){ 174 - } 175 - d: (_|_){ 176 - // [eval] 177 - aaa: (_|_){ 178 - // [eval] d.aaa: field not allowed: 179 - // ./in.cue:2:2 180 - // ./in.cue:4:5 181 - // ./in.cue:11:5 182 - // ./in.cue:11:6 183 - // ./in.cue:11:11 184 - // ./in.cue:12:4 185 - // ./in.cue:12:10 186 - } 187 - } 188 - } 64 + -- out/diff-v2-v3.txt -- 65 + Missing positions: v3 reports fewer positions than v2 for the "field not allowed" errors.
+17 -82
cue/testdata/definitions/038_continue_recursive_closing_for_optionals.txtar
··· 1 - #name: continue recursive closing for optionals 2 - #evalFull 3 - #todo:inline: medium — definitions with closedness; check @test(closed) support 4 1 -- in.cue -- 5 2 #S: { 6 3 [string]: {a: int} 7 4 } 8 5 a: #S & { 9 6 v: {b: int} 10 - } 11 - -- out/compile -- 12 - --- in.cue 13 - { 14 - #S: { 15 - [string]: { 16 - a: int 17 - } 18 - } 19 - a: (〈0;#S〉 & { 20 - v: { 21 - b: int 22 - } 23 - }) 24 - } 7 + } @test(err, at=v.b, code=eval, contains="field not allowed", pos=[1:6]) 8 + -- out/errors.txt -- 9 + [eval] a.v.b: field not allowed: 10 + ./in.cue:5:6 25 11 -- out/eval/stats -- 26 12 Leaks: 0 27 13 Freed: 6 ··· 34 20 Disjuncts: 0 35 21 36 22 NumCloseIDs: 1 37 - -- out/evalalpha -- 38 - Errors: 39 - a.v.b: field not allowed: 40 - ./in.cue:5:6 41 - 42 - Result: 43 - (_|_){ 44 - // [eval] 45 - #S: (#struct){ 23 + -- out/compile -- 24 + --- in.cue 25 + { 26 + #S: { 27 + [string]: { 28 + a: int 29 + } 46 30 } 47 - a: (_|_){ 48 - // [eval] 49 - v: (_|_){ 50 - // [eval] 51 - b: (_|_){ 52 - // [eval] a.v.b: field not allowed: 53 - // ./in.cue:5:6 54 - } 55 - a: (int){ int } 31 + a: (〈0;#S〉 & { 32 + v: { 33 + b: int 56 34 } 57 - } 35 + }) 58 36 } 59 - -- diff/-out/evalalpha<==>+out/eval -- 60 - diff old new 61 - --- old 62 - +++ new 63 - @@ -1,7 +1,5 @@ 64 - Errors: 37 + -- out/diff-v2-v3.txt -- 38 + Missing positions: v3 reports fewer positions than v2 for the "field not allowed" error. 65 39 a.v.b: field not allowed: 66 40 - ./in.cue:2:12 67 41 - ./in.cue:4:4 68 42 ./in.cue:5:6 69 - 70 - Result: 71 - @@ -15,8 +13,6 @@ 72 - // [eval] 73 - b: (_|_){ 74 - // [eval] a.v.b: field not allowed: 75 - - // ./in.cue:2:12 76 - - // ./in.cue:4:4 77 - // ./in.cue:5:6 78 - } 79 - a: (int){ int } 80 - -- diff/todo/p2 -- 81 - Missing positions. 82 - -- out/eval -- 83 - Errors: 84 - a.v.b: field not allowed: 85 - ./in.cue:2:12 86 - ./in.cue:4:4 87 - ./in.cue:5:6 88 - 89 - Result: 90 - (_|_){ 91 - // [eval] 92 - #S: (#struct){ 93 - } 94 - a: (_|_){ 95 - // [eval] 96 - v: (_|_){ 97 - // [eval] 98 - b: (_|_){ 99 - // [eval] a.v.b: field not allowed: 100 - // ./in.cue:2:12 101 - // ./in.cue:4:4 102 - // ./in.cue:5:6 103 - } 104 - a: (int){ int } 105 - } 106 - } 107 - }
+6 -22
cue/testdata/definitions/comprehensions.txtar
··· 1 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 2 1 -- in.cue -- 3 2 // Closedness should not be silently swallowed when propagated through 4 3 // comprehensions; fields added via comprehensions should still be checked. ··· 9 8 #cfgs: [{ 10 9 name: "foo" 11 10 }] 11 + _name: #cfgs[0].name 12 12 for cfg in #cfgs { 13 13 files: cfg.nam 14 14 } 15 + @test(err, code=eval, at=files, contains="undefined field: nam", pos=[8:14]) 15 16 } 17 + -- out/errors.txt -- 18 + [eval] issue595.files: undefined field: nam: 19 + ./in.cue:12:14 16 20 -- out/eval/stats -- 17 21 Leaks: 0 18 22 Freed: 6 ··· 25 29 Disjuncts: 0 26 30 27 31 NumCloseIDs: 2 28 - -- out/evalalpha -- 29 - Errors: 30 - issue595.files: undefined field: nam: 31 - ./in.cue:11:14 32 - 33 - Result: 34 - (_|_){ 35 - // [eval] 36 - issue595: (_|_){ 37 - // [eval] 38 - #cfgs: (#list){ 39 - 0: (#struct){ 40 - name: (string){ "foo" } 41 - } 42 - } 43 - files: (_|_){ 44 - // [eval] issue595.files: undefined field: nam: 45 - // ./in.cue:11:14 46 - } 47 - } 48 - } 49 32 -- out/compile -- 50 33 --- in.cue 51 34 { ··· 55 38 name: "foo" 56 39 }, 57 40 ] 41 + _name: 〈0;#cfgs〉[0].name 58 42 for _, cfg in 〈0;#cfgs〉 { 59 43 files: 〈1;cfg〉.nam 60 44 }
+14 -101
cue/testdata/definitions/defembed.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 a: { 4 3 #A 5 4 } 6 5 7 - a: c: 1 6 + a: c: 1 @test(err, code=eval, contains="field not allowed", pos=[0:4]) 8 7 9 8 #A: b: 1 10 9 ··· 13 12 leaf: "leaf value" 14 13 interpolation: "more \(leaf_ref)" 15 14 leaf_ref: leaf 15 + 16 + @test(eq, { 17 + b: 1 18 + leaf: "leaf value" 19 + interpolation: "more leaf value" 20 + leaf_ref: "leaf value" 21 + }) 16 22 } 23 + -- out/errors.txt -- 24 + [eval] a.c: field not allowed: 25 + ./in.cue:5:4 17 26 -- out/eval/stats -- 18 27 Leaks: 0 19 28 Freed: 11 ··· 26 35 Disjuncts: 0 27 36 28 37 NumCloseIDs: 6 29 - -- out/evalalpha -- 30 - Errors: 31 - a.c: field not allowed: 32 - ./in.cue:5:4 33 - 34 - Result: 35 - (_|_){ 36 - // [eval] 37 - a: (_|_){ 38 - // [eval] 39 - c: (_|_){ 40 - // [eval] a.c: field not allowed: 41 - // ./in.cue:5:4 42 - } 43 - b: (int){ 1 } 44 - } 45 - #A: (#struct){ 46 - b: (int){ 1 } 47 - } 48 - b: (#struct){ 49 - leaf: (string){ "leaf value" } 50 - interpolation: (string){ "more leaf value" } 51 - leaf_ref: (string){ "leaf value" } 52 - b: (int){ 1 } 53 - } 54 - } 55 - -- diff/-out/evalalpha<==>+out/eval -- 56 - diff old new 57 - --- old 58 - +++ new 59 - @@ -1,9 +1,6 @@ 60 - Errors: 61 - a.c: field not allowed: 62 - - ./in.cue:1:4 63 - - ./in.cue:2:2 64 - ./in.cue:5:4 65 - - ./in.cue:7:5 66 - 67 - Result: 68 - (_|_){ 69 - @@ -10,22 +7,19 @@ 70 - // [eval] 71 - a: (_|_){ 72 - // [eval] 73 - - b: (int){ 1 } 74 - c: (_|_){ 75 - // [eval] a.c: field not allowed: 76 - - // ./in.cue:1:4 77 - - // ./in.cue:2:2 78 - // ./in.cue:5:4 79 - - // ./in.cue:7:5 80 - } 81 - + b: (int){ 1 } 82 - } 83 - #A: (#struct){ 84 - b: (int){ 1 } 85 - } 86 - b: (#struct){ 87 - - b: (int){ 1 } 88 - leaf: (string){ "leaf value" } 89 - interpolation: (string){ "more leaf value" } 90 - leaf_ref: (string){ "leaf value" } 91 - + b: (int){ 1 } 92 - } 93 - } 94 - -- diff/todo/p2 -- 95 - Missing positions / reordering. 96 - -- out/eval -- 97 - Errors: 98 - a.c: field not allowed: 99 - ./in.cue:1:4 100 - ./in.cue:2:2 101 - ./in.cue:5:4 102 - ./in.cue:7:5 103 - 104 - Result: 105 - (_|_){ 106 - // [eval] 107 - a: (_|_){ 108 - // [eval] 109 - b: (int){ 1 } 110 - c: (_|_){ 111 - // [eval] a.c: field not allowed: 112 - // ./in.cue:1:4 113 - // ./in.cue:2:2 114 - // ./in.cue:5:4 115 - // ./in.cue:7:5 116 - } 117 - } 118 - #A: (#struct){ 119 - b: (int){ 1 } 120 - } 121 - b: (#struct){ 122 - b: (int){ 1 } 123 - leaf: (string){ "leaf value" } 124 - interpolation: (string){ "more leaf value" } 125 - leaf_ref: (string){ "leaf value" } 126 - } 127 - } 128 38 -- out/compile -- 129 39 --- in.cue 130 40 { ··· 144 54 leaf_ref: 〈0;leaf〉 145 55 } 146 56 } 57 + -- out/diff-v2-v3.txt -- 58 + Positions: v3 reports fewer positions than v2 for the "field not allowed" error. 59 + Reordering.
+27 -43
cue/testdata/definitions/dynamic.txtar
··· 1 - #todo:inline: medium — disjunctions; use @test(final) for default selection 2 1 -- in.cue -- 3 2 #A: { 4 3 a: "foo" 5 4 "\(a)": 3 5 + 6 + @test(eq, { 7 + a: "foo" 8 + foo: 3 9 + }) 6 10 } 7 11 #B: a: b: { 8 12 c: string 9 13 d: 2 10 - } 14 + } @test(eq, { 15 + c: string 16 + d: 2 17 + }) 18 + 11 19 #C: a: b: { 12 20 c: *"d" | string 13 21 (c): 2 14 - } 22 + } @test(eq, { 23 + c: *"d" | string 24 + d: 2 25 + }) 15 26 16 - x: #B & #C 27 + x: #B & #C @test(eq, { 28 + a: b: { 29 + c: *"d" | string 30 + d: 2 31 + } 32 + }) 17 33 18 34 -- evalv3regress.cue -- 19 35 chained: x: { 36 + // TODO: add this once the todo is fixed. 37 + // @test(permute) 20 38 (a.b): "foo" 21 39 (x.hello): "true" 22 40 a: b: "hello" 41 + 42 + @test(eq, {a: b: "hello", hello: "foo"}, incorrect, hint="shouldn't foo be in here?") 43 + @test(eq:todo, {a: b: "hello", hello: "foo", foo: "true"}) 23 44 } 24 45 -- out/eval/stats -- 25 46 Leaks: 0 ··· 33 54 Disjuncts: 4 34 55 35 56 NumCloseIDs: 2 36 - -- out/evalalpha -- 37 - (struct){ 38 - chained: (struct){ 39 - x: (struct){ 40 - a: (struct){ 41 - b: (string){ "hello" } 42 - } 43 - hello: (string){ "foo" } 44 - } 45 - } 46 - #A: (#struct){ 47 - a: (string){ "foo" } 48 - foo: (int){ 3 } 49 - } 50 - #B: (#struct){ 51 - a: (#struct){ 52 - b: (#struct){ 53 - c: (string){ string } 54 - d: (int){ 2 } 55 - } 56 - } 57 - } 58 - #C: (#struct){ 59 - a: (#struct){ 60 - b: (#struct){ 61 - c: (string){ |(*(string){ "d" }, (string){ string }) } 62 - d: (int){ 2 } 63 - } 64 - } 65 - } 66 - x: (#struct){ 67 - a: (#struct){ 68 - b: (#struct){ 69 - c: (string){ |(*(string){ "d" }, (string){ string }) } 70 - d: (int){ 2 } 71 - } 72 - } 73 - } 74 - } 57 + -- out/diff-v2-v3.txt -- 58 + Disjunctions with defaults: needs @test(final) for x.a.b.c field. 75 59 -- out/compile -- 76 60 --- evalv3regress.cue 77 61 {
+18 -320
cue/testdata/definitions/embed.txtar
··· 1 - #todo:inline: medium — disjunctions; use @test(final) for default selection 2 1 -- in.cue -- 3 2 deployment: [string]: #Deployment 4 3 5 4 deployment: foo: spec: replicas: 1 5 + 6 + @test(eq, { 7 + [string]: spec: replicas: int 8 + foo: spec: replicas: 1 9 + }, at=deployment) 6 10 7 11 #Deployment: { 8 12 #TypeMeta ··· 16 20 17 21 recloseSimple: { 18 22 #foo: {} 19 - a: {#foo} & {b: int} 23 + a: {#foo} & {b: int} @test(err, at=b, code=eval, contains="field not allowed", pos=[0:15]) 20 24 } 21 25 22 26 // Reclosing ··· 33 37 } 34 38 35 39 z: #a.b 36 - z: d: 3 // don't allow this 40 + z: d: 3 @test(err, code=eval, contains="field not allowed", pos=[0:5]) 37 41 } 38 42 39 43 reclose2: { ··· 48 52 } 49 53 } 50 54 51 - z: a.b 52 - z: d: 3 // allow this 55 + z: a.b @test(eq, { c: int, d: 3 }) 56 + z: d: 3 53 57 } 54 58 55 59 reclose3: { ··· 72 76 x: #A & { 73 77 Name: "a" 74 78 Something: 4 75 - } 79 + } @test(eq, {Name: "a", Something: 4}) 76 80 } 81 + -- out/errors.txt -- 82 + [eval] recloseSimple.a.b: field not allowed: 83 + ./in.cue:22:15 84 + [eval] reclose1.z.d: field not allowed: 85 + ./in.cue:39:5 77 86 -- out/eval/stats -- 78 87 Leaks: 3 79 88 Freed: 62 ··· 91 100 MaxConjunctInfos: 7 92 101 MaxReqSets: 12 93 102 MaxRedirect: 2 94 - -- out/evalalpha -- 95 - Errors: 96 - reclose1.z.d: field not allowed: 97 - ./in.cue:34:5 98 - recloseSimple.a.b: field not allowed: 99 - ./in.cue:17:15 100 - 101 - Result: 102 - (_|_){ 103 - // [eval] 104 - deployment: (struct){ 105 - foo: (#struct){ 106 - spec: (#struct){ 107 - replicas: (int){ 1 } 108 - } 109 - } 110 - } 111 - #Deployment: (#struct){ 112 - spec: ~(#Spec) 113 - } 114 - #Spec: (#struct){ 115 - replicas: (int){ int } 116 - } 117 - #TypeMeta: (#struct){ 118 - } 119 - recloseSimple: (_|_){ 120 - // [eval] 121 - #foo: (#struct){ 122 - } 123 - a: (_|_){ 124 - // [eval] 125 - b: (_|_){ 126 - // [eval] recloseSimple.a.b: field not allowed: 127 - // ./in.cue:17:15 128 - } 129 - } 130 - } 131 - reclose1: (_|_){ 132 - // [eval] 133 - #D: (#struct){ 134 - x: (int){ int } 135 - y: (int){ int } 136 - } 137 - #a: (#struct){ 138 - b: (#struct){ 139 - c: (int){ int } 140 - } 141 - x: (int){ int } 142 - y: (int){ int } 143 - } 144 - z: (_|_){ 145 - // [eval] 146 - d: (_|_){ 147 - // [eval] reclose1.z.d: field not allowed: 148 - // ./in.cue:34:5 149 - } 150 - c: (int){ int } 151 - } 152 - } 153 - reclose2: (struct){ 154 - #D: (#struct){ 155 - x: (int){ int } 156 - y: (int){ int } 157 - } 158 - a: (#struct){ 159 - b: (struct){ 160 - c: (int){ int } 161 - } 162 - x: (int){ int } 163 - y: (int){ int } 164 - } 165 - z: (struct){ 166 - d: (int){ 3 } 167 - c: (int){ int } 168 - } 169 - } 170 - reclose3: (struct){ 171 - #Step: (#struct){ |((#struct){ 172 - Name: (string){ string } 173 - Something: (int){ int } 174 - }, (#struct){ 175 - Name: (string){ string } 176 - Else: (int){ int } 177 - }) } 178 - #Common: (#struct){ 179 - Name: (string){ string } 180 - } 181 - #A: (#struct){ 182 - Something: (int){ int } 183 - Name: (string){ string } 184 - } 185 - #B: (#struct){ 186 - Else: (int){ int } 187 - Name: (string){ string } 188 - } 189 - x: (#struct){ 190 - Name: (string){ "a" } 191 - Something: (int){ 4 } 192 - } 193 - } 194 - } 195 - -- diff/-out/evalalpha<==>+out/eval -- 196 - diff old new 197 - --- old 198 - +++ new 199 - @@ -1,12 +1,7 @@ 200 - Errors: 201 - reclose1.z.d: field not allowed: 202 - - ./in.cue:28:6 203 - - ./in.cue:33:5 204 - ./in.cue:34:5 205 - recloseSimple.a.b: field not allowed: 206 - - ./in.cue:16:8 207 - - ./in.cue:17:5 208 - - ./in.cue:17:6 209 - ./in.cue:17:15 210 - 211 - Result: 212 - @@ -20,9 +15,7 @@ 213 - } 214 - } 215 - #Deployment: (#struct){ 216 - - spec: (#struct){ 217 - - replicas: (int){ int } 218 - - } 219 - + spec: ~(#Spec) 220 - } 221 - #Spec: (#struct){ 222 - replicas: (int){ int } 223 - @@ -37,9 +30,6 @@ 224 - // [eval] 225 - b: (_|_){ 226 - // [eval] recloseSimple.a.b: field not allowed: 227 - - // ./in.cue:16:8 228 - - // ./in.cue:17:5 229 - - // ./in.cue:17:6 230 - // ./in.cue:17:15 231 - } 232 - } 233 - @@ -51,21 +41,19 @@ 234 - y: (int){ int } 235 - } 236 - #a: (#struct){ 237 - - x: (int){ int } 238 - - y: (int){ int } 239 - b: (#struct){ 240 - c: (int){ int } 241 - } 242 - + x: (int){ int } 243 - + y: (int){ int } 244 - } 245 - z: (_|_){ 246 - // [eval] 247 - - c: (int){ int } 248 - d: (_|_){ 249 - // [eval] reclose1.z.d: field not allowed: 250 - - // ./in.cue:28:6 251 - - // ./in.cue:33:5 252 - // ./in.cue:34:5 253 - } 254 - + c: (int){ int } 255 - } 256 - } 257 - reclose2: (struct){ 258 - @@ -74,15 +62,15 @@ 259 - y: (int){ int } 260 - } 261 - a: (#struct){ 262 - - x: (int){ int } 263 - - y: (int){ int } 264 - b: (struct){ 265 - c: (int){ int } 266 - } 267 - + x: (int){ int } 268 - + y: (int){ int } 269 - } 270 - z: (struct){ 271 - - c: (int){ int } 272 - d: (int){ 3 } 273 - + c: (int){ int } 274 - } 275 - } 276 - reclose3: (struct){ 277 - @@ -97,12 +85,12 @@ 278 - Name: (string){ string } 279 - } 280 - #A: (#struct){ 281 - - Name: (string){ string } 282 - Something: (int){ int } 283 - + Name: (string){ string } 284 - } 285 - #B: (#struct){ 286 - - Name: (string){ string } 287 - Else: (int){ int } 288 - + Name: (string){ string } 289 - } 290 - x: (#struct){ 291 - Name: (string){ "a" } 292 - -- diff/todo/p3 -- 293 - Reordering 294 - Missing error positions 295 - -- out/eval -- 296 - Errors: 297 - reclose1.z.d: field not allowed: 298 - ./in.cue:28:6 299 - ./in.cue:33:5 300 - ./in.cue:34:5 301 - recloseSimple.a.b: field not allowed: 302 - ./in.cue:16:8 303 - ./in.cue:17:5 304 - ./in.cue:17:6 305 - ./in.cue:17:15 306 - 307 - Result: 308 - (_|_){ 309 - // [eval] 310 - deployment: (struct){ 311 - foo: (#struct){ 312 - spec: (#struct){ 313 - replicas: (int){ 1 } 314 - } 315 - } 316 - } 317 - #Deployment: (#struct){ 318 - spec: (#struct){ 319 - replicas: (int){ int } 320 - } 321 - } 322 - #Spec: (#struct){ 323 - replicas: (int){ int } 324 - } 325 - #TypeMeta: (#struct){ 326 - } 327 - recloseSimple: (_|_){ 328 - // [eval] 329 - #foo: (#struct){ 330 - } 331 - a: (_|_){ 332 - // [eval] 333 - b: (_|_){ 334 - // [eval] recloseSimple.a.b: field not allowed: 335 - // ./in.cue:16:8 336 - // ./in.cue:17:5 337 - // ./in.cue:17:6 338 - // ./in.cue:17:15 339 - } 340 - } 341 - } 342 - reclose1: (_|_){ 343 - // [eval] 344 - #D: (#struct){ 345 - x: (int){ int } 346 - y: (int){ int } 347 - } 348 - #a: (#struct){ 349 - x: (int){ int } 350 - y: (int){ int } 351 - b: (#struct){ 352 - c: (int){ int } 353 - } 354 - } 355 - z: (_|_){ 356 - // [eval] 357 - c: (int){ int } 358 - d: (_|_){ 359 - // [eval] reclose1.z.d: field not allowed: 360 - // ./in.cue:28:6 361 - // ./in.cue:33:5 362 - // ./in.cue:34:5 363 - } 364 - } 365 - } 366 - reclose2: (struct){ 367 - #D: (#struct){ 368 - x: (int){ int } 369 - y: (int){ int } 370 - } 371 - a: (#struct){ 372 - x: (int){ int } 373 - y: (int){ int } 374 - b: (struct){ 375 - c: (int){ int } 376 - } 377 - } 378 - z: (struct){ 379 - c: (int){ int } 380 - d: (int){ 3 } 381 - } 382 - } 383 - reclose3: (struct){ 384 - #Step: (#struct){ |((#struct){ 385 - Name: (string){ string } 386 - Something: (int){ int } 387 - }, (#struct){ 388 - Name: (string){ string } 389 - Else: (int){ int } 390 - }) } 391 - #Common: (#struct){ 392 - Name: (string){ string } 393 - } 394 - #A: (#struct){ 395 - Name: (string){ string } 396 - Something: (int){ int } 397 - } 398 - #B: (#struct){ 399 - Name: (string){ string } 400 - Else: (int){ int } 401 - } 402 - x: (#struct){ 403 - Name: (string){ "a" } 404 - Something: (int){ 4 } 405 - } 406 - } 407 - } 408 103 -- out/compile -- 409 104 --- in.cue 410 105 { ··· 489 184 }) 490 185 } 491 186 } 187 + -- out/diff-v2-v3.txt -- 188 + Reordering. 189 + Missing error positions: v3 reports fewer positions than v2.
+49 -417
cue/testdata/definitions/exclude.txtar
··· 1 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 2 1 -- in.cue -- 3 2 package p 4 3 ··· 6 5 // Two lets with the same name should not unify and checked by definition. 7 6 #D: { let X = {}, #foo: X, f: _ } 8 7 a: #D 9 - a: { let X = { a: 1 }, f: X } 8 + a: { let X = { a: 1 }, f: X } @test(debugCheck, #""" 9 + (#struct){ 10 + let X#2 = (struct){ 11 + a: (int){ 1 } 12 + } 13 + f: (#struct){ 14 + a: (int){ 1 } 15 + } 16 + let X#1 = (#struct){ 17 + } 18 + #foo: (#struct){ 19 + } 20 + } 21 + """#) 22 + 23 + @test(eq, { 24 + #D: { 25 + #foo: {} 26 + f: _ 27 + } 28 + a: { 29 + #foo: {} 30 + f: a: 1 31 + } 32 + }) 10 33 } 11 34 12 35 definition: { ··· 14 37 err1: { 15 38 #D: { #foo: a: int } 16 39 a: #D 17 - a: { #foo: b: int } 40 + a: { #foo: b: int @test(err, code=eval, contains="field not allowed", pos=[0:14]) } 18 41 } 19 42 ok1: { 20 43 #D: {} 21 44 a: #D 22 45 a: { #foo: b: int } 46 + @test(eq, { 47 + #D: {} 48 + a: #foo: b: int 49 + }) 23 50 } 24 51 } 25 52 ··· 28 55 err1: { 29 56 #D: { _foo: a: int } 30 57 a: #D 31 - a: { _foo: b: int } 58 + a: { _foo: b: int } @test(err, code=eval, at=_foo$p, contains="field not allowed", pos=[0:14]) 32 59 } 33 60 ok1: { 34 61 #D: {} 35 62 a: #D 36 63 a: { _foo: b: int } 37 - } 64 + } @test(eq, {#D: {}, a: {_foo$p: {b: int}}}) 38 65 } 39 66 -- regress.cue -- 40 67 package p 41 68 42 69 import "encoding/json" 43 70 44 - definition: ok1: { 45 - org: #Org & { 46 - #Employee: username: string 47 - } 48 - #Org: employees?: [string]: username!: string 49 - } 50 - 51 71 definition: ok2: { 52 72 #Tree: { 53 73 #Leaf: leaf: string 54 74 #Branch: branch?: #Leaf 55 75 root: #Branch 56 76 } 57 - out: json.Marshal(#Tree & {root: {}}) 77 + out: json.Marshal(#Tree & {root: {}}) @test(eq, #"{"root":{}}"#) 58 78 } 59 79 60 - hidden: ok1: { 80 + hidden: ok2: { 61 81 out: #Workflow & { 62 82 _hidden: #step & { 63 83 run: "foo bar" ··· 68 88 #step: matchN(1, [{ 69 89 "run"!: _ 70 90 }]) 91 + 92 + @test(eq, { 93 + out: _hidden$p: run: "foo bar" 94 + #Workflow: {} 95 + #step: matchN(1, [{ run!: _ }]) 96 + }) 71 97 } 98 + -- out/errors.txt -- 99 + [eval] definition.err1.a.#foo.b: field not allowed: 100 + ./in.cue:39:14 101 + [eval] hidden.err1.a._foo.b: field not allowed: 102 + ./in.cue:57:14 103 + -- out/diff-v2-v3.txt -- 104 + Reordering. 105 + Missing error positions: v3 reports fewer positions than v2. 72 106 -- out/eval/stats -- 73 107 Leaks: 1 74 108 Freed: 78 ··· 81 115 Disjuncts: 0 82 116 83 117 NumCloseIDs: 18 84 - -- out/evalalpha -- 85 - Errors: 86 - definition.err1.a.#foo.b: field not allowed: 87 - ./in.cue:15:14 88 - hidden.err1.a._foo.b: field not allowed: 89 - ./in.cue:29:14 90 - 91 - Result: 92 - (_|_){ 93 - // [eval] 94 - excludeLet: (struct){ 95 - #D: (#struct){ 96 - let X#1 = (#struct){ 97 - } 98 - #foo: (#struct){ 99 - } 100 - f: (_){ _ } 101 - } 102 - a: (#struct){ 103 - let X#2 = (struct){ 104 - a: (int){ 1 } 105 - } 106 - f: (#struct){ 107 - a: (int){ 1 } 108 - } 109 - let X#1 = (#struct){ 110 - } 111 - #foo: (#struct){ 112 - } 113 - } 114 - } 115 - definition: (_|_){ 116 - // [eval] 117 - err1: (_|_){ 118 - // [eval] 119 - #D: (#struct){ 120 - #foo: (#struct){ 121 - a: (int){ int } 122 - } 123 - } 124 - a: (_|_){ 125 - // [eval] 126 - #foo: (_|_){ 127 - // [eval] 128 - b: (_|_){ 129 - // [eval] definition.err1.a.#foo.b: field not allowed: 130 - // ./in.cue:15:14 131 - } 132 - a: (int){ int } 133 - } 134 - } 135 - } 136 - ok1: (struct){ 137 - #D: (#struct){ 138 - } 139 - a: (#struct){ 140 - #foo: (#struct){ 141 - b: (int){ int } 142 - } 143 - } 144 - org: (#struct){ 145 - #Employee: (#struct){ 146 - username: (string){ string } 147 - } 148 - employees?: (#struct){ 149 - } 150 - } 151 - #Org: (#struct){ 152 - employees?: (#struct){ 153 - } 154 - } 155 - } 156 - ok2: (struct){ 157 - #Tree: (#struct){ 158 - #Leaf: (#struct){ 159 - leaf: (string){ string } 160 - } 161 - #Branch: (#struct){ 162 - branch?: ~(definition.ok2.#Tree.#Leaf) 163 - } 164 - root: ~(definition.ok2.#Tree.#Branch) 165 - } 166 - out: (string){ "{\"root\":{}}" } 167 - } 168 - } 169 - hidden: (_|_){ 170 - // [eval] 171 - err1: (_|_){ 172 - // [eval] 173 - #D: (#struct){ 174 - _foo(:p): (#struct){ 175 - a: (int){ int } 176 - } 177 - } 178 - a: (_|_){ 179 - // [eval] 180 - _foo(:p): (_|_){ 181 - // [eval] 182 - b: (_|_){ 183 - // [eval] hidden.err1.a._foo.b: field not allowed: 184 - // ./in.cue:29:14 185 - } 186 - a: (int){ int } 187 - } 188 - } 189 - } 190 - ok1: (struct){ 191 - #D: (#struct){ 192 - } 193 - a: (#struct){ 194 - _foo(:p): (struct){ 195 - b: (int){ int } 196 - } 197 - } 198 - out: (#struct){ 199 - _hidden(:p): (#struct){ 200 - run: (string){ "foo bar" } 201 - } 202 - } 203 - #Workflow: (#struct){ 204 - } 205 - #step: (_){ matchN(1, (#list){ 206 - 0: (_|_){// { 207 - // run!: _ 208 - // } 209 - } 210 - }) } 211 - } 212 - } 213 - } 214 - -- diff/-out/evalalpha<==>+out/eval -- 215 - diff old new 216 - --- old 217 - +++ new 218 - @@ -1,11 +1,7 @@ 219 - Errors: 220 - definition.err1.a.#foo.b: field not allowed: 221 - - ./in.cue:13:15 222 - - ./in.cue:14:6 223 - ./in.cue:15:14 224 - hidden.err1.a._foo.b: field not allowed: 225 - - ./in.cue:27:15 226 - - ./in.cue:28:6 227 - ./in.cue:29:14 228 - 229 - Result: 230 - @@ -20,16 +16,16 @@ 231 - f: (_){ _ } 232 - } 233 - a: (#struct){ 234 - - let X#1 = (#struct){ 235 - - } 236 - - #foo: (#struct){ 237 - - } 238 - - f: (struct){ 239 - - a: (int){ 1 } 240 - - } 241 - let X#2 = (struct){ 242 - a: (int){ 1 } 243 - } 244 - + f: (#struct){ 245 - + a: (int){ 1 } 246 - + } 247 - + let X#1 = (#struct){ 248 - + } 249 - + #foo: (#struct){ 250 - + } 251 - } 252 - } 253 - definition: (_|_){ 254 - @@ -45,13 +41,11 @@ 255 - // [eval] 256 - #foo: (_|_){ 257 - // [eval] 258 - - a: (int){ int } 259 - b: (_|_){ 260 - // [eval] definition.err1.a.#foo.b: field not allowed: 261 - - // ./in.cue:13:15 262 - - // ./in.cue:14:6 263 - // ./in.cue:15:14 264 - } 265 - + a: (int){ int } 266 - } 267 - } 268 - } 269 - @@ -64,11 +58,11 @@ 270 - } 271 - } 272 - org: (#struct){ 273 - - employees?: (#struct){ 274 - - } 275 - #Employee: (#struct){ 276 - username: (string){ string } 277 - } 278 - + employees?: (#struct){ 279 - + } 280 - } 281 - #Org: (#struct){ 282 - employees?: (#struct){ 283 - @@ -81,15 +75,9 @@ 284 - leaf: (string){ string } 285 - } 286 - #Branch: (#struct){ 287 - - branch?: (#struct){ 288 - - leaf: (string){ string } 289 - - } 290 - - } 291 - - root: (#struct){ 292 - - branch?: (#struct){ 293 - - leaf: (string){ string } 294 - - } 295 - - } 296 - + branch?: ~(definition.ok2.#Tree.#Leaf) 297 - + } 298 - + root: ~(definition.ok2.#Tree.#Branch) 299 - } 300 - out: (string){ "{\"root\":{}}" } 301 - } 302 - @@ -107,13 +95,11 @@ 303 - // [eval] 304 - _foo(:p): (_|_){ 305 - // [eval] 306 - - a: (int){ int } 307 - b: (_|_){ 308 - // [eval] hidden.err1.a._foo.b: field not allowed: 309 - - // ./in.cue:27:15 310 - - // ./in.cue:28:6 311 - // ./in.cue:29:14 312 - } 313 - + a: (int){ int } 314 - } 315 - } 316 - } 317 - @@ -126,7 +112,7 @@ 318 - } 319 - } 320 - out: (#struct){ 321 - - _hidden(:p): (struct){ 322 - + _hidden(:p): (#struct){ 323 - run: (string){ "foo bar" } 324 - } 325 - } 326 - -- out/eval -- 327 - Errors: 328 - definition.err1.a.#foo.b: field not allowed: 329 - ./in.cue:13:15 330 - ./in.cue:14:6 331 - ./in.cue:15:14 332 - hidden.err1.a._foo.b: field not allowed: 333 - ./in.cue:27:15 334 - ./in.cue:28:6 335 - ./in.cue:29:14 336 - 337 - Result: 338 - (_|_){ 339 - // [eval] 340 - excludeLet: (struct){ 341 - #D: (#struct){ 342 - let X#1 = (#struct){ 343 - } 344 - #foo: (#struct){ 345 - } 346 - f: (_){ _ } 347 - } 348 - a: (#struct){ 349 - let X#1 = (#struct){ 350 - } 351 - #foo: (#struct){ 352 - } 353 - f: (struct){ 354 - a: (int){ 1 } 355 - } 356 - let X#2 = (struct){ 357 - a: (int){ 1 } 358 - } 359 - } 360 - } 361 - definition: (_|_){ 362 - // [eval] 363 - err1: (_|_){ 364 - // [eval] 365 - #D: (#struct){ 366 - #foo: (#struct){ 367 - a: (int){ int } 368 - } 369 - } 370 - a: (_|_){ 371 - // [eval] 372 - #foo: (_|_){ 373 - // [eval] 374 - a: (int){ int } 375 - b: (_|_){ 376 - // [eval] definition.err1.a.#foo.b: field not allowed: 377 - // ./in.cue:13:15 378 - // ./in.cue:14:6 379 - // ./in.cue:15:14 380 - } 381 - } 382 - } 383 - } 384 - ok1: (struct){ 385 - #D: (#struct){ 386 - } 387 - a: (#struct){ 388 - #foo: (#struct){ 389 - b: (int){ int } 390 - } 391 - } 392 - org: (#struct){ 393 - employees?: (#struct){ 394 - } 395 - #Employee: (#struct){ 396 - username: (string){ string } 397 - } 398 - } 399 - #Org: (#struct){ 400 - employees?: (#struct){ 401 - } 402 - } 403 - } 404 - ok2: (struct){ 405 - #Tree: (#struct){ 406 - #Leaf: (#struct){ 407 - leaf: (string){ string } 408 - } 409 - #Branch: (#struct){ 410 - branch?: (#struct){ 411 - leaf: (string){ string } 412 - } 413 - } 414 - root: (#struct){ 415 - branch?: (#struct){ 416 - leaf: (string){ string } 417 - } 418 - } 419 - } 420 - out: (string){ "{\"root\":{}}" } 421 - } 422 - } 423 - hidden: (_|_){ 424 - // [eval] 425 - err1: (_|_){ 426 - // [eval] 427 - #D: (#struct){ 428 - _foo(:p): (#struct){ 429 - a: (int){ int } 430 - } 431 - } 432 - a: (_|_){ 433 - // [eval] 434 - _foo(:p): (_|_){ 435 - // [eval] 436 - a: (int){ int } 437 - b: (_|_){ 438 - // [eval] hidden.err1.a._foo.b: field not allowed: 439 - // ./in.cue:27:15 440 - // ./in.cue:28:6 441 - // ./in.cue:29:14 442 - } 443 - } 444 - } 445 - } 446 - ok1: (struct){ 447 - #D: (#struct){ 448 - } 449 - a: (#struct){ 450 - _foo(:p): (struct){ 451 - b: (int){ int } 452 - } 453 - } 454 - out: (#struct){ 455 - _hidden(:p): (struct){ 456 - run: (string){ "foo bar" } 457 - } 458 - } 459 - #Workflow: (#struct){ 460 - } 461 - #step: (_){ matchN(1, (#list){ 462 - 0: (_|_){// { 463 - // run!: _ 464 - // } 465 - } 466 - }) } 467 - } 468 - } 469 - } 470 118 -- out/compile -- 471 119 --- in.cue 472 120 { ··· 536 184 --- regress.cue 537 185 { 538 186 definition: { 539 - ok1: { 540 - org: (〈0;#Org〉 & { 541 - #Employee: { 542 - username: string 543 - } 544 - }) 545 - #Org: { 546 - employees?: { 547 - [string]: { 548 - username!: string 549 - } 550 - } 551 - } 552 - } 553 - } 554 - definition: { 555 187 ok2: { 556 188 #Tree: { 557 189 #Leaf: { ··· 568 200 } 569 201 } 570 202 hidden: { 571 - ok1: { 203 + ok2: { 572 204 out: (〈0;#Workflow〉 & { 573 205 _hidden(:p): (〈1;#step〉 & { 574 206 run: "foo bar"
+149 -959
cue/testdata/definitions/explicitopen.txtar
··· 1 1 # Tests the explicitopen experiment: allows using the spread operator (...) to 2 2 # explicitly open closed structs. NewClosed1: {#A} is closed; NewOpen1: {#A...} 3 3 # is open. The test covers interactions between old and new style closedness. 4 - #todo:inline: medium — multiple error cases; annotate with @test(err) per field 5 4 -- cue.mod/module.cue -- 6 5 module: "mod.test" 7 6 ··· 26 25 } 27 26 28 27 useNewClosed1: { 29 - t1: err: NewClosed1 & {c: 3} 30 - t2: ok: {NewClosed1, c: 3} 28 + t1: err: NewClosed1 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:25]) 29 + t2: ok: {NewClosed1, c: 3} @test(eq, { a: 1, c: 3 }) 31 30 } 32 31 33 32 useNewClosed2: { 34 - t1: err: #NewClosed2 & {c: 3} 35 - t2: ok: {#NewClosed2, c: 3} 33 + t1: err: #NewClosed2 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:26]) 34 + t2: ok: {#NewClosed2, c: 3} @test(eq, { a: 1, b: 1, c: 3 }) 36 35 } 37 36 38 37 useNewOpen1: { 39 - t1: ok: NewOpen1 & {c: 3} 40 - t2: ok: {NewOpen1, c: 3} 38 + t1: ok: NewOpen1 & {c: 3} @test(eq, { a: 1, b: 1, c: 3 }) 39 + t2: ok: {NewOpen1, c: 3} @test(eq, { a: 1, b: 1, c: 3 }) 41 40 } 42 41 43 42 useNewOpen2: { 44 - t1: ok: NewOpen2 & {c: 3} 45 - t2: ok: {NewOpen2, c: 3} 43 + t1: ok: NewOpen2 & {c: 3} @test(eq, { a: 1, c: 3 }) 44 + t2: ok: {NewOpen2, c: 3} @test(eq, { a: 1, c: 3 }) 46 45 } 47 46 48 47 combineold: { 49 48 // all {a: 1} 50 - a0: ok: #A & NewClosed1 51 - a1: ok: {#A, NewClosed1} 49 + a0: ok: #A & NewClosed1 @test(eq, { a: 1 }) 50 + a1: ok: {#A, NewClosed1} @test(eq, { a: 1 }) 52 51 53 - a2: ok: NewClosed1 & NewOpen2 54 - a3: ok: {NewClosed1, NewOpen2} 52 + a2: ok: NewClosed1 & NewOpen2 @test(eq, { a: 1 }) 53 + a3: ok: {NewClosed1, NewOpen2} @test(eq, { a: 1 }) 55 54 56 55 // all {a: 1, b: 2} 57 - b0: ok: Old1 & #NewClosed2 58 - b1: ok: #Old2 & #NewClosed2 56 + b0: ok: Old1 & #NewClosed2 @test(eq, { a: 1, b: 1 }) 57 + b1: ok: #Old2 & #NewClosed2 @test(eq, { a: 1, b: 1 }) 59 58 60 - c1: ok: {#NewClosed2, Old1} 61 - c2: ok: {#NewClosed2, #Old2} 59 + c1: ok: {#NewClosed2, Old1} @test(eq, { a: 1, b: 1 }) 60 + c2: ok: {#NewClosed2, #Old2} @test(eq, { a: 1, b: 1 }) 62 61 63 62 // {a: 1} and {a: 1, b: 2} 64 - e0: err: #A & Old1 65 - e1: err: #A & #Old2 66 - e2: err: #A & #NewClosed2 67 - e3: err: #A & NewOpen1 63 + e0: err: #A & Old1 @test(err, code=eval, contains="field not allowed", pos=[-47:3]) 64 + e1: err: #A & #Old2 @test(err, code=eval, contains="field not allowed", pos=[-41:3]) 65 + e2: err: #A & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[new.cue:11:2]) 66 + e3: err: #A & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[new.cue:16:2]) 68 67 69 - e4: ok: {#A, Old1} 70 - e5: ok: {#A, #Old2} 71 - e6: ok: {#A, #NewClosed2} 72 - e7: ok: {#A, NewOpen1} 68 + e4: ok: {#A, Old1} @test(eq, { a: 1, b: 1 }) 69 + e5: ok: {#A, #Old2} @test(eq, { a: 1, b: 1 }) 70 + e6: ok: {#A, #NewClosed2} @test(eq, { a: 1, b: 1 }) 71 + e7: ok: {#A, NewOpen1} @test(eq, { a: 1, b: 1 }) 73 72 74 - f0: err: NewClosed1 & Old1 75 - f1: err: NewClosed1 & #Old2 76 - f2: err: NewClosed1 & #NewClosed2 77 - f3: err: NewClosed1 & NewOpen1 73 + f0: err: NewClosed1 & Old1 @test(err, code=eval, contains="field not allowed", pos=[-57:3]) 74 + f1: err: NewClosed1 & #Old2 @test(err, code=eval, contains="field not allowed", pos=[-51:3]) 75 + f2: err: NewClosed1 & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[new.cue:11:2]) 76 + f3: err: NewClosed1 & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[new.cue:16:2]) 78 77 79 - f4: ok: {NewClosed1, Old1} 80 - f5: ok: {NewClosed1, #Old2} 81 - f6: ok: {NewClosed1, NewClosed1} 82 - f7: ok: {NewClosed1, #NewClosed2} 83 - f8: ok: {NewClosed1, NewOpen1} 78 + f4: ok: {NewClosed1, Old1} @test(eq, { a: 1, b: 1 }) 79 + f5: ok: {NewClosed1, #Old2} @test(eq, { a: 1, b: 1 }) 80 + f6: ok: {NewClosed1, NewClosed1} @test(eq, { a: 1 }) 81 + f7: ok: {NewClosed1, #NewClosed2} @test(eq, { a: 1, b: 1 }) 82 + f8: ok: {NewClosed1, NewOpen1} @test(eq, { a: 1, b: 1 }) 84 83 } 85 84 86 85 -- new.cue -- ··· 105 104 NewOpen2: #A... 106 105 107 106 useOld1: { 108 - t1: err: Old1 & {c: 3} 109 - t2: err: {Old1, c: 3} // TODO 110 - t3: ok: {Old1..., c: 3} 107 + t1: err: Old1 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:19]) 108 + t2: err: {Old1, c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:18]) // TODO 109 + t3: ok: {Old1..., c: 3} @test(eq, {a: 1, b: 1, c: 3}) 111 110 } 112 111 113 112 useOld2: { 114 - t1: err: #Old2 & {c: 3} 115 - t2: err: {#Old2, c: 3} 116 - t3: ok: {#Old2..., c: 3} 113 + t1: err: #Old2 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:20]) 114 + t2: err: {#Old2, c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:19]) 115 + t3: ok: {#Old2..., c: 3} @test(eq, {a: 1, b: 1, c: 3}) 117 116 } 118 117 119 118 combinenew: { 120 119 // all {a: 1} 121 - a0: ok: #A & NewClosed1 122 - a1: ok: {#A, NewClosed1} 120 + a0: ok: #A & NewClosed1 @test(eq, {a: 1}) 121 + a1: ok: {#A, NewClosed1} @test(eq, {a: 1}) 123 122 124 - a2: ok: NewClosed1 & NewOpen2 125 - a3: ok: {NewClosed1, NewOpen2} 126 - a4: ok: {NewClosed1..., NewOpen2} 123 + a2: ok: NewClosed1 & NewOpen2 @test(eq, {a: 1}) 124 + a3: ok: {NewClosed1, NewOpen2} @test(eq, {a: 1}) 125 + a4: ok: {NewClosed1..., NewOpen2} @test(eq, {a: 1}) 127 126 128 - a5: ok: NewOpen2 & NewClosed1 129 - a6: ok: {NewOpen2, NewClosed1} 130 - a7: ok: {NewOpen2..., NewClosed1} 127 + a5: ok: NewOpen2 & NewClosed1 @test(eq, {a: 1}) 128 + a6: ok: {NewOpen2, NewClosed1} @test(eq, {a: 1}) 129 + a7: ok: {NewOpen2..., NewClosed1} @test(eq, {a: 1}) 131 130 132 131 // all {a: 1, b: 2} 133 - b0: ok: Old1 & #NewClosed2 134 - b1: ok: #Old2 & #NewClosed2 135 - b2: ok: #NewClosed2 & Old1 136 - b3: ok: #NewClosed2 & #Old2 132 + b0: ok: Old1 & #NewClosed2 @test(eq, {a: 1, b: 1}) 133 + b1: ok: #Old2 & #NewClosed2 @test(eq, {a: 1, b: 1}) 134 + b2: ok: #NewClosed2 & Old1 @test(eq, {a: 1, b: 1}) 135 + b3: ok: #NewClosed2 & #Old2 @test(eq, {a: 1, b: 1}) 137 136 138 - c1: ok: {#NewClosed2, Old1} 139 - c2: ok: {#NewClosed2, #Old2} 140 - c3: ok: {Old1, #NewClosed2} 141 - c4: ok: {#Old2, #NewClosed2} 137 + c1: ok: {#NewClosed2, Old1} @test(eq, {a: 1, b: 1}) 138 + c2: ok: {#NewClosed2, #Old2} @test(eq, {a: 1, b: 1}) 139 + c3: ok: {Old1, #NewClosed2} @test(eq, {a: 1, b: 1}) 140 + c4: ok: {#Old2, #NewClosed2} @test(eq, {a: 1, b: 1}) 142 141 143 - d0: ok: {#NewClosed2, Old1...} 144 - d1: ok: {#NewClosed2, #Old2...} 145 - d2: ok: {#NewClosed2..., Old1} 146 - d3: ok: {#NewClosed2..., #Old2} 147 - d4: ok: {#NewClosed2..., Old1...} 148 - d5: ok: {#NewClosed2..., #Old2...} 142 + d0: ok: {#NewClosed2, Old1...} @test(eq, {a: 1, b: 1}) 143 + d1: ok: {#NewClosed2, #Old2...} @test(eq, {a: 1, b: 1}) 144 + d2: ok: {#NewClosed2..., Old1} @test(eq, {a: 1, b: 1}) 145 + d3: ok: {#NewClosed2..., #Old2} @test(eq, {a: 1, b: 1}) 146 + d4: ok: {#NewClosed2..., Old1...} @test(eq, {a: 1, b: 1}) 147 + d5: ok: {#NewClosed2..., #Old2...} @test(eq, {a: 1, b: 1}) 149 148 150 - d6: ok: {Old1..., #NewClosed2} 151 - d7: ok: {#Old2..., #NewClosed2} 152 - d8: ok: {Old1, #NewClosed2...,} 153 - d9: ok: {#Old2, #NewClosed2...,} 154 - d10: ok: {Old1..., #NewClosed2...,} 155 - d11: ok: {#Old2..., #NewClosed2...,} 149 + d6: ok: {Old1..., #NewClosed2} @test(eq, {a: 1, b: 1}) 150 + d7: ok: {#Old2..., #NewClosed2} @test(eq, {a: 1, b: 1}) 151 + d8: ok: {Old1, #NewClosed2...,} @test(eq, {a: 1, b: 1}) 152 + d9: ok: {#Old2, #NewClosed2...,} @test(eq, {a: 1, b: 1}) 153 + d10: ok: {Old1..., #NewClosed2...,} @test(eq, {a: 1, b: 1}) 154 + d11: ok: {#Old2..., #NewClosed2...,} @test(eq, {a: 1, b: 1}) 156 155 157 156 // {a: 1} and {a: 1, b: 2} 158 - e0: err: #A & Old1 159 - e1: err: #A & #Old2 160 - e2: err: #A & #NewClosed2 161 - e3: err: #A & NewOpen1 157 + e0: err: #A & Old1 @test(err, code=eval, contains="field not allowed", pos=[old.cue:7:3]) 158 + e1: err: #A & #Old2 @test(err, code=eval, contains="field not allowed", pos=[old.cue:14:3]) 159 + e2: err: #A & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[-63:2]) 160 + e3: err: #A & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[-59:2]) 162 161 163 - e4: err: {#A, Old1} 164 - e5: err: {#A, #Old2} 165 - e6: err: {#A, #NewClosed2} 166 - e7: err: {#A, NewOpen1} 162 + e4: err: {#A, Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:7:3]) 163 + e5: err: {#A, #Old2} @test(err, code=eval, contains="field not allowed", pos=[old.cue:14:3]) 164 + e6: err: {#A, #NewClosed2} @test(err, code=eval, contains="field not allowed", pos=[-68:2]) 165 + e7: err: {#A, NewOpen1} @test(err, code=eval, contains="field not allowed", pos=[-64:2]) 167 166 168 - e8: ok: {#A..., Old1} 169 - e9: ok: {#A..., #Old2} 170 - e10: ok: {#A..., #NewClosed2} 171 - e11: ok: {#A..., NewOpen1} 167 + e8: ok: {#A..., Old1} @test(eq, {a: 1, b: 1}) 168 + e9: ok: {#A..., #Old2} @test(eq, {a: 1, b: 1}) 169 + e10: ok: {#A..., #NewClosed2} @test(eq, {a: 1, b: 1}) 170 + e11: ok: {#A..., NewOpen1} @test(eq, {a: 1, b: 1}) 172 171 173 - f0: err: NewClosed1 & Old1 174 - f1: err: NewClosed1 & #Old2 175 - f2: err: NewClosed1 & #NewClosed2 176 - f3: err: NewClosed1 & NewOpen1 177 - f4: ok: NewClosed1 & NewClosed1 172 + f0: err: NewClosed1 & Old1 @test(err, code=eval, contains="field not allowed", pos=[old.cue:7:3]) 173 + f1: err: NewClosed1 & #Old2 @test(err, code=eval, contains="field not allowed", pos=[old.cue:14:3]) 174 + f2: err: NewClosed1 & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[-78:2]) 175 + f3: err: NewClosed1 & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[-74:2]) 176 + f4: ok: NewClosed1 & NewClosed1 @test(eq, {a: 1}) 178 177 179 - f5: err: {NewClosed1, Old1} 180 - f6: err: {NewClosed1, #Old2} 181 - f7: err: {NewClosed1, #NewClosed2} 182 - f8: err: {NewClosed1, NewOpen1} 183 - f9: ok: {NewClosed1, NewClosed1} 178 + f5: err: {NewClosed1, Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:7:3]) 179 + f6: err: {NewClosed1, #Old2} @test(err, code=eval, contains="field not allowed", pos=[old.cue:14:3]) 180 + f7: err: {NewClosed1, #NewClosed2} @test(err, code=eval, contains="field not allowed", pos=[-84:2]) 181 + f8: err: {NewClosed1, NewOpen1} @test(err, code=eval, contains="field not allowed", pos=[-80:2]) 182 + f9: ok: {NewClosed1, NewClosed1} @test(err) 184 183 185 - f9: ok: {NewClosed1..., Old1} 186 - f10: ok: {NewClosed1..., #Old2} 187 - f11: ok: {NewClosed1..., NewClosed1} 188 - f12: ok: {NewClosed1..., #NewClosed2} 189 - f13: ok: {NewClosed1..., NewOpen1} 184 + f9: ok: {NewClosed1..., Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:7:3], hint="see todo") 185 + f10: ok: {NewClosed1..., #Old2} @test(eq, {a: 1, b: 1}) 186 + f11: ok: {NewClosed1..., NewClosed1} @test(eq, {a: 1}) 187 + f12: ok: {NewClosed1..., #NewClosed2} @test(eq, {a: 1, b: 1}) 188 + f13: ok: {NewClosed1..., NewOpen1} @test(eq, {a: 1, b: 1}) 190 189 191 - f14: err: Old1 & NewClosed1 192 - f15: err: #Old2 & NewClosed1 193 - f16: err: #NewClosed2 & NewClosed1 194 - f17: err: NewOpen1 & NewClosed1 195 - f18: ok: NewClosed1 & NewClosed1 190 + f14: err: Old1 & NewClosed1 @test(eq, {a: 1, b: 1}, hint="see todo") 191 + f15: err: #Old2 & NewClosed1 @test(eq, {a: 1, b: 1}, hint="see todo") 192 + f16: err: #NewClosed2 & NewClosed1 @test(err, code=eval, contains="field not allowed", pos=[-96:2]) 193 + f17: err: NewOpen1 & NewClosed1 @test(err, code=eval, contains="field not allowed", pos=[-92:2]) 194 + f18: ok: NewClosed1 & NewClosed1 @test(eq, {a: 1}) 196 195 } 197 196 -- issues.cue -- 198 197 @experiment(explicitopen) ··· 205 204 x: #Def... & { 206 205 a: 42 207 206 b: 42 208 - } 207 + } @test(eq, {a: 42, b: 42}) @test(closed) 208 + 209 209 foo: {a: int} 210 210 bar: {b: int} 211 - y: foo... & bar... 211 + y: foo... & bar... @test(eq, {a: int, b: int}) 212 212 213 213 // NOTE: we allow this, even though it doesn't mean anything. The benefit 214 214 // of this is that code doesn't become brittle using the spread operator ··· 220 220 // 221 221 // Not allowing ... on any expression would mean #foo... may or may not be 222 222 // erroneous, depending on the value foo is set to. 223 - z: 1... 223 + z: 1... @test(eq, 1) 224 224 } 225 - -- out/evalalpha -- 226 - Errors: 227 - combinenew.e0.err.b: field not allowed: 225 + -- out/errors.txt -- 226 + [eval] useOld1.t1.err.c: field not allowed: 227 + ./new.cue:22:19 228 + [eval] useOld1.t2.err.c: field not allowed: 229 + ./new.cue:23:18 230 + [eval] useOld2.t1.err.c: field not allowed: 231 + ./new.cue:28:20 232 + [eval] useOld2.t2.err.c: field not allowed: 233 + ./new.cue:29:19 234 + [eval] combinenew.e0.err.b: field not allowed: 228 235 ./old.cue:7:3 229 - combinenew.e1.err.b: field not allowed: 236 + [eval] combinenew.e1.err.b: field not allowed: 230 237 ./old.cue:14:3 231 - combinenew.e2.err.b: field not allowed: 238 + [eval] combinenew.e2.err.b: field not allowed: 232 239 ./new.cue:11:2 233 - combinenew.e3.err.b: field not allowed: 240 + [eval] combinenew.e3.err.b: field not allowed: 234 241 ./new.cue:16:2 235 - combinenew.e4.err.b: field not allowed: 242 + [eval] combinenew.e4.err.b: field not allowed: 236 243 ./old.cue:7:3 237 - combinenew.e5.err.b: field not allowed: 244 + [eval] combinenew.e5.err.b: field not allowed: 238 245 ./old.cue:14:3 239 - combinenew.e6.err.b: field not allowed: 246 + [eval] combinenew.e6.err.b: field not allowed: 240 247 ./new.cue:11:2 241 - combinenew.e7.err.b: field not allowed: 248 + [eval] combinenew.e7.err.b: field not allowed: 242 249 ./new.cue:16:2 243 - combinenew.f0.err.b: field not allowed: 250 + [eval] combinenew.f0.err.b: field not allowed: 244 251 ./old.cue:7:3 245 - combinenew.f1.err.b: field not allowed: 252 + [eval] combinenew.f1.err.b: field not allowed: 246 253 ./old.cue:14:3 247 - combinenew.f16.err.b: field not allowed: 254 + [eval] combinenew.f2.err.b: field not allowed: 248 255 ./new.cue:11:2 249 - combinenew.f17.err.b: field not allowed: 256 + [eval] combinenew.f3.err.b: field not allowed: 250 257 ./new.cue:16:2 251 - combinenew.f2.err.b: field not allowed: 258 + [eval] combinenew.f5.err.b: field not allowed: 259 + ./old.cue:7:3 260 + [eval] combinenew.f6.err.b: field not allowed: 261 + ./old.cue:14:3 262 + [eval] combinenew.f7.err.b: field not allowed: 252 263 ./new.cue:11:2 253 - combinenew.f3.err.b: field not allowed: 264 + [eval] combinenew.f8.err.b: field not allowed: 254 265 ./new.cue:16:2 255 - combinenew.f5.err.b: field not allowed: 266 + [eval] combinenew.f9.ok.b: field not allowed: 256 267 ./old.cue:7:3 257 - combinenew.f6.err.b: field not allowed: 258 - ./old.cue:14:3 259 - combinenew.f7.err.b: field not allowed: 268 + [eval] combinenew.f16.err.b: field not allowed: 260 269 ./new.cue:11:2 261 - combinenew.f8.err.b: field not allowed: 270 + [eval] combinenew.f17.err.b: field not allowed: 262 271 ./new.cue:16:2 263 - combinenew.f9.ok.b: field not allowed: 264 - ./old.cue:7:3 265 - combineold.e0.err.b: field not allowed: 272 + [eval] useNewClosed1.t1.err.c: field not allowed: 273 + ./old.cue:19:25 274 + [eval] useNewClosed2.t1.err.c: field not allowed: 275 + ./old.cue:24:26 276 + [eval] combineold.e0.err.b: field not allowed: 266 277 ./old.cue:7:3 267 - combineold.e1.err.b: field not allowed: 278 + [eval] combineold.e1.err.b: field not allowed: 268 279 ./old.cue:14:3 269 - combineold.e2.err.b: field not allowed: 280 + [eval] combineold.e2.err.b: field not allowed: 270 281 ./new.cue:11:2 271 - combineold.e3.err.b: field not allowed: 282 + [eval] combineold.e3.err.b: field not allowed: 272 283 ./new.cue:16:2 273 - combineold.f0.err.b: field not allowed: 284 + [eval] combineold.f0.err.b: field not allowed: 274 285 ./old.cue:7:3 275 - combineold.f1.err.b: field not allowed: 286 + [eval] combineold.f1.err.b: field not allowed: 276 287 ./old.cue:14:3 277 - combineold.f2.err.b: field not allowed: 288 + [eval] combineold.f2.err.b: field not allowed: 278 289 ./new.cue:11:2 279 - combineold.f3.err.b: field not allowed: 290 + [eval] combineold.f3.err.b: field not allowed: 280 291 ./new.cue:16:2 281 - useNewClosed1.t1.err.c: field not allowed: 282 - ./old.cue:19:25 283 - useNewClosed2.t1.err.c: field not allowed: 284 - ./old.cue:24:26 285 - useOld1.t1.err.c: field not allowed: 286 - ./new.cue:22:19 287 - useOld1.t2.err.c: field not allowed: 288 - ./new.cue:23:18 289 - useOld2.t1.err.c: field not allowed: 290 - ./new.cue:28:20 291 - useOld2.t2.err.c: field not allowed: 292 - ./new.cue:29:19 293 - 294 - Result: 295 - (_|_){ 296 - // [eval] 297 - issue4150: (struct){ 298 - #Def: (#struct){ 299 - a: (int){ int } 300 - } 301 - x: (#struct){ 302 - a: (int){ 42 } 303 - b: (int){ 42 } 304 - } 305 - foo: (struct){ 306 - a: (int){ int } 307 - } 308 - bar: (struct){ 309 - b: (int){ int } 310 - } 311 - y: (struct){ 312 - a: (int){ int } 313 - b: (int){ int } 314 - } 315 - z: (int){ 1 } 316 - } 317 - NewClosed1: (#struct){ 318 - a: (int){ 1 } 319 - } 320 - #NewClosed2: (#struct){ 321 - b: (int){ 1 } 322 - a: (int){ 1 } 323 - } 324 - NewOpen1: (#struct){ 325 - b: (int){ 1 } 326 - a: (int){ 1 } 327 - } 328 - NewOpen2: ~(#A) 329 - useOld1: (_|_){ 330 - // [eval] 331 - t1: (_|_){ 332 - // [eval] 333 - err: (_|_){ 334 - // [eval] 335 - c: (_|_){ 336 - // [eval] useOld1.t1.err.c: field not allowed: 337 - // ./new.cue:22:19 338 - } 339 - b: (int){ 1 } 340 - a: (int){ 1 } 341 - } 342 - } 343 - t2: (_|_){ 344 - // [eval] 345 - err: (_|_){ 346 - // [eval] 347 - c: (_|_){ 348 - // [eval] useOld1.t2.err.c: field not allowed: 349 - // ./new.cue:23:18 350 - } 351 - b: (int){ 1 } 352 - a: (int){ 1 } 353 - } 354 - } 355 - t3: (struct){ 356 - ok: (#struct){ 357 - c: (int){ 3 } 358 - b: (int){ 1 } 359 - a: (int){ 1 } 360 - } 361 - } 362 - } 363 - useOld2: (_|_){ 364 - // [eval] 365 - t1: (_|_){ 366 - // [eval] 367 - err: (_|_){ 368 - // [eval] 369 - c: (_|_){ 370 - // [eval] useOld2.t1.err.c: field not allowed: 371 - // ./new.cue:28:20 372 - } 373 - b: (int){ 1 } 374 - a: (int){ 1 } 375 - } 376 - } 377 - t2: (_|_){ 378 - // [eval] 379 - err: (_|_){ 380 - // [eval] 381 - c: (_|_){ 382 - // [eval] useOld2.t2.err.c: field not allowed: 383 - // ./new.cue:29:19 384 - } 385 - b: (int){ 1 } 386 - a: (int){ 1 } 387 - } 388 - } 389 - t3: (struct){ 390 - ok: (#struct){ 391 - c: (int){ 3 } 392 - b: (int){ 1 } 393 - a: (int){ 1 } 394 - } 395 - } 396 - } 397 - combinenew: (_|_){ 398 - // [eval] 399 - a0: (struct){ 400 - ok: (#struct){ 401 - a: (int){ 1 } 402 - } 403 - } 404 - a1: (struct){ 405 - ok: (#struct){ 406 - a: (int){ 1 } 407 - } 408 - } 409 - a2: (struct){ 410 - ok: (#struct){ 411 - a: (int){ 1 } 412 - } 413 - } 414 - a3: (struct){ 415 - ok: (#struct){ 416 - a: (int){ 1 } 417 - } 418 - } 419 - a4: (struct){ 420 - ok: (#struct){ 421 - a: (int){ 1 } 422 - } 423 - } 424 - a5: (struct){ 425 - ok: (#struct){ 426 - a: (int){ 1 } 427 - } 428 - } 429 - a6: (struct){ 430 - ok: (#struct){ 431 - a: (int){ 1 } 432 - } 433 - } 434 - a7: (struct){ 435 - ok: (#struct){ 436 - a: (int){ 1 } 437 - } 438 - } 439 - b0: (struct){ 440 - ok: (#struct){ 441 - b: (int){ 1 } 442 - a: (int){ 1 } 443 - } 444 - } 445 - b1: (struct){ 446 - ok: (#struct){ 447 - b: (int){ 1 } 448 - a: (int){ 1 } 449 - } 450 - } 451 - b2: (struct){ 452 - ok: (#struct){ 453 - b: (int){ 1 } 454 - a: (int){ 1 } 455 - } 456 - } 457 - b3: (struct){ 458 - ok: (#struct){ 459 - b: (int){ 1 } 460 - a: (int){ 1 } 461 - } 462 - } 463 - c1: (struct){ 464 - ok: (#struct){ 465 - b: (int){ 1 } 466 - a: (int){ 1 } 467 - } 468 - } 469 - c2: (struct){ 470 - ok: (#struct){ 471 - b: (int){ 1 } 472 - a: (int){ 1 } 473 - } 474 - } 475 - c3: (struct){ 476 - ok: (#struct){ 477 - b: (int){ 1 } 478 - a: (int){ 1 } 479 - } 480 - } 481 - c4: (struct){ 482 - ok: (#struct){ 483 - b: (int){ 1 } 484 - a: (int){ 1 } 485 - } 486 - } 487 - d0: (struct){ 488 - ok: (#struct){ 489 - b: (int){ 1 } 490 - a: (int){ 1 } 491 - } 492 - } 493 - d1: (struct){ 494 - ok: (#struct){ 495 - b: (int){ 1 } 496 - a: (int){ 1 } 497 - } 498 - } 499 - d2: (struct){ 500 - ok: (#struct){ 501 - b: (int){ 1 } 502 - a: (int){ 1 } 503 - } 504 - } 505 - d3: (struct){ 506 - ok: (#struct){ 507 - b: (int){ 1 } 508 - a: (int){ 1 } 509 - } 510 - } 511 - d4: (struct){ 512 - ok: (#struct){ 513 - b: (int){ 1 } 514 - a: (int){ 1 } 515 - } 516 - } 517 - d5: (struct){ 518 - ok: (#struct){ 519 - b: (int){ 1 } 520 - a: (int){ 1 } 521 - } 522 - } 523 - d6: (struct){ 524 - ok: (#struct){ 525 - b: (int){ 1 } 526 - a: (int){ 1 } 527 - } 528 - } 529 - d7: (struct){ 530 - ok: (#struct){ 531 - b: (int){ 1 } 532 - a: (int){ 1 } 533 - } 534 - } 535 - d8: (struct){ 536 - ok: (#struct){ 537 - b: (int){ 1 } 538 - a: (int){ 1 } 539 - } 540 - } 541 - d9: (struct){ 542 - ok: (#struct){ 543 - b: (int){ 1 } 544 - a: (int){ 1 } 545 - } 546 - } 547 - d10: (struct){ 548 - ok: (#struct){ 549 - b: (int){ 1 } 550 - a: (int){ 1 } 551 - } 552 - } 553 - d11: (struct){ 554 - ok: (#struct){ 555 - b: (int){ 1 } 556 - a: (int){ 1 } 557 - } 558 - } 559 - e0: (_|_){ 560 - // [eval] 561 - err: (_|_){ 562 - // [eval] 563 - a: (int){ 1 } 564 - b: (_|_){ 565 - // [eval] combinenew.e0.err.b: field not allowed: 566 - // ./old.cue:7:3 567 - } 568 - } 569 - } 570 - e1: (_|_){ 571 - // [eval] 572 - err: (_|_){ 573 - // [eval] 574 - a: (int){ 1 } 575 - b: (_|_){ 576 - // [eval] combinenew.e1.err.b: field not allowed: 577 - // ./old.cue:14:3 578 - } 579 - } 580 - } 581 - e2: (_|_){ 582 - // [eval] 583 - err: (_|_){ 584 - // [eval] 585 - a: (int){ 1 } 586 - b: (_|_){ 587 - // [eval] combinenew.e2.err.b: field not allowed: 588 - // ./new.cue:11:2 589 - } 590 - } 591 - } 592 - e3: (_|_){ 593 - // [eval] 594 - err: (_|_){ 595 - // [eval] 596 - a: (int){ 1 } 597 - b: (_|_){ 598 - // [eval] combinenew.e3.err.b: field not allowed: 599 - // ./new.cue:16:2 600 - } 601 - } 602 - } 603 - e4: (_|_){ 604 - // [eval] 605 - err: (_|_){ 606 - // [eval] 607 - a: (int){ 1 } 608 - b: (_|_){ 609 - // [eval] combinenew.e4.err.b: field not allowed: 610 - // ./old.cue:7:3 611 - } 612 - } 613 - } 614 - e5: (_|_){ 615 - // [eval] 616 - err: (_|_){ 617 - // [eval] 618 - a: (int){ 1 } 619 - b: (_|_){ 620 - // [eval] combinenew.e5.err.b: field not allowed: 621 - // ./old.cue:14:3 622 - } 623 - } 624 - } 625 - e6: (_|_){ 626 - // [eval] 627 - err: (_|_){ 628 - // [eval] 629 - a: (int){ 1 } 630 - b: (_|_){ 631 - // [eval] combinenew.e6.err.b: field not allowed: 632 - // ./new.cue:11:2 633 - } 634 - } 635 - } 636 - e7: (_|_){ 637 - // [eval] 638 - err: (_|_){ 639 - // [eval] 640 - a: (int){ 1 } 641 - b: (_|_){ 642 - // [eval] combinenew.e7.err.b: field not allowed: 643 - // ./new.cue:16:2 644 - } 645 - } 646 - } 647 - e8: (struct){ 648 - ok: (#struct){ 649 - a: (int){ 1 } 650 - b: (int){ 1 } 651 - } 652 - } 653 - e9: (struct){ 654 - ok: (#struct){ 655 - a: (int){ 1 } 656 - b: (int){ 1 } 657 - } 658 - } 659 - e10: (struct){ 660 - ok: (#struct){ 661 - a: (int){ 1 } 662 - b: (int){ 1 } 663 - } 664 - } 665 - e11: (struct){ 666 - ok: (#struct){ 667 - a: (int){ 1 } 668 - b: (int){ 1 } 669 - } 670 - } 671 - f0: (_|_){ 672 - // [eval] 673 - err: (_|_){ 674 - // [eval] 675 - b: (_|_){ 676 - // [eval] combinenew.f0.err.b: field not allowed: 677 - // ./old.cue:7:3 678 - } 679 - a: (int){ 1 } 680 - } 681 - } 682 - f1: (_|_){ 683 - // [eval] 684 - err: (_|_){ 685 - // [eval] 686 - b: (_|_){ 687 - // [eval] combinenew.f1.err.b: field not allowed: 688 - // ./old.cue:14:3 689 - } 690 - a: (int){ 1 } 691 - } 692 - } 693 - f2: (_|_){ 694 - // [eval] 695 - err: (_|_){ 696 - // [eval] 697 - b: (_|_){ 698 - // [eval] combinenew.f2.err.b: field not allowed: 699 - // ./new.cue:11:2 700 - } 701 - a: (int){ 1 } 702 - } 703 - } 704 - f3: (_|_){ 705 - // [eval] 706 - err: (_|_){ 707 - // [eval] 708 - b: (_|_){ 709 - // [eval] combinenew.f3.err.b: field not allowed: 710 - // ./new.cue:16:2 711 - } 712 - a: (int){ 1 } 713 - } 714 - } 715 - f4: (struct){ 716 - ok: ~(NewClosed1) 717 - } 718 - f5: (_|_){ 719 - // [eval] 720 - err: (_|_){ 721 - // [eval] 722 - b: (_|_){ 723 - // [eval] combinenew.f5.err.b: field not allowed: 724 - // ./old.cue:7:3 725 - } 726 - a: (int){ 1 } 727 - } 728 - } 729 - f6: (_|_){ 730 - // [eval] 731 - err: (_|_){ 732 - // [eval] 733 - b: (_|_){ 734 - // [eval] combinenew.f6.err.b: field not allowed: 735 - // ./old.cue:14:3 736 - } 737 - a: (int){ 1 } 738 - } 739 - } 740 - f7: (_|_){ 741 - // [eval] 742 - err: (_|_){ 743 - // [eval] 744 - b: (_|_){ 745 - // [eval] combinenew.f7.err.b: field not allowed: 746 - // ./new.cue:11:2 747 - } 748 - a: (int){ 1 } 749 - } 750 - } 751 - f8: (_|_){ 752 - // [eval] 753 - err: (_|_){ 754 - // [eval] 755 - b: (_|_){ 756 - // [eval] combinenew.f8.err.b: field not allowed: 757 - // ./new.cue:16:2 758 - } 759 - a: (int){ 1 } 760 - } 761 - } 762 - f9: (_|_){ 763 - // [eval] 764 - ok: (_|_){ 765 - // [eval] 766 - b: (_|_){ 767 - // [eval] combinenew.f9.ok.b: field not allowed: 768 - // ./old.cue:7:3 769 - } 770 - a: (int){ 1 } 771 - } 772 - } 773 - f10: (struct){ 774 - ok: (#struct){ 775 - b: (int){ 1 } 776 - a: (int){ 1 } 777 - } 778 - } 779 - f11: (struct){ 780 - ok: (#struct){ 781 - a: (int){ 1 } 782 - } 783 - } 784 - f12: (struct){ 785 - ok: (#struct){ 786 - b: (int){ 1 } 787 - a: (int){ 1 } 788 - } 789 - } 790 - f13: (struct){ 791 - ok: (#struct){ 792 - b: (int){ 1 } 793 - a: (int){ 1 } 794 - } 795 - } 796 - f14: (struct){ 797 - err: (#struct){ 798 - b: (int){ 1 } 799 - a: (int){ 1 } 800 - } 801 - } 802 - f15: (struct){ 803 - err: (#struct){ 804 - b: (int){ 1 } 805 - a: (int){ 1 } 806 - } 807 - } 808 - f16: (_|_){ 809 - // [eval] 810 - err: (_|_){ 811 - // [eval] 812 - b: (_|_){ 813 - // [eval] combinenew.f16.err.b: field not allowed: 814 - // ./new.cue:11:2 815 - } 816 - a: (int){ 1 } 817 - } 818 - } 819 - f17: (_|_){ 820 - // [eval] 821 - err: (_|_){ 822 - // [eval] 823 - b: (_|_){ 824 - // [eval] combinenew.f17.err.b: field not allowed: 825 - // ./new.cue:16:2 826 - } 827 - a: (int){ 1 } 828 - } 829 - } 830 - f18: (struct){ 831 - ok: ~(NewClosed1) 832 - } 833 - } 834 - #A: (#struct){ 835 - a: (int){ 1 } 836 - } 837 - Old1: (#struct){ 838 - b: (int){ 1 } 839 - a: (int){ 1 } 840 - } 841 - #Old2: (#struct){ 842 - b: (int){ 1 } 843 - a: (int){ 1 } 844 - } 845 - useNewClosed1: (_|_){ 846 - // [eval] 847 - t1: (_|_){ 848 - // [eval] 849 - err: (_|_){ 850 - // [eval] 851 - c: (_|_){ 852 - // [eval] useNewClosed1.t1.err.c: field not allowed: 853 - // ./old.cue:19:25 854 - } 855 - a: (int){ 1 } 856 - } 857 - } 858 - t2: (struct){ 859 - ok: (#struct){ 860 - c: (int){ 3 } 861 - a: (int){ 1 } 862 - } 863 - } 864 - } 865 - useNewClosed2: (_|_){ 866 - // [eval] 867 - t1: (_|_){ 868 - // [eval] 869 - err: (_|_){ 870 - // [eval] 871 - c: (_|_){ 872 - // [eval] useNewClosed2.t1.err.c: field not allowed: 873 - // ./old.cue:24:26 874 - } 875 - b: (int){ 1 } 876 - a: (int){ 1 } 877 - } 878 - } 879 - t2: (struct){ 880 - ok: (#struct){ 881 - c: (int){ 3 } 882 - b: (int){ 1 } 883 - a: (int){ 1 } 884 - } 885 - } 886 - } 887 - useNewOpen1: (struct){ 888 - t1: (struct){ 889 - ok: (#struct){ 890 - c: (int){ 3 } 891 - b: (int){ 1 } 892 - a: (int){ 1 } 893 - } 894 - } 895 - t2: (struct){ 896 - ok: (#struct){ 897 - c: (int){ 3 } 898 - b: (int){ 1 } 899 - a: (int){ 1 } 900 - } 901 - } 902 - } 903 - useNewOpen2: (struct){ 904 - t1: (struct){ 905 - ok: (#struct){ 906 - c: (int){ 3 } 907 - a: (int){ 1 } 908 - } 909 - } 910 - t2: (struct){ 911 - ok: (#struct){ 912 - c: (int){ 3 } 913 - a: (int){ 1 } 914 - } 915 - } 916 - } 917 - combineold: (_|_){ 918 - // [eval] 919 - a0: (struct){ 920 - ok: (#struct){ 921 - a: (int){ 1 } 922 - } 923 - } 924 - a1: (struct){ 925 - ok: (#struct){ 926 - a: (int){ 1 } 927 - } 928 - } 929 - a2: (struct){ 930 - ok: (#struct){ 931 - a: (int){ 1 } 932 - } 933 - } 934 - a3: (struct){ 935 - ok: (#struct){ 936 - a: (int){ 1 } 937 - } 938 - } 939 - b0: (struct){ 940 - ok: (#struct){ 941 - b: (int){ 1 } 942 - a: (int){ 1 } 943 - } 944 - } 945 - b1: (struct){ 946 - ok: (#struct){ 947 - b: (int){ 1 } 948 - a: (int){ 1 } 949 - } 950 - } 951 - c1: (struct){ 952 - ok: (#struct){ 953 - b: (int){ 1 } 954 - a: (int){ 1 } 955 - } 956 - } 957 - c2: (struct){ 958 - ok: (#struct){ 959 - b: (int){ 1 } 960 - a: (int){ 1 } 961 - } 962 - } 963 - e0: (_|_){ 964 - // [eval] 965 - err: (_|_){ 966 - // [eval] 967 - a: (int){ 1 } 968 - b: (_|_){ 969 - // [eval] combineold.e0.err.b: field not allowed: 970 - // ./old.cue:7:3 971 - } 972 - } 973 - } 974 - e1: (_|_){ 975 - // [eval] 976 - err: (_|_){ 977 - // [eval] 978 - a: (int){ 1 } 979 - b: (_|_){ 980 - // [eval] combineold.e1.err.b: field not allowed: 981 - // ./old.cue:14:3 982 - } 983 - } 984 - } 985 - e2: (_|_){ 986 - // [eval] 987 - err: (_|_){ 988 - // [eval] 989 - a: (int){ 1 } 990 - b: (_|_){ 991 - // [eval] combineold.e2.err.b: field not allowed: 992 - // ./new.cue:11:2 993 - } 994 - } 995 - } 996 - e3: (_|_){ 997 - // [eval] 998 - err: (_|_){ 999 - // [eval] 1000 - a: (int){ 1 } 1001 - b: (_|_){ 1002 - // [eval] combineold.e3.err.b: field not allowed: 1003 - // ./new.cue:16:2 1004 - } 1005 - } 1006 - } 1007 - e4: (struct){ 1008 - ok: (#struct){ 1009 - a: (int){ 1 } 1010 - b: (int){ 1 } 1011 - } 1012 - } 1013 - e5: (struct){ 1014 - ok: (#struct){ 1015 - a: (int){ 1 } 1016 - b: (int){ 1 } 1017 - } 1018 - } 1019 - e6: (struct){ 1020 - ok: (#struct){ 1021 - a: (int){ 1 } 1022 - b: (int){ 1 } 1023 - } 1024 - } 1025 - e7: (struct){ 1026 - ok: (#struct){ 1027 - a: (int){ 1 } 1028 - b: (int){ 1 } 1029 - } 1030 - } 1031 - f0: (_|_){ 1032 - // [eval] 1033 - err: (_|_){ 1034 - // [eval] 1035 - b: (_|_){ 1036 - // [eval] combineold.f0.err.b: field not allowed: 1037 - // ./old.cue:7:3 1038 - } 1039 - a: (int){ 1 } 1040 - } 1041 - } 1042 - f1: (_|_){ 1043 - // [eval] 1044 - err: (_|_){ 1045 - // [eval] 1046 - b: (_|_){ 1047 - // [eval] combineold.f1.err.b: field not allowed: 1048 - // ./old.cue:14:3 1049 - } 1050 - a: (int){ 1 } 1051 - } 1052 - } 1053 - f2: (_|_){ 1054 - // [eval] 1055 - err: (_|_){ 1056 - // [eval] 1057 - b: (_|_){ 1058 - // [eval] combineold.f2.err.b: field not allowed: 1059 - // ./new.cue:11:2 1060 - } 1061 - a: (int){ 1 } 1062 - } 1063 - } 1064 - f3: (_|_){ 1065 - // [eval] 1066 - err: (_|_){ 1067 - // [eval] 1068 - b: (_|_){ 1069 - // [eval] combineold.f3.err.b: field not allowed: 1070 - // ./new.cue:16:2 1071 - } 1072 - a: (int){ 1 } 1073 - } 1074 - } 1075 - f4: (struct){ 1076 - ok: (#struct){ 1077 - b: (int){ 1 } 1078 - a: (int){ 1 } 1079 - } 1080 - } 1081 - f5: (struct){ 1082 - ok: (#struct){ 1083 - b: (int){ 1 } 1084 - a: (int){ 1 } 1085 - } 1086 - } 1087 - f6: (struct){ 1088 - ok: (#struct){ 1089 - a: (int){ 1 } 1090 - } 1091 - } 1092 - f7: (struct){ 1093 - ok: (#struct){ 1094 - b: (int){ 1 } 1095 - a: (int){ 1 } 1096 - } 1097 - } 1098 - f8: (struct){ 1099 - ok: (#struct){ 1100 - b: (int){ 1 } 1101 - a: (int){ 1 } 1102 - } 1103 - } 1104 - } 1105 - } 292 + -- out/diff-v2-v3.txt -- 293 + f9: combinenew.f9.ok is in error because two f9 declarations conflict. 294 + f14/f15: combinenew.f14.err and f15.err are NOT in error (v3 allows these). 295 + Structure sharing: NewOpen2: ~(#A), combinenew.f4.ok ~(NewClosed1), combinenew.f18.ok ~(NewClosed1). 1106 296 -- out/compile -- 1107 297 --- issues.cue 1108 298 {
+176 -1440
cue/testdata/definitions/fields.txtar
··· 1 1 // Tests fields.go 2 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 3 2 -- in.cue -- 4 3 // TODO: reorganize ordered on what is tested by name. E.g. 5 4 // insertion: longPath: ok: p1: { ··· 8 7 9 8 ok: t1: { 10 9 c: #R 11 - c: [{b: int}] 12 - #R: [...] 10 + c: [{b: int}] @test(allows=false, int) 11 + #R: [...] @test(allows, int) 12 + 13 + @test(eq, { 14 + c: [{b: int}] 15 + #R: [] 16 + }) 13 17 } 14 18 15 19 ok: t2: { 16 20 #A: _ 17 21 l: #A 18 22 l: f: "hi" 23 + 24 + @test(eq, { 25 + #A: _ 26 + l: f: "hi" 27 + }) 19 28 } 20 29 21 30 ok: t3: { ··· 23 32 #A1: { #A } 24 33 s: [string]: #A1 25 34 s: foo: f: d: foo: 1 35 + 36 + @test(eq, { 37 + #A: f: {} 38 + #A1: f: {} 39 + s: foo: f: d: foo: 1 40 + }) 26 41 } 27 42 28 43 ok: t4: { ··· 31 46 {#T} 32 47 b: c: 2 33 48 } 49 + 50 + @test(eq, { 51 + #T: a: b: 1 52 + W: { 53 + a: b: 1 54 + b: c: 2 55 + } 56 + }) 34 57 } 35 58 36 59 ok: t5: { ··· 41 64 } 42 65 Common: { } 43 66 x: #A 44 - x: c: int 67 + x: c: int @test(err, code=eval, 68 + hint="not sure if this is actually correct", 69 + contains="field not allowed", pos=[0:5]) 45 70 } 46 71 47 72 ok: t6: { ··· 50 75 ... 51 76 } 52 77 Common: { } 53 - x: #A 78 + x: #A @test(allows, string) 54 79 x: c: int 80 + 81 + @test(eq, { 82 + #A: {} 83 + Common: {} 84 + x: c: int 85 + }) 55 86 } 56 87 57 88 ok: t7: { 58 89 a: {#A, #B} 59 90 #A: b: f: 1 60 91 #B: b: g: 1 92 + 93 + @test(eq, { 94 + a: b: { 95 + f: 1 96 + g: 1 97 + } 98 + #A: b: f: 1 99 + #B: b: g: 1 100 + }) 61 101 } 62 102 63 103 ok: t8: { 64 104 // TODO: this should pass 65 - foo: #X 105 + foo: #X @test(shareID=ok_t8_foox) 66 106 #X: { 107 + @test(shareID=ok_t8_foox) 108 + 67 109 a: b: c: C: 1 68 110 for k, _ in a { 69 111 // dynamic field causes insertion one level higher. This causes ··· 71 113 a: (k): c: D: 2 72 114 } 73 115 } 116 + 117 + @test(eq, { 118 + foo: a: b: c: { 119 + C: 1 120 + D: 2 121 + } 122 + #X: a: b: c: { 123 + C: 1 124 + D: 2 125 + } 126 + }) 74 127 } 75 128 76 129 ok: t9: { 77 130 c: #R 78 131 c: [{b: int}] 79 132 #R: [...] 133 + 134 + @test(eq, { 135 + c: [{ 136 + b: int 137 + }] 138 + #R: [] 139 + }) 80 140 } 81 141 82 142 ok: t10: { 83 143 #A: _ // top should allow everything 84 144 l: #A 85 145 l: f: "hi" 146 + 147 + @test(eq, { 148 + #A: _ 149 + l: f: "hi" 150 + }) 86 151 } 87 152 88 153 ok: t11: { ··· 91 156 #A1: { #A } 92 157 s: [string]: #A1 93 158 s: foo: f: d: foo: "bar" // should pass 159 + 160 + @test(eq, { 161 + #A: f: {} 162 + #A1: f: {} 163 + s: foo: f: d: foo: "bar" 164 + }) 94 165 } 95 166 96 167 ok: t12: { ··· 100 171 {#T} 101 172 b: c: 2 102 173 } 174 + 175 + @test(eq, { 176 + #T: { a: b: 1 } 177 + W: { 178 + a: b: 1 179 + b: c: 2 180 + } 181 + }) 103 182 } 104 183 105 184 ok: t13: { ··· 112 191 } 113 192 Common: { } 114 193 x: #A 115 - x: c: int 194 + x: c: int @test(err, code=eval, contains="field not allowed", pos=[0:5]) 195 + 196 + @test(eq, { 197 + #A: {} 198 + Common: {} 199 + x: c: _|_ 200 + }) 116 201 } 117 202 118 203 ok: t14: { ··· 124 209 Common: { } 125 210 x: #A 126 211 x: c: int 212 + 213 + @test(eq, { 214 + #A: {} 215 + Common: {} 216 + x: c: int 217 + }) 127 218 } 128 219 129 220 // TODO: move this test to "ok": _ means any and implicitly defines all fields ··· 133 224 // either allow for an error variant that only "allows" all fields but does not 134 225 // define them as optional top, or rethink the closedness model altogether. 135 226 err: t1: { 227 + @test(permute) 136 228 #D: _ & {a: 2} 137 229 a: #D 138 - a: disallowed: 1 230 + a: disallowed: 1 @test(err, code=eval, contains="field not allowed", pos=[0:5]) 139 231 } 140 232 141 233 err: t2: { 234 + @test(permute) 142 235 #S: { { c: d: 1 } } 143 236 V: #S 144 - V: { c: e: 1 } 237 + V: { c: e: 1 @test(err, code=eval, contains="field not allowed", pos=[0:10]) } 145 238 } 146 239 147 - err: t3: p1: { 240 + err: t3: { 241 + @test(permute) 148 242 #D: {} 149 243 a: #D 150 - a: c: "C" 151 - } 152 - 153 - err: t3: p2: { 154 - #D: b: {} 155 - a: #D 156 - a: b: c: "C" 244 + a: c: "C" @test(err, code=eval, contains="field not allowed", pos=[0:5]) 157 245 } 158 246 159 247 err: t4: { 248 + @test(permute) 160 249 a: #A 161 250 #A: b: f: 1 162 - a: b: h: 1 251 + a: b: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:8]) 163 252 } 164 253 165 254 err: t5: { 255 + @test(permute) 166 256 // TODO: this should fail 167 257 a: {#A, #B} 168 258 #A: b: f: 1 169 259 #B: b: g: 1 170 260 b: a 171 - b: b: h: 1 // only an error here 261 + b: b: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:8]) 172 262 } 173 263 174 264 err: t6: { 265 + @test(permute) 175 266 // TODO: this should fail 176 267 a: {#A, #B} 177 268 #A: b: c: d: e: f: 1 178 269 #B: b: c: d: e: g: 1 179 270 b: a 180 - b: b: c: d: e: h: 1 // only an error here 271 + b: b: c: d: e: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:17]) 181 272 } 182 273 183 274 // TODO: move this test to "ok": _ means any and implicitly defines all fields ··· 187 278 // either allow for an error variant that only "allows" all fields but does not 188 279 // define them as optional top, or rethink the closedness model altogether. 189 280 err: t7: { 281 + @test(permute) 190 282 #D: _ & {a: 2} 191 283 a: #D 192 - a: b: 1 284 + a: b: 1 @test(err, code=eval, contains="field not allowed", pos=[0:5]) 193 285 } 194 286 195 287 err: t8: { 288 + @test(permute) 196 289 // nested embedding 197 290 #S: { { c: d: 1 } } 198 291 V: #S 199 - V: { c: e: 1 } // Should fail 292 + V: { c: e: 1 @test(err, code=eval, contains="field not allowed", pos=[0:10]) } 200 293 } 201 294 -- validators.cue -- 202 295 import "struct" ··· 213 306 } 214 307 data: trailingComma: "all" 215 308 data: #Schema 309 + 310 + @test(eq, { 311 + #Schema: { 312 + matchN(1, [{trailingComma: "all"}]) 313 + #x: trailingComma?: "all" 314 + } 315 + data: { 316 + // TODO: why is the matchN dropped here? 317 + trailingComma: "all" 318 + #x: trailingComma?: "all" 319 + } 320 + }) 216 321 } 217 322 218 323 validator: keepClosed: { ··· 222 327 b?: int 223 328 } 224 329 x: #X 225 - x: c: 1 330 + x: c: 1 @test(err, code=eval, contains="field not allowed", pos=[-5:3, 0:5]) 226 331 } 227 332 -- issue1830.cue -- 228 333 // Closedness was not applied when accessing optional fields through a selector; ··· 241 346 x1: (#x & {y: z: _}).y.z & { 242 347 name: "blah" 243 348 age1: 5 244 - } 349 + } @test(closed) @test(eq, { name: "blah", age1: 5 }, incorrect) 245 350 x2: (#x.y & {z: _}).z & { 246 351 name: "blah" 247 352 age2: 5 248 - } 353 + } @test(closed) @test(eq, { name: "blah", age2: 5 }, incorrect) 354 + 355 + @test(err:todo, at=x1.age1, code=eval, contains="field not allowed") 356 + @test(err:todo, at=x2.age2, code=eval, contains="field not allowed") 249 357 } 250 358 } 251 359 -- issue3491.cue -- ··· 254 362 // https://cuelang.org/issue/3491 255 363 issue3491: { 256 364 #Schema: field?: {} 257 - 365 + 258 366 a: #Schema & { 259 367 field: {} 260 368 } 261 - 369 + 262 370 a: b 263 371 b: #Extra: {} 372 + 373 + @test(eq, { 374 + #Schema: field?: {} 375 + a: { 376 + field: {} 377 + #Extra: {} 378 + } 379 + b: #Extra: {} 380 + }) 264 381 } 265 382 -- out/eval/stats -- 266 383 Leaks: 1 ··· 274 391 Disjuncts: 0 275 392 276 393 NumCloseIDs: 122 277 - -- out/evalalpha -- 278 - Errors: 279 - err.t1.a.disallowed: field not allowed: 280 - ./in.cue:135:5 281 - err.t2.V.c.e: field not allowed: 282 - ./in.cue:141:10 283 - err.t3.p1.a.c: field not allowed: 284 - ./in.cue:147:5 285 - err.t3.p2.a.b.c: field not allowed: 286 - ./in.cue:153:8 287 - err.t4.a.b.h: field not allowed: 288 - ./in.cue:159:8 289 - err.t5.b.b.h: field not allowed: 290 - ./in.cue:168:8 291 - err.t6.b.b.c.d.e.h: field not allowed: 292 - ./in.cue:177:17 293 - err.t7.a.b: field not allowed: 294 - ./in.cue:189:5 295 - err.t8.V.c.e: field not allowed: 296 - ./in.cue:196:10 297 - ok.t13.x.c: field not allowed: 298 - ./in.cue:112:5 299 - ok.t5.x.c: field not allowed: 300 - ./in.cue:41:5 301 - validator.keepClosed.x.c: field not allowed: 302 - ./validators.cue:19:3 303 - ./validators.cue:24:5 304 - 305 - Result: 306 - (_|_){ 307 - // [eval] 308 - ok: (_|_){ 309 - // [eval] 310 - t1: (struct){ 311 - c: (#list){ 312 - 0: (#struct){ 313 - b: (int){ int } 314 - } 315 - } 316 - #R: (list){ 317 - } 318 - } 319 - t2: (struct){ 320 - #A: (_){ _ } 321 - l: (#struct){ 322 - f: (string){ "hi" } 323 - } 324 - } 325 - t3: (struct){ 326 - #A: (#struct){ 327 - f: (#struct){ 328 - } 329 - } 330 - #A1: (#struct){ 331 - f: (#struct){ 332 - } 333 - } 334 - s: (struct){ 335 - foo: (#struct){ 336 - f: (#struct){ 337 - d: (struct){ 338 - foo: (int){ 1 } 339 - } 340 - } 341 - } 342 - } 343 - } 344 - t4: (struct){ 345 - #T: (#struct){ 346 - a: (#struct){ 347 - b: (int){ 1 } 348 - } 349 - } 350 - W: (#struct){ 351 - b: (struct){ 352 - c: (int){ 2 } 353 - } 354 - a: (#struct){ 355 - b: (int){ 1 } 356 - } 357 - } 358 - } 359 - t5: (_|_){ 360 - // [eval] 361 - #A: (#struct){ 362 - } 363 - Common: (struct){ 364 - } 365 - x: (_|_){ 366 - // [eval] 367 - c: (_|_){ 368 - // [eval] ok.t5.x.c: field not allowed: 369 - // ./in.cue:41:5 370 - } 371 - } 372 - } 373 - t6: (struct){ 374 - #A: (#struct){ 375 - } 376 - Common: (struct){ 377 - } 378 - x: (#struct){ 379 - c: (int){ int } 380 - } 381 - } 382 - t7: (struct){ 383 - a: (#struct){ 384 - b: (#struct){ 385 - f: (int){ 1 } 386 - g: (int){ 1 } 387 - } 388 - } 389 - #A: (#struct){ 390 - b: (#struct){ 391 - f: (int){ 1 } 392 - } 393 - } 394 - #B: (#struct){ 395 - b: (#struct){ 396 - g: (int){ 1 } 397 - } 398 - } 399 - } 400 - t8: (struct){ 401 - foo: ~(ok.t8.#X) 402 - #X: (#struct){ 403 - a: (#struct){ 404 - b: (#struct){ 405 - c: (#struct){ 406 - C: (int){ 1 } 407 - D: (int){ 2 } 408 - } 409 - } 410 - } 411 - } 412 - } 413 - t9: (struct){ 414 - c: (#list){ 415 - 0: (#struct){ 416 - b: (int){ int } 417 - } 418 - } 419 - #R: (list){ 420 - } 421 - } 422 - t10: (struct){ 423 - #A: (_){ _ } 424 - l: (#struct){ 425 - f: (string){ "hi" } 426 - } 427 - } 428 - t11: (struct){ 429 - #A: (#struct){ 430 - f: (#struct){ 431 - } 432 - } 433 - #A1: (#struct){ 434 - f: (#struct){ 435 - } 436 - } 437 - s: (struct){ 438 - foo: (#struct){ 439 - f: (#struct){ 440 - d: (struct){ 441 - foo: (string){ "bar" } 442 - } 443 - } 444 - } 445 - } 446 - } 447 - t12: (struct){ 448 - #T: (#struct){ 449 - a: (#struct){ 450 - b: (int){ 1 } 451 - } 452 - } 453 - W: (#struct){ 454 - b: (struct){ 455 - c: (int){ 2 } 456 - } 457 - a: (#struct){ 458 - b: (int){ 1 } 459 - } 460 - } 461 - } 462 - t13: (_|_){ 463 - // [eval] 464 - #A: (#struct){ 465 - } 466 - Common: (struct){ 467 - } 468 - x: (_|_){ 469 - // [eval] 470 - c: (_|_){ 471 - // [eval] ok.t13.x.c: field not allowed: 472 - // ./in.cue:112:5 473 - } 474 - } 475 - } 476 - t14: (struct){ 477 - #A: (#struct){ 478 - } 479 - Common: (struct){ 480 - } 481 - x: (#struct){ 482 - c: (int){ int } 483 - } 484 - } 485 - } 486 - err: (_|_){ 487 - // [eval] 488 - t1: (_|_){ 489 - // [eval] 490 - #D: (#struct){ 491 - a: (int){ 2 } 492 - } 493 - a: (_|_){ 494 - // [eval] 495 - disallowed: (_|_){ 496 - // [eval] err.t1.a.disallowed: field not allowed: 497 - // ./in.cue:135:5 498 - } 499 - a: (int){ 2 } 500 - } 501 - } 502 - t2: (_|_){ 503 - // [eval] 504 - #S: (#struct){ 505 - c: (#struct){ 506 - d: (int){ 1 } 507 - } 508 - } 509 - V: (_|_){ 510 - // [eval] 511 - c: (_|_){ 512 - // [eval] 513 - e: (_|_){ 514 - // [eval] err.t2.V.c.e: field not allowed: 515 - // ./in.cue:141:10 516 - } 517 - d: (int){ 1 } 518 - } 519 - } 520 - } 521 - t3: (_|_){ 522 - // [eval] 523 - p1: (_|_){ 524 - // [eval] 525 - #D: (#struct){ 526 - } 527 - a: (_|_){ 528 - // [eval] 529 - c: (_|_){ 530 - // [eval] err.t3.p1.a.c: field not allowed: 531 - // ./in.cue:147:5 532 - } 533 - } 534 - } 535 - p2: (_|_){ 536 - // [eval] 537 - #D: (#struct){ 538 - b: (#struct){ 539 - } 540 - } 541 - a: (_|_){ 542 - // [eval] 543 - b: (_|_){ 544 - // [eval] 545 - c: (_|_){ 546 - // [eval] err.t3.p2.a.b.c: field not allowed: 547 - // ./in.cue:153:8 548 - } 549 - } 550 - } 551 - } 552 - } 553 - t4: (_|_){ 554 - // [eval] 555 - a: (_|_){ 556 - // [eval] 557 - b: (_|_){ 558 - // [eval] 559 - h: (_|_){ 560 - // [eval] err.t4.a.b.h: field not allowed: 561 - // ./in.cue:159:8 562 - } 563 - f: (int){ 1 } 564 - } 565 - } 566 - #A: (#struct){ 567 - b: (#struct){ 568 - f: (int){ 1 } 569 - } 570 - } 571 - } 572 - t5: (_|_){ 573 - // [eval] 574 - a: (#struct){ 575 - b: (#struct){ 576 - f: (int){ 1 } 577 - g: (int){ 1 } 578 - } 579 - } 580 - #A: (#struct){ 581 - b: (#struct){ 582 - f: (int){ 1 } 583 - } 584 - } 585 - #B: (#struct){ 586 - b: (#struct){ 587 - g: (int){ 1 } 588 - } 589 - } 590 - b: (_|_){ 591 - // [eval] 592 - b: (_|_){ 593 - // [eval] 594 - h: (_|_){ 595 - // [eval] err.t5.b.b.h: field not allowed: 596 - // ./in.cue:168:8 597 - } 598 - f: (int){ 1 } 599 - g: (int){ 1 } 600 - } 601 - } 602 - } 603 - t6: (_|_){ 604 - // [eval] 605 - a: (#struct){ 606 - b: (#struct){ 607 - c: (#struct){ 608 - d: (#struct){ 609 - e: (#struct){ 610 - f: (int){ 1 } 611 - g: (int){ 1 } 612 - } 613 - } 614 - } 615 - } 616 - } 617 - #A: (#struct){ 618 - b: (#struct){ 619 - c: (#struct){ 620 - d: (#struct){ 621 - e: (#struct){ 622 - f: (int){ 1 } 623 - } 624 - } 625 - } 626 - } 627 - } 628 - #B: (#struct){ 629 - b: (#struct){ 630 - c: (#struct){ 631 - d: (#struct){ 632 - e: (#struct){ 633 - g: (int){ 1 } 634 - } 635 - } 636 - } 637 - } 638 - } 639 - b: (_|_){ 640 - // [eval] 641 - b: (_|_){ 642 - // [eval] 643 - c: (_|_){ 644 - // [eval] 645 - d: (_|_){ 646 - // [eval] 647 - e: (_|_){ 648 - // [eval] 649 - h: (_|_){ 650 - // [eval] err.t6.b.b.c.d.e.h: field not allowed: 651 - // ./in.cue:177:17 652 - } 653 - f: (int){ 1 } 654 - g: (int){ 1 } 655 - } 656 - } 657 - } 658 - } 659 - } 660 - } 661 - t7: (_|_){ 662 - // [eval] 663 - #D: (#struct){ 664 - a: (int){ 2 } 665 - } 666 - a: (_|_){ 667 - // [eval] 668 - b: (_|_){ 669 - // [eval] err.t7.a.b: field not allowed: 670 - // ./in.cue:189:5 671 - } 672 - a: (int){ 2 } 673 - } 674 - } 675 - t8: (_|_){ 676 - // [eval] 677 - #S: (#struct){ 678 - c: (#struct){ 679 - d: (int){ 1 } 680 - } 681 - } 682 - V: (_|_){ 683 - // [eval] 684 - c: (_|_){ 685 - // [eval] 686 - e: (_|_){ 687 - // [eval] err.t8.V.c.e: field not allowed: 688 - // ./in.cue:196:10 689 - } 690 - d: (int){ 1 } 691 - } 692 - } 693 - } 694 - } 695 - issue1830: (struct){ 696 - #x: (#struct){ 697 - y: (#struct){ 698 - z?: (#struct){ 699 - name: (string){ string } 700 - } 701 - } 702 - } 703 - egs: (struct){ 704 - x1: (#struct){ 705 - name: (string){ "blah" } 706 - age1: (int){ 5 } 707 - } 708 - x2: (#struct){ 709 - name: (string){ "blah" } 710 - age2: (int){ 5 } 711 - } 712 - } 713 - } 714 - issue3491: (struct){ 715 - #Schema: (#struct){ 716 - field?: (#struct){ 717 - } 718 - } 719 - a: (#struct){ 720 - field: (#struct){ 721 - } 722 - #Extra: (#struct){ 723 - } 724 - } 725 - b: (struct){ 726 - #Extra: (#struct){ 727 - } 728 - } 729 - } 730 - validator: (_|_){ 731 - // [eval] 732 - open: (struct){ 733 - #Schema: (_){ 734 - matchN(1, (#list){ 735 - 0: (_|_){// 〈1;#x〉 736 - } 737 - }) 738 - #x: (#struct){ 739 - trailingComma?: (string){ "all" } 740 - } 741 - } 742 - data: (#struct){ 743 - trailingComma: (string){ "all" } 744 - #x: (#struct){ 745 - trailingComma?: (string){ "all" } 746 - } 747 - } 748 - } 749 - keepClosed: (_|_){ 750 - // [eval] 751 - #X: (#struct){ 752 - a?: (int){ int } 753 - b?: (int){ int } 754 - } 755 - x: (_|_){ 756 - // [eval] 757 - c: (_|_){ 758 - // [eval] validator.keepClosed.x.c: field not allowed: 759 - // ./validators.cue:19:3 760 - // ./validators.cue:24:5 761 - } 762 - a?: (int){ int } 763 - b?: (int){ int } 764 - } 765 - } 766 - } 767 - } 768 - -- diff/-out/evalalpha<==>+out/eval -- 769 - diff old new 770 - --- old 771 - +++ new 772 - @@ -1,74 +1,29 @@ 773 - Errors: 774 - err.t1.a.disallowed: field not allowed: 775 - - ./in.cue:133:10 776 - - ./in.cue:134:5 777 - ./in.cue:135:5 778 - err.t2.V.c.e: field not allowed: 779 - - ./in.cue:139:8 780 - - ./in.cue:139:13 781 - - ./in.cue:140:5 782 - ./in.cue:141:10 783 - err.t3.p1.a.c: field not allowed: 784 - - ./in.cue:145:6 785 - - ./in.cue:146:5 786 - ./in.cue:147:5 787 - err.t3.p2.a.b.c: field not allowed: 788 - - ./in.cue:151:9 789 - - ./in.cue:152:5 790 - ./in.cue:153:8 791 - err.t4.a.b.h: field not allowed: 792 - - ./in.cue:157:5 793 - - ./in.cue:158:9 794 - ./in.cue:159:8 795 - err.t5.b.b.h: field not allowed: 796 - - ./in.cue:164:6 797 - - ./in.cue:164:10 798 - - ./in.cue:165:9 799 - - ./in.cue:166:9 800 - - ./in.cue:167:5 801 - ./in.cue:168:8 802 - err.t6.b.b.c.d.e.h: field not allowed: 803 - - ./in.cue:173:6 804 - - ./in.cue:173:10 805 - - ./in.cue:174:18 806 - - ./in.cue:175:18 807 - - ./in.cue:176:5 808 - ./in.cue:177:17 809 - err.t7.a.b: field not allowed: 810 - - ./in.cue:187:10 811 - - ./in.cue:188:5 812 - ./in.cue:189:5 813 - err.t8.V.c.e: field not allowed: 814 - - ./in.cue:194:8 815 - - ./in.cue:194:13 816 - - ./in.cue:195:5 817 - ./in.cue:196:10 818 - ok.t13.x.c: field not allowed: 819 - - ./in.cue:106:6 820 - - ./in.cue:107:3 821 - - ./in.cue:110:10 822 - - ./in.cue:111:5 823 - ./in.cue:112:5 824 - ok.t5.x.c: field not allowed: 825 - - ./in.cue:35:6 826 - - ./in.cue:36:3 827 - - ./in.cue:39:10 828 - - ./in.cue:40:5 829 - ./in.cue:41:5 830 - validator.keepClosed.x.c: field not allowed: 831 - - ./validators.cue:18:6 832 - - ./validators.cue:23:5 833 - + ./validators.cue:19:3 834 - ./validators.cue:24:5 835 - -validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:_|_(validator.open.data.trailingComma: field not allowed)} (does not satisfy matchN): 0 matched, expected 1: 836 - - ./validators.cue:10:3 837 - - ./validators.cue:10:10 838 - - ./validators.cue:13:8 839 - - ./validators.cue:14:8 840 - -validator.open.data.trailingComma: field not allowed: 841 - - ./validators.cue:10:3 842 - - ./validators.cue:9:11 843 - - ./validators.cue:13:8 844 - - ./validators.cue:14:8 845 - 846 - Result: 847 - (_|_){ 848 - @@ -116,11 +71,11 @@ 849 - } 850 - } 851 - W: (#struct){ 852 - - a: (#struct){ 853 - - b: (int){ 1 } 854 - - } 855 - - b: (struct){ 856 - - c: (int){ 2 } 857 - + b: (struct){ 858 - + c: (int){ 2 } 859 - + } 860 - + a: (#struct){ 861 - + b: (int){ 1 } 862 - } 863 - } 864 - } 865 - @@ -134,10 +89,6 @@ 866 - // [eval] 867 - c: (_|_){ 868 - // [eval] ok.t5.x.c: field not allowed: 869 - - // ./in.cue:35:6 870 - - // ./in.cue:36:3 871 - - // ./in.cue:39:10 872 - - // ./in.cue:40:5 873 - // ./in.cue:41:5 874 - } 875 - } 876 - @@ -223,11 +174,11 @@ 877 - } 878 - } 879 - W: (#struct){ 880 - - a: (#struct){ 881 - - b: (int){ 1 } 882 - - } 883 - - b: (struct){ 884 - - c: (int){ 2 } 885 - + b: (struct){ 886 - + c: (int){ 2 } 887 - + } 888 - + a: (#struct){ 889 - + b: (int){ 1 } 890 - } 891 - } 892 - } 893 - @@ -241,10 +192,6 @@ 894 - // [eval] 895 - c: (_|_){ 896 - // [eval] ok.t13.x.c: field not allowed: 897 - - // ./in.cue:106:6 898 - - // ./in.cue:107:3 899 - - // ./in.cue:110:10 900 - - // ./in.cue:111:5 901 - // ./in.cue:112:5 902 - } 903 - } 904 - @@ -286,14 +233,11 @@ 905 - // [eval] 906 - c: (_|_){ 907 - // [eval] 908 - - d: (int){ 1 } 909 - e: (_|_){ 910 - // [eval] err.t2.V.c.e: field not allowed: 911 - - // ./in.cue:139:8 912 - - // ./in.cue:139:13 913 - - // ./in.cue:140:5 914 - // ./in.cue:141:10 915 - } 916 - + d: (int){ 1 } 917 - } 918 - } 919 - } 920 - @@ -307,8 +251,6 @@ 921 - // [eval] 922 - c: (_|_){ 923 - // [eval] err.t3.p1.a.c: field not allowed: 924 - - // ./in.cue:145:6 925 - - // ./in.cue:146:5 926 - // ./in.cue:147:5 927 - } 928 - } 929 - @@ -325,8 +267,6 @@ 930 - // [eval] 931 - c: (_|_){ 932 - // [eval] err.t3.p2.a.b.c: field not allowed: 933 - - // ./in.cue:151:9 934 - - // ./in.cue:152:5 935 - // ./in.cue:153:8 936 - } 937 - } 938 - @@ -339,54 +279,47 @@ 939 - // [eval] 940 - b: (_|_){ 941 - // [eval] 942 - - f: (int){ 1 } 943 - h: (_|_){ 944 - // [eval] err.t4.a.b.h: field not allowed: 945 - - // ./in.cue:157:5 946 - - // ./in.cue:158:9 947 - // ./in.cue:159:8 948 - } 949 - - } 950 - - } 951 - - #A: (#struct){ 952 - - b: (#struct){ 953 - - f: (int){ 1 } 954 - - } 955 - - } 956 - - } 957 - - t5: (_|_){ 958 - - // [eval] 959 - - a: (#struct){ 960 - - b: (#struct){ 961 - - f: (int){ 1 } 962 - - g: (int){ 1 } 963 - - } 964 - - } 965 - - #A: (#struct){ 966 - - b: (#struct){ 967 - - f: (int){ 1 } 968 - - } 969 - - } 970 - - #B: (#struct){ 971 - - b: (#struct){ 972 - - g: (int){ 1 } 973 - - } 974 - - } 975 - - b: (_|_){ 976 - - // [eval] 977 - - b: (_|_){ 978 - - // [eval] 979 - - f: (int){ 1 } 980 - - g: (int){ 1 } 981 - + f: (int){ 1 } 982 - + } 983 - + } 984 - + #A: (#struct){ 985 - + b: (#struct){ 986 - + f: (int){ 1 } 987 - + } 988 - + } 989 - + } 990 - + t5: (_|_){ 991 - + // [eval] 992 - + a: (#struct){ 993 - + b: (#struct){ 994 - + f: (int){ 1 } 995 - + g: (int){ 1 } 996 - + } 997 - + } 998 - + #A: (#struct){ 999 - + b: (#struct){ 1000 - + f: (int){ 1 } 1001 - + } 1002 - + } 1003 - + #B: (#struct){ 1004 - + b: (#struct){ 1005 - + g: (int){ 1 } 1006 - + } 1007 - + } 1008 - + b: (_|_){ 1009 - + // [eval] 1010 - + b: (_|_){ 1011 - + // [eval] 1012 - h: (_|_){ 1013 - // [eval] err.t5.b.b.h: field not allowed: 1014 - - // ./in.cue:164:6 1015 - - // ./in.cue:164:10 1016 - - // ./in.cue:165:9 1017 - - // ./in.cue:166:9 1018 - - // ./in.cue:167:5 1019 - // ./in.cue:168:8 1020 - } 1021 - + f: (int){ 1 } 1022 - + g: (int){ 1 } 1023 - } 1024 - } 1025 - } 1026 - @@ -436,17 +369,12 @@ 1027 - // [eval] 1028 - e: (_|_){ 1029 - // [eval] 1030 - - f: (int){ 1 } 1031 - - g: (int){ 1 } 1032 - h: (_|_){ 1033 - // [eval] err.t6.b.b.c.d.e.h: field not allowed: 1034 - - // ./in.cue:173:6 1035 - - // ./in.cue:173:10 1036 - - // ./in.cue:174:18 1037 - - // ./in.cue:175:18 1038 - - // ./in.cue:176:5 1039 - // ./in.cue:177:17 1040 - } 1041 - + f: (int){ 1 } 1042 - + g: (int){ 1 } 1043 - } 1044 - } 1045 - } 1046 - @@ -460,13 +388,11 @@ 1047 - } 1048 - a: (_|_){ 1049 - // [eval] 1050 - - a: (int){ 2 } 1051 - b: (_|_){ 1052 - // [eval] err.t7.a.b: field not allowed: 1053 - - // ./in.cue:187:10 1054 - - // ./in.cue:188:5 1055 - // ./in.cue:189:5 1056 - } 1057 - + a: (int){ 2 } 1058 - } 1059 - } 1060 - t8: (_|_){ 1061 - @@ -480,14 +406,11 @@ 1062 - // [eval] 1063 - c: (_|_){ 1064 - // [eval] 1065 - - d: (int){ 1 } 1066 - e: (_|_){ 1067 - // [eval] err.t8.V.c.e: field not allowed: 1068 - - // ./in.cue:194:8 1069 - - // ./in.cue:194:13 1070 - - // ./in.cue:195:5 1071 - // ./in.cue:196:10 1072 - } 1073 - + d: (int){ 1 } 1074 - } 1075 - } 1076 - } 1077 - @@ -554,14 +477,13 @@ 1078 - } 1079 - x: (_|_){ 1080 - // [eval] 1081 - - a?: (int){ int } 1082 - - b?: (int){ int } 1083 - c: (_|_){ 1084 - // [eval] validator.keepClosed.x.c: field not allowed: 1085 - - // ./validators.cue:18:6 1086 - - // ./validators.cue:23:5 1087 - + // ./validators.cue:19:3 1088 - // ./validators.cue:24:5 1089 - } 1090 - + a?: (int){ int } 1091 - + b?: (int){ int } 1092 - } 1093 - } 1094 - } 1095 - -- diff/todo/p2 -- 1096 - all: error positions and reordering. 1097 - -- diff/explanation -- 1098 - issue1830: the new evaluator correctly rejects inserting new fields in a closed struct 1099 - err.t(1|2): bug fixes. 1100 - -- out/eval -- 1101 - Errors: 1102 - err.t1.a.disallowed: field not allowed: 1103 - ./in.cue:133:10 1104 - ./in.cue:134:5 1105 - ./in.cue:135:5 1106 - err.t2.V.c.e: field not allowed: 1107 - ./in.cue:139:8 1108 - ./in.cue:139:13 1109 - ./in.cue:140:5 1110 - ./in.cue:141:10 1111 - err.t3.p1.a.c: field not allowed: 1112 - ./in.cue:145:6 1113 - ./in.cue:146:5 1114 - ./in.cue:147:5 1115 - err.t3.p2.a.b.c: field not allowed: 1116 - ./in.cue:151:9 1117 - ./in.cue:152:5 1118 - ./in.cue:153:8 1119 - err.t4.a.b.h: field not allowed: 1120 - ./in.cue:157:5 1121 - ./in.cue:158:9 1122 - ./in.cue:159:8 1123 - err.t5.b.b.h: field not allowed: 1124 - ./in.cue:164:6 1125 - ./in.cue:164:10 1126 - ./in.cue:165:9 1127 - ./in.cue:166:9 1128 - ./in.cue:167:5 1129 - ./in.cue:168:8 1130 - err.t6.b.b.c.d.e.h: field not allowed: 1131 - ./in.cue:173:6 1132 - ./in.cue:173:10 1133 - ./in.cue:174:18 1134 - ./in.cue:175:18 1135 - ./in.cue:176:5 1136 - ./in.cue:177:17 1137 - err.t7.a.b: field not allowed: 1138 - ./in.cue:187:10 1139 - ./in.cue:188:5 1140 - ./in.cue:189:5 1141 - err.t8.V.c.e: field not allowed: 1142 - ./in.cue:194:8 1143 - ./in.cue:194:13 1144 - ./in.cue:195:5 1145 - ./in.cue:196:10 1146 - ok.t13.x.c: field not allowed: 1147 - ./in.cue:106:6 1148 - ./in.cue:107:3 1149 - ./in.cue:110:10 1150 - ./in.cue:111:5 1151 - ./in.cue:112:5 1152 - ok.t5.x.c: field not allowed: 1153 - ./in.cue:35:6 1154 - ./in.cue:36:3 1155 - ./in.cue:39:10 1156 - ./in.cue:40:5 1157 - ./in.cue:41:5 1158 - validator.keepClosed.x.c: field not allowed: 1159 - ./validators.cue:18:6 1160 - ./validators.cue:23:5 1161 - ./validators.cue:24:5 1162 - validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:_|_(validator.open.data.trailingComma: field not allowed)} (does not satisfy matchN): 0 matched, expected 1: 1163 - ./validators.cue:10:3 1164 - ./validators.cue:10:10 1165 - ./validators.cue:13:8 1166 - ./validators.cue:14:8 1167 - validator.open.data.trailingComma: field not allowed: 1168 - ./validators.cue:10:3 1169 - ./validators.cue:9:11 1170 - ./validators.cue:13:8 1171 - ./validators.cue:14:8 1172 - 1173 - Result: 1174 - (_|_){ 1175 - // [eval] 1176 - ok: (_|_){ 1177 - // [eval] 1178 - t1: (struct){ 1179 - c: (#list){ 1180 - 0: (#struct){ 1181 - b: (int){ int } 1182 - } 1183 - } 1184 - #R: (list){ 1185 - } 1186 - } 1187 - t2: (struct){ 1188 - #A: (_){ _ } 1189 - l: (#struct){ 1190 - f: (string){ "hi" } 1191 - } 1192 - } 1193 - t3: (struct){ 1194 - #A: (#struct){ 1195 - f: (#struct){ 1196 - } 1197 - } 1198 - #A1: (#struct){ 1199 - f: (#struct){ 1200 - } 1201 - } 1202 - s: (struct){ 1203 - foo: (#struct){ 1204 - f: (#struct){ 1205 - d: (struct){ 1206 - foo: (int){ 1 } 1207 - } 1208 - } 1209 - } 1210 - } 1211 - } 1212 - t4: (struct){ 1213 - #T: (#struct){ 1214 - a: (#struct){ 1215 - b: (int){ 1 } 1216 - } 1217 - } 1218 - W: (#struct){ 1219 - a: (#struct){ 1220 - b: (int){ 1 } 1221 - } 1222 - b: (struct){ 1223 - c: (int){ 2 } 1224 - } 1225 - } 1226 - } 1227 - t5: (_|_){ 1228 - // [eval] 1229 - #A: (#struct){ 1230 - } 1231 - Common: (struct){ 1232 - } 1233 - x: (_|_){ 1234 - // [eval] 1235 - c: (_|_){ 1236 - // [eval] ok.t5.x.c: field not allowed: 1237 - // ./in.cue:35:6 1238 - // ./in.cue:36:3 1239 - // ./in.cue:39:10 1240 - // ./in.cue:40:5 1241 - // ./in.cue:41:5 1242 - } 1243 - } 1244 - } 1245 - t6: (struct){ 1246 - #A: (#struct){ 1247 - } 1248 - Common: (struct){ 1249 - } 1250 - x: (#struct){ 1251 - c: (int){ int } 1252 - } 1253 - } 1254 - t7: (struct){ 1255 - a: (#struct){ 1256 - b: (#struct){ 1257 - f: (int){ 1 } 1258 - g: (int){ 1 } 1259 - } 1260 - } 1261 - #A: (#struct){ 1262 - b: (#struct){ 1263 - f: (int){ 1 } 1264 - } 1265 - } 1266 - #B: (#struct){ 1267 - b: (#struct){ 1268 - g: (int){ 1 } 1269 - } 1270 - } 1271 - } 1272 - t8: (struct){ 1273 - foo: ~(ok.t8.#X) 1274 - #X: (#struct){ 1275 - a: (#struct){ 1276 - b: (#struct){ 1277 - c: (#struct){ 1278 - C: (int){ 1 } 1279 - D: (int){ 2 } 1280 - } 1281 - } 1282 - } 1283 - } 1284 - } 1285 - t9: (struct){ 1286 - c: (#list){ 1287 - 0: (#struct){ 1288 - b: (int){ int } 1289 - } 1290 - } 1291 - #R: (list){ 1292 - } 1293 - } 1294 - t10: (struct){ 1295 - #A: (_){ _ } 1296 - l: (#struct){ 1297 - f: (string){ "hi" } 1298 - } 1299 - } 1300 - t11: (struct){ 1301 - #A: (#struct){ 1302 - f: (#struct){ 1303 - } 1304 - } 1305 - #A1: (#struct){ 1306 - f: (#struct){ 1307 - } 1308 - } 1309 - s: (struct){ 1310 - foo: (#struct){ 1311 - f: (#struct){ 1312 - d: (struct){ 1313 - foo: (string){ "bar" } 1314 - } 1315 - } 1316 - } 1317 - } 1318 - } 1319 - t12: (struct){ 1320 - #T: (#struct){ 1321 - a: (#struct){ 1322 - b: (int){ 1 } 1323 - } 1324 - } 1325 - W: (#struct){ 1326 - a: (#struct){ 1327 - b: (int){ 1 } 1328 - } 1329 - b: (struct){ 1330 - c: (int){ 2 } 1331 - } 1332 - } 1333 - } 1334 - t13: (_|_){ 1335 - // [eval] 1336 - #A: (#struct){ 1337 - } 1338 - Common: (struct){ 1339 - } 1340 - x: (_|_){ 1341 - // [eval] 1342 - c: (_|_){ 1343 - // [eval] ok.t13.x.c: field not allowed: 1344 - // ./in.cue:106:6 1345 - // ./in.cue:107:3 1346 - // ./in.cue:110:10 1347 - // ./in.cue:111:5 1348 - // ./in.cue:112:5 1349 - } 1350 - } 1351 - } 1352 - t14: (struct){ 1353 - #A: (#struct){ 1354 - } 1355 - Common: (struct){ 1356 - } 1357 - x: (#struct){ 1358 - c: (int){ int } 1359 - } 1360 - } 1361 - } 1362 - err: (_|_){ 1363 - // [eval] 1364 - t1: (_|_){ 1365 - // [eval] 1366 - #D: (#struct){ 1367 - a: (int){ 2 } 1368 - } 1369 - a: (_|_){ 1370 - // [eval] 1371 - disallowed: (_|_){ 1372 - // [eval] err.t1.a.disallowed: field not allowed: 1373 - // ./in.cue:135:5 1374 - } 1375 - a: (int){ 2 } 1376 - } 1377 - } 1378 - t2: (_|_){ 1379 - // [eval] 1380 - #S: (#struct){ 1381 - c: (#struct){ 1382 - d: (int){ 1 } 1383 - } 1384 - } 1385 - V: (_|_){ 1386 - // [eval] 1387 - c: (_|_){ 1388 - // [eval] 1389 - d: (int){ 1 } 1390 - e: (_|_){ 1391 - // [eval] err.t2.V.c.e: field not allowed: 1392 - // ./in.cue:139:8 1393 - // ./in.cue:139:13 1394 - // ./in.cue:140:5 1395 - // ./in.cue:141:10 1396 - } 1397 - } 1398 - } 1399 - } 1400 - t3: (_|_){ 1401 - // [eval] 1402 - p1: (_|_){ 1403 - // [eval] 1404 - #D: (#struct){ 1405 - } 1406 - a: (_|_){ 1407 - // [eval] 1408 - c: (_|_){ 1409 - // [eval] err.t3.p1.a.c: field not allowed: 1410 - // ./in.cue:145:6 1411 - // ./in.cue:146:5 1412 - // ./in.cue:147:5 1413 - } 1414 - } 1415 - } 1416 - p2: (_|_){ 1417 - // [eval] 1418 - #D: (#struct){ 1419 - b: (#struct){ 1420 - } 1421 - } 1422 - a: (_|_){ 1423 - // [eval] 1424 - b: (_|_){ 1425 - // [eval] 1426 - c: (_|_){ 1427 - // [eval] err.t3.p2.a.b.c: field not allowed: 1428 - // ./in.cue:151:9 1429 - // ./in.cue:152:5 1430 - // ./in.cue:153:8 1431 - } 1432 - } 1433 - } 1434 - } 1435 - } 1436 - t4: (_|_){ 1437 - // [eval] 1438 - a: (_|_){ 1439 - // [eval] 1440 - b: (_|_){ 1441 - // [eval] 1442 - f: (int){ 1 } 1443 - h: (_|_){ 1444 - // [eval] err.t4.a.b.h: field not allowed: 1445 - // ./in.cue:157:5 1446 - // ./in.cue:158:9 1447 - // ./in.cue:159:8 1448 - } 1449 - } 1450 - } 1451 - #A: (#struct){ 1452 - b: (#struct){ 1453 - f: (int){ 1 } 1454 - } 1455 - } 1456 - } 1457 - t5: (_|_){ 1458 - // [eval] 1459 - a: (#struct){ 1460 - b: (#struct){ 1461 - f: (int){ 1 } 1462 - g: (int){ 1 } 1463 - } 1464 - } 1465 - #A: (#struct){ 1466 - b: (#struct){ 1467 - f: (int){ 1 } 1468 - } 1469 - } 1470 - #B: (#struct){ 1471 - b: (#struct){ 1472 - g: (int){ 1 } 1473 - } 1474 - } 1475 - b: (_|_){ 1476 - // [eval] 1477 - b: (_|_){ 1478 - // [eval] 1479 - f: (int){ 1 } 1480 - g: (int){ 1 } 1481 - h: (_|_){ 1482 - // [eval] err.t5.b.b.h: field not allowed: 1483 - // ./in.cue:164:6 1484 - // ./in.cue:164:10 1485 - // ./in.cue:165:9 1486 - // ./in.cue:166:9 1487 - // ./in.cue:167:5 1488 - // ./in.cue:168:8 1489 - } 1490 - } 1491 - } 1492 - } 1493 - t6: (_|_){ 1494 - // [eval] 1495 - a: (#struct){ 1496 - b: (#struct){ 1497 - c: (#struct){ 1498 - d: (#struct){ 1499 - e: (#struct){ 1500 - f: (int){ 1 } 1501 - g: (int){ 1 } 1502 - } 1503 - } 1504 - } 1505 - } 1506 - } 1507 - #A: (#struct){ 1508 - b: (#struct){ 1509 - c: (#struct){ 1510 - d: (#struct){ 1511 - e: (#struct){ 1512 - f: (int){ 1 } 1513 - } 1514 - } 1515 - } 1516 - } 1517 - } 1518 - #B: (#struct){ 1519 - b: (#struct){ 1520 - c: (#struct){ 1521 - d: (#struct){ 1522 - e: (#struct){ 1523 - g: (int){ 1 } 1524 - } 1525 - } 1526 - } 1527 - } 1528 - } 1529 - b: (_|_){ 1530 - // [eval] 1531 - b: (_|_){ 1532 - // [eval] 1533 - c: (_|_){ 1534 - // [eval] 1535 - d: (_|_){ 1536 - // [eval] 1537 - e: (_|_){ 1538 - // [eval] 1539 - f: (int){ 1 } 1540 - g: (int){ 1 } 1541 - h: (_|_){ 1542 - // [eval] err.t6.b.b.c.d.e.h: field not allowed: 1543 - // ./in.cue:173:6 1544 - // ./in.cue:173:10 1545 - // ./in.cue:174:18 1546 - // ./in.cue:175:18 1547 - // ./in.cue:176:5 1548 - // ./in.cue:177:17 1549 - } 1550 - } 1551 - } 1552 - } 1553 - } 1554 - } 1555 - } 1556 - t7: (_|_){ 1557 - // [eval] 1558 - #D: (#struct){ 1559 - a: (int){ 2 } 1560 - } 1561 - a: (_|_){ 1562 - // [eval] 1563 - a: (int){ 2 } 1564 - b: (_|_){ 1565 - // [eval] err.t7.a.b: field not allowed: 1566 - // ./in.cue:187:10 1567 - // ./in.cue:188:5 1568 - // ./in.cue:189:5 1569 - } 1570 - } 1571 - } 1572 - t8: (_|_){ 1573 - // [eval] 1574 - #S: (#struct){ 1575 - c: (#struct){ 1576 - d: (int){ 1 } 1577 - } 1578 - } 1579 - V: (_|_){ 1580 - // [eval] 1581 - c: (_|_){ 1582 - // [eval] 1583 - d: (int){ 1 } 1584 - e: (_|_){ 1585 - // [eval] err.t8.V.c.e: field not allowed: 1586 - // ./in.cue:194:8 1587 - // ./in.cue:194:13 1588 - // ./in.cue:195:5 1589 - // ./in.cue:196:10 1590 - } 1591 - } 1592 - } 1593 - } 1594 - } 1595 - issue1830: (struct){ 1596 - #x: (#struct){ 1597 - y: (#struct){ 1598 - z?: (#struct){ 1599 - name: (string){ string } 1600 - } 1601 - } 1602 - } 1603 - egs: (struct){ 1604 - x1: (#struct){ 1605 - name: (string){ "blah" } 1606 - age1: (int){ 5 } 1607 - } 1608 - x2: (#struct){ 1609 - name: (string){ "blah" } 1610 - age2: (int){ 5 } 1611 - } 1612 - } 1613 - } 1614 - issue3491: (struct){ 1615 - #Schema: (#struct){ 1616 - field?: (#struct){ 1617 - } 1618 - } 1619 - a: (#struct){ 1620 - field: (#struct){ 1621 - } 1622 - #Extra: (#struct){ 1623 - } 1624 - } 1625 - b: (struct){ 1626 - #Extra: (#struct){ 1627 - } 1628 - } 1629 - } 1630 - validator: (_|_){ 1631 - // [eval] 1632 - open: (struct){ 1633 - #Schema: (_){ 1634 - matchN(1, (#list){ 1635 - 0: (_|_){// 〈1;#x〉 1636 - } 1637 - }) 1638 - #x: (#struct){ 1639 - trailingComma?: (string){ "all" } 1640 - } 1641 - } 1642 - data: (#struct){ 1643 - trailingComma: (string){ "all" } 1644 - #x: (#struct){ 1645 - trailingComma?: (string){ "all" } 1646 - } 1647 - } 1648 - } 1649 - keepClosed: (_|_){ 1650 - // [eval] 1651 - #X: (#struct){ 1652 - a?: (int){ int } 1653 - b?: (int){ int } 1654 - } 1655 - x: (_|_){ 1656 - // [eval] 1657 - a?: (int){ int } 1658 - b?: (int){ int } 1659 - c: (_|_){ 1660 - // [eval] validator.keepClosed.x.c: field not allowed: 1661 - // ./validators.cue:18:6 1662 - // ./validators.cue:23:5 1663 - // ./validators.cue:24:5 1664 - } 1665 - } 1666 - } 1667 - } 1668 - } 394 + -- out/errors.txt -- 395 + [eval] ok.t5.x.c: field not allowed: 396 + ./in.cue:65:5 397 + [eval] ok.t13.x.c: field not allowed: 398 + ./in.cue:192:5 399 + [eval] err.t1.a.disallowed: field not allowed: 400 + ./in.cue:228:5 401 + [eval] err.t2.V.c.e: field not allowed: 402 + ./in.cue:235:10 403 + [eval] err.t3.a.c: field not allowed: 404 + ./in.cue:242:5 405 + [eval] err.t4.a.b.h: field not allowed: 406 + ./in.cue:249:8 407 + [eval] err.t5.b.b.h: field not allowed: 408 + ./in.cue:259:8 409 + [eval] err.t6.b.b.c.d.e.h: field not allowed: 410 + ./in.cue:269:17 411 + [eval] err.t7.a.b: field not allowed: 412 + ./in.cue:282:5 413 + [eval] err.t8.V.c.e: field not allowed: 414 + ./in.cue:290:10 415 + [eval] validator.keepClosed.x.c: field not allowed: 416 + ./validators.cue:31:3 417 + ./validators.cue:36:5 418 + -- out/diff-v2-v3.txt -- 419 + Error positions: v3 reports fewer positions than v2. 420 + Field reordering differences between v2 and v3. 421 + Verdict: worsening -- v3 reports fewer error positions than v2; field reordering. 1669 422 -- out/compile -- 1670 423 --- in.cue 1671 424 { ··· 1918 671 } 1919 672 err: { 1920 673 t3: { 1921 - p1: { 1922 - #D: {} 1923 - a: 〈0;#D〉 1924 - a: { 1925 - c: "C" 1926 - } 1927 - } 1928 - } 1929 - } 1930 - err: { 1931 - t3: { 1932 - p2: { 1933 - #D: { 1934 - b: {} 1935 - } 1936 - a: 〈0;#D〉 1937 - a: { 1938 - b: { 1939 - c: "C" 1940 - } 1941 - } 674 + #D: {} 675 + a: 〈0;#D〉 676 + a: { 677 + c: "C" 1942 678 } 1943 679 } 1944 680 }
+38 -81
cue/testdata/definitions/files.txtar
··· 1 1 // Treat fields of different files as belonging to the same struct. 2 2 // This means that a closed embedding in one file should not restrict the 3 3 // fields of another. 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 package foo 7 6 ··· 12 11 dark: #theme & { 13 12 color: "dark" 14 13 ctermbg: "239" 15 - } 14 + } @test(eq, {color: "dark", ctermbg: "239"}) 15 + 16 16 light: #theme & { 17 17 color: "light" 18 18 ctermbg: "254" 19 - } 19 + } @test(eq, {color: "light", ctermbg: "254"}) 20 + 20 21 #Config: { 21 22 console: dark | *light 22 - } 23 + } @test(eq, { 24 + console: *{color: "light", ctermbg: "254"} | {color: "dark", ctermbg: "239"} 25 + }) 23 26 -- box.cue -- 24 27 package foo 25 28 26 29 #Config & { 27 30 console: dark 28 31 } 32 + 33 + @test(eq, {color: "dark", ctermbg: "239"}, at=console) 34 + 29 35 -- out/eval/stats -- 30 36 Leaks: 3 31 37 Freed: 24 ··· 39 45 Notifications: 1 40 46 41 47 NumCloseIDs: 13 48 + -- out/compile -- 49 + --- box.cue 50 + { 51 + (〈0;#Config〉 & { 52 + console: 〈1;dark〉 53 + }) 54 + } 55 + --- in.cue 56 + { 57 + #theme: { 58 + color: string 59 + ctermbg: string 60 + } 61 + dark: (〈0;#theme〉 & { 62 + color: "dark" 63 + ctermbg: "239" 64 + }) 65 + light: (〈0;#theme〉 & { 66 + color: "light" 67 + ctermbg: "254" 68 + }) 69 + #Config: { 70 + console: (〈1;dark〉|*〈1;light〉) 71 + } 72 + } 73 + -- out/diff-v2-v3.txt -- 74 + Reordering. 75 + Disjunctions with defaults: needs @test(final) for console field. 42 76 -- out/evalalpha -- 43 77 (#struct){ 44 78 console: (#struct){ ··· 67 101 }) } 68 102 } 69 103 } 70 - -- diff/-out/evalalpha<==>+out/eval -- 71 - diff old new 72 - --- old 73 - +++ new 74 - @@ -1,4 +1,8 @@ 75 - (#struct){ 76 - + console: (#struct){ 77 - + color: (string){ "dark" } 78 - + ctermbg: (string){ "239" } 79 - + } 80 - #theme: (#struct){ 81 - color: (string){ string } 82 - ctermbg: (string){ string } 83 - @@ -20,8 +24,4 @@ 84 - ctermbg: (string){ "239" } 85 - }) } 86 - } 87 - - console: (#struct){ 88 - - color: (string){ "dark" } 89 - - ctermbg: (string){ "239" } 90 - - } 91 - } 92 - -- diff/todo/p3 -- 93 - Reordering. 94 - -- out/eval -- 95 - (#struct){ 96 - #theme: (#struct){ 97 - color: (string){ string } 98 - ctermbg: (string){ string } 99 - } 100 - dark: (#struct){ 101 - color: (string){ "dark" } 102 - ctermbg: (string){ "239" } 103 - } 104 - light: (#struct){ 105 - color: (string){ "light" } 106 - ctermbg: (string){ "254" } 107 - } 108 - #Config: (#struct){ 109 - console: (#struct){ |(*(#struct){ 110 - color: (string){ "light" } 111 - ctermbg: (string){ "254" } 112 - }, (#struct){ 113 - color: (string){ "dark" } 114 - ctermbg: (string){ "239" } 115 - }) } 116 - } 117 - console: (#struct){ 118 - color: (string){ "dark" } 119 - ctermbg: (string){ "239" } 120 - } 121 - } 122 - -- out/compile -- 123 - --- box.cue 124 - { 125 - (〈0;#Config〉 & { 126 - console: 〈1;dark〉 127 - }) 128 - } 129 - --- in.cue 130 - { 131 - #theme: { 132 - color: string 133 - ctermbg: string 134 - } 135 - dark: (〈0;#theme〉 & { 136 - color: "dark" 137 - ctermbg: "239" 138 - }) 139 - light: (〈0;#theme〉 & { 140 - color: "light" 141 - ctermbg: "254" 142 - }) 143 - #Config: { 144 - console: (〈1;dark〉|*〈1;light〉) 145 - } 146 - }
+19 -187
cue/testdata/definitions/hidden.txtar
··· 1 1 exec cue eval ./pkg:foo 2 - #todo:inline: medium — definitions with closedness; check @test(closed) support 3 2 -- cue.mod/module.cue -- 4 3 module: "mod.test" 5 4 language: version: "v0.9.0" ··· 23 22 24 23 // This should not fail, as this is a different _val 25 24 _val: g: int 26 - } 25 + } @test(err, code=eval, at=_name$foo.c, contains="field not allowed", pos=[3:9]) 27 26 28 - f: pkg.#D & {_val: f: 4} 29 - g: f._val 27 + f: pkg.#D & {_val: f: 4} @test(debugCheck, """ 28 + (#struct){ 29 + _val(:foo): (struct){ 30 + f: (int){ 4 } 31 + } 32 + _val(mod.test/pkg): (#struct){ 33 + f: (int){ 3 } 34 + } 35 + } 36 + """) 37 + 38 + g: f._val @test(eq, {f: 4}) 30 39 -- pkg/bar.cue -- 31 40 package pkg 32 41 33 42 #D: {_val: f: 3} 43 + -- out/errors.txt -- 44 + [eval] e._name.c: field not allowed: 45 + ./in.cue:16:9 34 46 -- out/eval/stats -- 35 47 Leaks: 2 36 48 Freed: 25 ··· 43 55 Disjuncts: 0 44 56 45 57 NumCloseIDs: 4 46 - -- out/evalalpha -- 47 - Errors: 48 - e._name.c: field not allowed: 49 - ./in.cue:16:9 50 - 51 - Result: 52 - (_|_){ 53 - // [eval] 54 - #def: (#struct){ 55 - _name(:foo): (#struct){ 56 - d: (int){ int } 57 - } 58 - } 59 - d: (#struct){ 60 - _name(:foo): (struct){ 61 - d: (int){ int } 62 - } 63 - _val(:foo): (struct){ 64 - f: (int){ 4 } 65 - } 66 - _val(mod.test/pkg): (#struct){ 67 - f: (int){ 3 } 68 - } 69 - } 70 - e: (_|_){ 71 - // [eval] 72 - _name(:foo): (_|_){ 73 - // [eval] 74 - c: (_|_){ 75 - // [eval] e._name.c: field not allowed: 76 - // ./in.cue:16:9 77 - } 78 - d: (int){ int } 79 - } 80 - _val(:foo): (struct){ 81 - g: (int){ int } 82 - } 83 - _val(mod.test/pkg): (#struct){ 84 - f: (int){ 3 } 85 - } 86 - } 87 - f: (#struct){ 88 - _val(:foo): (struct){ 89 - f: (int){ 4 } 90 - } 91 - _val(mod.test/pkg): (#struct){ 92 - f: (int){ 3 } 93 - } 94 - } 95 - g: ~(f._val(:foo)) 96 - } 97 - -- diff/-out/evalalpha<==>+out/eval -- 98 - diff old new 99 - --- old 100 - +++ new 101 - @@ -1,7 +1,5 @@ 102 - Errors: 103 - e._name.c: field not allowed: 104 - - ./in.cue:6:9 105 - - ./in.cue:13:13 106 - ./in.cue:16:9 107 - 108 - Result: 109 - @@ -13,9 +11,6 @@ 110 - } 111 - } 112 - d: (#struct){ 113 - - _val(mod.test/pkg): (#struct){ 114 - - f: (int){ 3 } 115 - - } 116 - _name(:foo): (struct){ 117 - d: (int){ int } 118 - } 119 - @@ -22,35 +17,34 @@ 120 - _val(:foo): (struct){ 121 - f: (int){ 4 } 122 - } 123 - + _val(mod.test/pkg): (#struct){ 124 - + f: (int){ 3 } 125 - + } 126 - } 127 - e: (_|_){ 128 - // [eval] 129 - - _val(mod.test/pkg): (#struct){ 130 - - f: (int){ 3 } 131 - - } 132 - _name(:foo): (_|_){ 133 - // [eval] 134 - - d: (int){ int } 135 - c: (_|_){ 136 - // [eval] e._name.c: field not allowed: 137 - - // ./in.cue:6:9 138 - - // ./in.cue:13:13 139 - // ./in.cue:16:9 140 - } 141 - + d: (int){ int } 142 - } 143 - _val(:foo): (struct){ 144 - g: (int){ int } 145 - } 146 - + _val(mod.test/pkg): (#struct){ 147 - + f: (int){ 3 } 148 - + } 149 - } 150 - f: (#struct){ 151 - - _val(mod.test/pkg): (#struct){ 152 - - f: (int){ 3 } 153 - - } 154 - - _val(:foo): (struct){ 155 - - f: (int){ 4 } 156 - - } 157 - - } 158 - - g: (struct){ 159 - - f: (int){ 4 } 160 - - } 161 - + _val(:foo): (struct){ 162 - + f: (int){ 4 } 163 - + } 164 - + _val(mod.test/pkg): (#struct){ 165 - + f: (int){ 3 } 166 - + } 167 - + } 168 - + g: ~(f._val(:foo)) 169 - } 170 - -- diff/todo/p2 -- 171 - Reordering / missing positions. 172 - -- out/eval -- 173 - Errors: 174 - e._name.c: field not allowed: 175 - ./in.cue:6:9 176 - ./in.cue:13:13 177 - ./in.cue:16:9 178 - 179 - Result: 180 - (_|_){ 181 - // [eval] 182 - #def: (#struct){ 183 - _name(:foo): (#struct){ 184 - d: (int){ int } 185 - } 186 - } 187 - d: (#struct){ 188 - _val(mod.test/pkg): (#struct){ 189 - f: (int){ 3 } 190 - } 191 - _name(:foo): (struct){ 192 - d: (int){ int } 193 - } 194 - _val(:foo): (struct){ 195 - f: (int){ 4 } 196 - } 197 - } 198 - e: (_|_){ 199 - // [eval] 200 - _val(mod.test/pkg): (#struct){ 201 - f: (int){ 3 } 202 - } 203 - _name(:foo): (_|_){ 204 - // [eval] 205 - d: (int){ int } 206 - c: (_|_){ 207 - // [eval] e._name.c: field not allowed: 208 - // ./in.cue:6:9 209 - // ./in.cue:13:13 210 - // ./in.cue:16:9 211 - } 212 - } 213 - _val(:foo): (struct){ 214 - g: (int){ int } 215 - } 216 - } 217 - f: (#struct){ 218 - _val(mod.test/pkg): (#struct){ 219 - f: (int){ 3 } 220 - } 221 - _val(:foo): (struct){ 222 - f: (int){ 4 } 223 - } 224 - } 225 - g: (struct){ 226 - f: (int){ 4 } 227 - } 228 - } 58 + -- out/diff-v2-v3.txt -- 59 + g: v2 evaluator expands g to {f: 4}; v3 uses structure sharing (~(f._val(:foo))). 60 + Verdict: improvement -- v3 uses structure sharing for g; more efficient. 229 61 -- out/compile -- 230 62 --- in.cue 231 63 {
+16 -77
cue/testdata/definitions/issue271.txtar
··· 1 + 1 2 # Tests that a struct combining an open pattern constraint with close() correctly 2 3 # rejects fields not allowed by the close() constraint when unified with a value. 3 4 # https://cuelang.org/issue/271 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 5 -- in.cue -- 6 6 #T: [_]: _ 7 7 #T: close({"a": string}) 8 8 x: #T 9 9 x: { 10 - a: "hello" 11 - b: "foo" 10 + a: "hello" @test(eq, "hello") 11 + b: "foo" @test(err, code=eval, contains="field not allowed", pos=[-5:5, 0:2]) 12 12 } 13 + -- out/errors.txt -- 14 + [eval] x.b: field not allowed: 15 + ./in.cue:1:5 16 + ./in.cue:6:2 13 17 -- out/eval/stats -- 14 18 Leaks: 0 15 19 Freed: 14 16 20 Reused: 5 17 21 Allocs: 9 18 22 Retain: 0 19 - 20 23 Unifications: 10 21 24 Conjuncts: 20 22 25 Disjuncts: 0 23 - 24 26 NumCloseIDs: 3 25 - -- out/evalalpha -- 26 - Errors: 27 - x.b: field not allowed: 28 - ./in.cue:1:5 29 - ./in.cue:6:2 30 - 31 - Result: 32 - (_|_){ 33 - // [eval] 34 - #T: (#struct){ 35 - a: (string){ string } 36 - } 37 - x: (_|_){ 38 - // [eval] 39 - a: (string){ "hello" } 40 - b: (_|_){ 41 - // [eval] x.b: field not allowed: 42 - // ./in.cue:1:5 43 - // ./in.cue:6:2 44 - } 45 - } 46 - } 47 - -- diff/-out/evalalpha<==>+out/eval -- 48 - diff old new 49 - --- old 50 - +++ new 51 - @@ -1,8 +1,6 @@ 52 - Errors: 53 - x.b: field not allowed: 54 - ./in.cue:1:5 55 - - ./in.cue:2:11 56 - - ./in.cue:3:5 57 - ./in.cue:6:2 58 - 59 - Result: 60 - @@ -17,8 +15,6 @@ 61 - b: (_|_){ 62 - // [eval] x.b: field not allowed: 63 - // ./in.cue:1:5 64 - - // ./in.cue:2:11 65 - - // ./in.cue:3:5 66 - // ./in.cue:6:2 67 - } 68 - } 69 - -- diff/todo/p2 -- 70 - Positions. 71 - -- out/eval -- 72 - Errors: 73 - x.b: field not allowed: 74 - ./in.cue:1:5 75 - ./in.cue:2:11 76 - ./in.cue:3:5 77 - ./in.cue:6:2 78 - 79 - Result: 80 - (_|_){ 81 - // [eval] 82 - #T: (#struct){ 83 - a: (string){ string } 84 - } 85 - x: (_|_){ 86 - // [eval] 87 - a: (string){ "hello" } 88 - b: (_|_){ 89 - // [eval] x.b: field not allowed: 90 - // ./in.cue:1:5 91 - // ./in.cue:2:11 92 - // ./in.cue:3:5 93 - // ./in.cue:6:2 94 - } 95 - } 96 - } 97 27 -- out/compile -- 98 28 --- in.cue 99 29 { ··· 109 39 b: "foo" 110 40 } 111 41 } 42 + -- out/diff-v2-v3.txt -- 43 + Positions: v3 reports fewer positions than v2 for the "field not allowed" error. 44 + x.b: field not allowed: 45 + ./in.cue:1:5 46 + - ./in.cue:2:11 47 + - ./in.cue:3:5 48 + ./in.cue:6:2 49 + 50 + No newline at end of right file.
+26 -87
cue/testdata/definitions/issue317.txtar
··· 1 + 1 2 # Allow otherField 2 3 # Tests that comprehension-based schemas and deployment configurations correctly 3 4 # allow fields defined through pattern constraints and let comprehensions. 4 5 # Issue: https://cuelang.org/issue/317 5 - #todo:inline: medium — comprehension; may need @test(final) for incomplete fields 6 6 -- in.cue -- 7 7 #T: { 8 8 #Schema: [_]: #D ··· 17 17 foo: otherField: string 18 18 } 19 19 concrete: foo: otherField: "hello" 20 - } 21 - 20 + } @test(closed) @test(eq, { 21 + #Schema: foo: { 22 + fieldWithDefault: *0 | int 23 + otherField: string 24 + } 25 + concrete: foo: { 26 + fieldWithDefault: *0 | int 27 + otherField: "hello" 28 + } 29 + }) 22 30 #Container: { 23 31 Env: [Name=string]: { 24 32 name: string ··· 27 35 } 28 36 #Deployment: { 29 37 #Containers: [Name=string]: #Container 30 - 31 38 containers: [for c in #Containers {c}] // Problem is here. 32 39 } 33 40 Something: { ··· 37 44 "a thing": Env: foobar: value: "foo" 38 45 } 39 46 } 40 - x: Something & #Deployment 47 + x: Something & #Deployment @test(closed) @test(eq, { 48 + #Containers: { 49 + "a thing": Env: foobar: { 50 + value: "foo" 51 + name: string 52 + } 53 + } 54 + containers: [{ 55 + Env: foobar: { 56 + name: string 57 + value: "foo" 58 + } 59 + }] 60 + }) 61 + -- out/errors.txt -- 41 62 -- out/eval/stats -- 42 63 Leaks: 0 43 64 Freed: 52 44 65 Reused: 37 45 66 Allocs: 15 46 67 Retain: 0 47 - 48 68 Unifications: 46 49 69 Conjuncts: 96 50 70 Disjuncts: 6 51 - 52 71 NumCloseIDs: 21 53 - -- out/evalalpha -- 54 - (struct){ 55 - #T: (#struct){ 56 - #Schema: (#struct){ 57 - } 58 - concrete: (#struct){ 59 - } 60 - } 61 - #D: (#struct){ 62 - fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) } 63 - } 64 - s: (#struct){ 65 - #Schema: (#struct){ 66 - foo: (#struct){ 67 - otherField: (string){ string } 68 - fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) } 69 - } 70 - } 71 - concrete: (#struct){ 72 - foo: (#struct){ 73 - otherField: (string){ "hello" } 74 - fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) } 75 - } 76 - } 77 - } 78 - #Container: (#struct){ 79 - Env: (#struct){ 80 - } 81 - } 82 - #Deployment: (#struct){ 83 - #Containers: (#struct){ 84 - } 85 - containers: (#list){ 86 - } 87 - } 88 - Something: (#struct){ 89 - #Containers: (#struct){ 90 - "a thing": (#struct){ 91 - Env: (#struct){ 92 - foobar: (#struct){ 93 - value: (string){ "foo" } 94 - name: (string){ string } 95 - } 96 - } 97 - } 98 - } 99 - containers: (#list){ 100 - 0: (#struct){ 101 - Env: (#struct){ 102 - foobar: (#struct){ 103 - value: (string){ "foo" } 104 - name: (string){ string } 105 - } 106 - } 107 - } 108 - } 109 - } 110 - x: (#struct){ 111 - #Containers: (#struct){ 112 - "a thing": (#struct){ 113 - Env: (#struct){ 114 - foobar: (#struct){ 115 - value: (string){ "foo" } 116 - name: (string){ string } 117 - } 118 - } 119 - } 120 - } 121 - containers: (#list){ 122 - 0: (#struct){ 123 - Env: (#struct){ 124 - foobar: (#struct){ 125 - value: (string){ "foo" } 126 - name: (string){ string } 127 - } 128 - } 129 - } 130 - } 131 - } 132 - } 133 72 -- out/compile -- 134 73 --- in.cue 135 74 {
+17 -83
cue/testdata/definitions/issue320.txtar
··· 1 + 1 2 # Tests that "field not allowed" errors in closed structs include sufficient 2 3 # diagnostic information about the source of the restriction. 3 4 # https://cuelang.org/issue/320 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 5 -- in.cue -- 6 6 #Foo: { 7 7 x: string ··· 13 13 foo: #Foo & { 14 14 x: "hello" 15 15 y: "goodbye" 16 - } 16 + } @test(err, at=y, code=eval, 17 + hint="could use more positions, like in v2", 18 + contains="field not allowed", 19 + pos=[in.cue:10:2]) 20 + -- out/errors.txt -- 21 + [eval] foo.y: field not allowed: 22 + ./in.cue:10:2 17 23 -- out/eval/stats -- 18 24 Leaks: 0 19 25 Freed: 7 20 26 Reused: 1 21 27 Allocs: 6 22 28 Retain: 0 23 - 24 29 Unifications: 7 25 30 Conjuncts: 14 26 31 Disjuncts: 0 27 - 28 32 NumCloseIDs: 7 29 - -- out/evalalpha -- 30 - Errors: 31 - foo.y: field not allowed: 32 - ./in.cue:10:2 33 - 34 - Result: 35 - (_|_){ 36 - // [eval] 37 - #Foo: (#struct){ 38 - x: (string){ string } 39 - } 40 - #More: (#struct){ 41 - } 42 - foo: (_|_){ 43 - // [eval] 44 - x: (string){ "hello" } 45 - y: (_|_){ 46 - // [eval] foo.y: field not allowed: 47 - // ./in.cue:10:2 48 - } 49 - } 50 - } 51 - -- diff/-out/evalalpha<==>+out/eval -- 52 - diff old new 53 - --- old 54 - +++ new 55 - @@ -1,9 +1,5 @@ 56 - Errors: 57 - foo.y: field not allowed: 58 - - ./in.cue:1:7 59 - - ./in.cue:3:2 60 - - ./in.cue:6:8 61 - - ./in.cue:8:6 62 - ./in.cue:10:2 63 - 64 - Result: 65 - @@ -19,10 +15,6 @@ 66 - x: (string){ "hello" } 67 - y: (_|_){ 68 - // [eval] foo.y: field not allowed: 69 - - // ./in.cue:1:7 70 - - // ./in.cue:3:2 71 - - // ./in.cue:6:8 72 - - // ./in.cue:8:6 73 - // ./in.cue:10:2 74 - } 75 - } 76 - -- diff/todo/p2 -- 77 - Positions. 78 - -- out/eval -- 79 - Errors: 80 - foo.y: field not allowed: 81 - ./in.cue:1:7 82 - ./in.cue:3:2 83 - ./in.cue:6:8 84 - ./in.cue:8:6 85 - ./in.cue:10:2 86 - 87 - Result: 88 - (_|_){ 89 - // [eval] 90 - #Foo: (#struct){ 91 - x: (string){ string } 92 - } 93 - #More: (#struct){ 94 - } 95 - foo: (_|_){ 96 - // [eval] 97 - x: (string){ "hello" } 98 - y: (_|_){ 99 - // [eval] foo.y: field not allowed: 100 - // ./in.cue:1:7 101 - // ./in.cue:3:2 102 - // ./in.cue:6:8 103 - // ./in.cue:8:6 104 - // ./in.cue:10:2 105 - } 106 - } 107 - } 108 33 -- out/compile -- 109 34 --- in.cue 110 35 { ··· 120 45 y: "goodbye" 121 46 }) 122 47 } 48 + -- out/diff-v2-v3.txt -- 49 + Positions: v3 reports fewer positions than v2 for the "field not allowed" error. 50 + Verdict: worsening -- v3 reports fewer error positions than v2. 51 + foo.y: field not allowed: 52 + - ./in.cue:1:7 53 + - ./in.cue:3:2 54 + - ./in.cue:6:8 55 + - ./in.cue:8:6 56 + ./in.cue:10:2
+61 -81
cue/testdata/definitions/issue359.txtar
··· 1 1 # Tests that inner structs within a definition template constraint are not 2 2 # incorrectly treated as closed when unified via a non-definition value. 3 3 # https://cuelang.org/issue/359 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 #simple: { 7 6 peso: *1 | int ··· 11 10 // Second struct is not considered closed, as expected 12 11 good: #simple & { 13 12 peso: 4 14 - } 13 + } @test(eq, {peso: 4, edad: *2 | int}) 15 14 16 15 #complex: { 17 16 things: [string]: #simple ··· 21 20 #many: #complex & { 22 21 things: hola: peso: 2 23 22 things: sol: peso: 3 24 - } 23 + } @test(eq, { 24 + things: { 25 + hola: { 26 + peso: 2 27 + edad: *2 | int 28 + } 29 + sol: { 30 + peso: 3 31 + edad: *2 | int 32 + } 33 + } 34 + }) 25 35 26 36 // Inner struct in second struct IS considered closed: why? 27 37 bad: #many & { 28 38 things: hola: peso: 2 29 - } 39 + } @test(eq, { 40 + things: { 41 + hola: { 42 + peso: 2 43 + edad: *2 | int 44 + } 45 + sol: { 46 + peso: 3 47 + edad: *2 | int 48 + } 49 + } 50 + }) 30 51 31 52 // non-definition equivalent 32 53 many: #complex & { 33 54 things: hola: peso: 2 34 55 things: sol: peso: 3 35 - } 56 + } @test(eq, { 57 + things: { 58 + hola: { 59 + peso: 2 60 + edad: *2 | int 61 + } 62 + sol: { 63 + peso: 3 64 + edad: *2 | int 65 + } 66 + } 67 + }) 36 68 37 69 // Now inner struct on second struct is NOT considered closed 38 70 notbad: many & { 39 71 things: hola: peso: 2 40 - } 41 - -- out/eval/stats -- 42 - Leaks: 9 43 - Freed: 72 44 - Reused: 57 45 - Allocs: 24 46 - Retain: 0 47 - 48 - Unifications: 41 49 - Conjuncts: 134 50 - Disjuncts: 40 51 - 52 - NumCloseIDs: 15 53 - -- out/evalalpha -- 54 - (struct){ 55 - #simple: (#struct){ 56 - peso: (int){ |(*(int){ 1 }, (int){ int }) } 57 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 58 - } 59 - good: (#struct){ 60 - peso: (int){ 4 } 61 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 62 - } 63 - #complex: (#struct){ 64 - things: (#struct){ 65 - } 66 - } 67 - #many: (#struct){ 68 - things: (#struct){ 69 - hola: (#struct){ 70 - peso: (int){ 2 } 71 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 72 - } 73 - sol: (#struct){ 74 - peso: (int){ 3 } 75 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 76 - } 77 - } 78 - } 79 - bad: (#struct){ 80 - things: (#struct){ 81 - hola: (#struct){ 82 - peso: (int){ 2 } 83 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 84 - } 85 - sol: (#struct){ 86 - peso: (int){ 3 } 87 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 88 - } 89 - } 90 - } 91 - many: (#struct){ 92 - things: (#struct){ 93 - hola: (#struct){ 94 - peso: (int){ 2 } 95 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 96 - } 97 - sol: (#struct){ 98 - peso: (int){ 3 } 99 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 100 - } 101 - } 102 - } 103 - notbad: (#struct){ 104 - things: (#struct){ 105 - hola: (#struct){ 106 - peso: (int){ 2 } 107 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 108 - } 109 - sol: (#struct){ 110 - peso: (int){ 3 } 111 - edad: (int){ |(*(int){ 2 }, (int){ int }) } 112 - } 113 - } 114 - } 115 - } 72 + } @test(eq, { 73 + things: { 74 + hola: { 75 + peso: 2 76 + edad: *2 | int 77 + } 78 + sol: { 79 + peso: 3 80 + edad: *2 | int 81 + } 82 + } 83 + }) 116 84 -- out/compile -- 117 85 --- in.cue 118 86 { ··· 167 135 } 168 136 }) 169 137 } 138 + -- out/eval/stats -- 139 + Leaks: 9 140 + Freed: 72 141 + Reused: 57 142 + Allocs: 24 143 + Retain: 0 144 + 145 + Unifications: 41 146 + Conjuncts: 134 147 + Disjuncts: 40 148 + 149 + NumCloseIDs: 15
+19 -39
cue/testdata/definitions/issue367.txtar
··· 1 - TODO: l4 should be allowed 2 - #todo:inline: medium — definitions with closedness; check @test(closed) support 3 1 -- in.cue -- 4 2 #def1: l1: ["l2"]: {l3: int, l4: 26} 5 - #special1: #def1 & {l1: l2: l3: <100} 6 - instance: #special1 & {l1: l2: l3: 34} 7 - -- out/eval/stats -- 8 - Leaks: 0 9 - Freed: 13 10 - Reused: 5 11 - Allocs: 8 12 - Retain: 0 13 - 14 - Unifications: 13 15 - Conjuncts: 28 16 - Disjuncts: 0 17 - 18 - NumCloseIDs: 3 19 - -- out/evalalpha -- 20 - (struct){ 21 - #def1: (#struct){ 22 - l1: (#struct){ 23 - } 24 - } 25 - #special1: (#struct){ 26 - l1: (#struct){ 27 - l2: (#struct){ 28 - l3: (int){ &(<100, int) } 29 - l4: (int){ 26 } 30 - } 31 - } 32 - } 33 - instance: (#struct){ 34 - l1: (#struct){ 35 - l2: (#struct){ 36 - l3: (int){ 34 } 37 - l4: (int){ 26 } 38 - } 39 - } 40 - } 41 - } 3 + #special1: #def1 & {l1: l2: l3: <100} @test(eq, { 4 + l1: l2: { 5 + l3: int & <100 6 + l4: 26 7 + } 8 + }) 9 + instance: #special1 & {l1: l2: l3: 34} @test(eq, {l1: {l2: {l3: 34, l4: 26}}}) 42 10 -- out/compile -- 43 11 --- in.cue 44 12 { ··· 65 33 } 66 34 }) 67 35 } 36 + -- out/eval/stats -- 37 + Leaks: 0 38 + Freed: 13 39 + Reused: 5 40 + Allocs: 8 41 + Retain: 0 42 + 43 + Unifications: 13 44 + Conjuncts: 28 45 + Disjuncts: 0 46 + 47 + NumCloseIDs: 3
+16 -72
cue/testdata/definitions/issue370.txtar
··· 1 1 # Tests that embedding a definition (#C1) inside another definition (#C2) and 2 2 # then unifying with a concrete struct correctly validates all fields. 3 3 # https://cuelang.org/issue/370 4 - #todo:inline: medium — general test; audit in.cue for appropriate @test annotations 5 4 -- x.cue -- 6 5 package x 7 6 ··· 16 15 17 16 c1: #C1 & { 18 17 name: "cueckoo" 19 - } 18 + } @test(eq, {name: "cueckoo"}) 20 19 21 20 c2: #C2 & { 22 21 c1 23 22 age: 5 24 - } 25 - -- out/eval/stats -- 26 - Leaks: 0 27 - Freed: 11 28 - Reused: 4 29 - Allocs: 7 30 - Retain: 0 31 - 32 - Unifications: 11 33 - Conjuncts: 25 34 - Disjuncts: 0 35 - 36 - NumCloseIDs: 12 37 - -- out/evalalpha -- 38 - (struct){ 39 - #C1: (#struct){ 40 - name: (string){ string } 41 - } 42 - #C2: (#struct){ 43 - age: (int){ int } 44 - name: (string){ string } 45 - } 46 - c1: (#struct){ 47 - name: (string){ "cueckoo" } 48 - } 49 - c2: (#struct){ 50 - age: (int){ 5 } 51 - name: (string){ "cueckoo" } 52 - } 53 - } 54 - -- diff/-out/evalalpha<==>+out/eval -- 55 - diff old new 56 - --- old 57 - +++ new 58 - @@ -3,14 +3,14 @@ 59 - name: (string){ string } 60 - } 61 - #C2: (#struct){ 62 - - name: (string){ string } 63 - age: (int){ int } 64 - + name: (string){ string } 65 - } 66 - c1: (#struct){ 67 - name: (string){ "cueckoo" } 68 - } 69 - c2: (#struct){ 70 - - name: (string){ "cueckoo" } 71 - age: (int){ 5 } 72 - + name: (string){ "cueckoo" } 73 - } 74 - } 75 - -- diff/explanation -- 76 - Reordering 77 - -- out/eval -- 78 - (struct){ 79 - #C1: (#struct){ 80 - name: (string){ string } 81 - } 82 - #C2: (#struct){ 83 - name: (string){ string } 84 - age: (int){ int } 85 - } 86 - c1: (#struct){ 87 - name: (string){ "cueckoo" } 88 - } 89 - c2: (#struct){ 90 - name: (string){ "cueckoo" } 91 - age: (int){ 5 } 92 - } 93 - } 23 + } @test(eq, {age: 5, name: "cueckoo"}) 94 24 -- out/compile -- 95 25 --- x.cue 96 26 { ··· 109 39 age: 5 110 40 }) 111 41 } 42 + -- out/eval/stats -- 43 + Leaks: 0 44 + Freed: 11 45 + Reused: 4 46 + Allocs: 7 47 + Retain: 0 48 + 49 + Unifications: 11 50 + Conjuncts: 25 51 + Disjuncts: 0 52 + 53 + NumCloseIDs: 12 54 + -- out/diff-v2-v3.txt -- 55 + Reordering
+94 -505
cue/testdata/definitions/issue3834.txtar
··· 2 2 # correctly when exposed through embedding. The key behavior is that _a unifies 3 3 # with close({y!: ...}) correctly even when exposed via {X} or X. 4 4 # Issue: https://cuelang.org/issue/3834 5 - #todo:inline: medium — disjunctions; use @test(final) for default selection 6 5 -- in.cue -- 7 6 // expose at top level 8 7 X: { ··· 10 9 _a: _ | close({y!: z?: _}) 11 10 _b: _a & {y: {}} 12 11 concrete: _b.y 13 - isTrue: concrete != _|_ 12 + isTrue: concrete != _|_ @test(eq, true) 14 13 } 15 14 {X} 15 + 16 + @test(eq, { 17 + X: { 18 + _a: {foo: true} 19 + _b: {y: {}, foo: true} 20 + concrete: {} 21 + isTrue: true 22 + } 23 + _a: {foo: true} 24 + _b: {y: {}, foo: true} 25 + concrete: {} 26 + isTrue: true 27 + 28 + sub: _ @test(ignore) 29 + full: _ @test(ignore) 30 + }) 16 31 17 32 sub: t1: { 18 33 X: { ··· 22 37 concrete: _b.y 23 38 } 24 39 {X} 40 + 41 + @test(eq, { 42 + X: { 43 + _a: {foo: true} 44 + _b: {y: {}, foo: true} 45 + concrete: {} 46 + } 47 + _a: {foo: true} 48 + _b: {y: {}, foo: true} 49 + concrete: {} 50 + }) 25 51 } 26 52 sub: t2: { 27 53 X: { 28 54 _a: foo: true 29 55 _a: _ | close({y!: z?: _}) 30 56 _b: _a & {y: {}} 31 - concrete: _b.y 57 + concrete: _b.y @test(eq, {}) 32 58 } 33 59 X 60 + 61 + @test(eq, { 62 + X: { 63 + _a: {foo: true} 64 + _b: {y: {}, foo: true} 65 + concrete: {} 66 + } 67 + _a: {foo: true} 68 + _b: {y: {}, foo: true} 69 + concrete: {} 70 + }) 34 71 } 35 72 sub: t3: { 36 73 #X: { 37 74 _a: foo: true 38 75 _a: _ | close({y!: z?: _}) 39 76 _b: _a & {y: {}} 40 - concrete: _b.y 77 + concrete: _b.y @test(eq, {}) 41 78 } 42 79 {#X} 80 + 81 + @test(eq, { 82 + #X: { 83 + _a: {foo: true} 84 + _b: {y: {}, foo: true} 85 + concrete: {} 86 + } 87 + _a: {foo: true} 88 + _b: {y: {}, foo: true} 89 + concrete: {} 90 + }) 43 91 } 44 92 sub: t4: { 45 93 #X: { 46 94 _a: foo: true 47 95 _a: _ | close({y!: z?: _}) 48 96 _b: _a & {y: {}} 49 - concrete: _b.y 97 + concrete: _b.y @test(eq, {}) 98 + @test(debug, #""" 99 + (#struct){ 100 + _a: (#struct){ 101 + foo: (bool){ true } 102 + } 103 + _b: (#struct){ 104 + y: (#struct){ 105 + } 106 + foo: (bool){ true } 107 + } 108 + concrete: (#struct){ 109 + } 110 + } 111 + """#) 50 112 } 51 113 #X 114 + 115 + @test(eq, { 116 + #X: { 117 + _a: {foo: true} 118 + _b: {y: {}, foo: true} 119 + concrete: {} 120 + } 121 + _a: {foo: true} 122 + _b: {y: {}, foo: true} 123 + concrete: {} 124 + }) 52 125 } 53 126 54 127 full: { ··· 58 131 59 132 _dataWithExtra: _data & {Extra: {}} 60 133 61 - out: _dataWithExtra.Extra != _|_ 134 + out: _dataWithExtra.Extra != _|_ @test(eq, true) 62 135 } 63 136 64 137 {#Foo} 138 + 139 + @test(eq, { 140 + #Foo: { 141 + _data: {Foo: true} 142 + _dataWithExtra: {Extra: {}, Foo: true} 143 + out: true 144 + } 145 + _data: {Foo: true} 146 + _dataWithExtra: {Extra: {}, Foo: true} 147 + out: true 148 + }) 65 149 } 150 + -- out/errors.txt -- 66 151 -- out/eval/stats -- 67 152 Leaks: 60 68 153 Freed: 279 ··· 76 161 Notifications: 6 77 162 78 163 NumCloseIDs: 69 79 - -- out/evalalpha -- 80 - (struct){ 81 - X: (struct){ 82 - _a: (struct){ 83 - foo: (bool){ true } 84 - } 85 - _b: (struct){ 86 - y: (struct){ 87 - } 88 - foo: (bool){ true } 89 - } 90 - concrete: (struct){ 91 - } 92 - isTrue: (bool){ true } 93 - } 94 - sub: (struct){ 95 - t1: (struct){ 96 - X: (struct){ 97 - _a: (struct){ 98 - foo: (bool){ true } 99 - } 100 - _b: (struct){ 101 - y: (struct){ 102 - } 103 - foo: (bool){ true } 104 - } 105 - concrete: (struct){ 106 - } 107 - } 108 - _a: (struct){ 109 - foo: (bool){ true } 110 - } 111 - _b: (struct){ 112 - y: (struct){ 113 - } 114 - foo: (bool){ true } 115 - } 116 - concrete: (struct){ 117 - } 118 - } 119 - t2: (struct){ 120 - X: (struct){ 121 - _a: (struct){ 122 - foo: (bool){ true } 123 - } 124 - _b: (struct){ 125 - y: (struct){ 126 - } 127 - foo: (bool){ true } 128 - } 129 - concrete: (struct){ 130 - } 131 - } 132 - _a: (struct){ 133 - foo: (bool){ true } 134 - } 135 - _b: (struct){ 136 - y: (struct){ 137 - } 138 - foo: (bool){ true } 139 - } 140 - concrete: (struct){ 141 - } 142 - } 143 - t3: (#struct){ 144 - #X: (#struct){ 145 - _a: (#struct){ 146 - foo: (bool){ true } 147 - } 148 - _b: (#struct){ 149 - y: (#struct){ 150 - } 151 - foo: (bool){ true } 152 - } 153 - concrete: (#struct){ 154 - } 155 - } 156 - _a: (#struct){ 157 - foo: (bool){ true } 158 - } 159 - _b: (#struct){ 160 - y: (#struct){ 161 - } 162 - foo: (bool){ true } 163 - } 164 - concrete: (#struct){ 165 - } 166 - } 167 - t4: (#struct){ 168 - #X: (#struct){ 169 - _a: (#struct){ 170 - foo: (bool){ true } 171 - } 172 - _b: (#struct){ 173 - y: (#struct){ 174 - } 175 - foo: (bool){ true } 176 - } 177 - concrete: (#struct){ 178 - } 179 - } 180 - _a: (#struct){ 181 - foo: (bool){ true } 182 - } 183 - _b: (#struct){ 184 - y: (#struct){ 185 - } 186 - foo: (bool){ true } 187 - } 188 - concrete: (#struct){ 189 - } 190 - } 191 - } 192 - full: (#struct){ 193 - #Foo: (#struct){ 194 - _data: (#struct){ 195 - Foo: (bool){ true } 196 - } 197 - _dataWithExtra: (#struct){ 198 - Extra: (#struct){ 199 - } 200 - Foo: (bool){ true } 201 - } 202 - out: (bool){ true } 203 - } 204 - _data: (#struct){ 205 - Foo: (bool){ true } 206 - } 207 - _dataWithExtra: (#struct){ 208 - Extra: (#struct){ 209 - } 210 - Foo: (bool){ true } 211 - } 212 - out: (bool){ true } 213 - } 214 - _a: (struct){ 215 - foo: (bool){ true } 216 - } 217 - _b: (struct){ 218 - y: (struct){ 219 - } 220 - foo: (bool){ true } 221 - } 222 - concrete: (struct){ 223 - } 224 - isTrue: (bool){ true } 225 - } 226 - -- diff/-out/evalalpha<==>+out/eval -- 227 - diff old new 228 - --- old 229 - +++ new 230 - @@ -4,25 +4,14 @@ 231 - foo: (bool){ true } 232 - } 233 - _b: (struct){ 234 - - foo: (bool){ true } 235 - y: (struct){ 236 - } 237 - + foo: (bool){ true } 238 - } 239 - concrete: (struct){ 240 - } 241 - isTrue: (bool){ true } 242 - } 243 - - _a: (struct){ 244 - - foo: (bool){ true } 245 - - } 246 - - _b: (struct){ 247 - - foo: (bool){ true } 248 - - y: (struct){ 249 - - } 250 - - } 251 - - concrete: (struct){ 252 - - } 253 - - isTrue: (bool){ true } 254 - sub: (struct){ 255 - t1: (struct){ 256 - X: (struct){ 257 - @@ -30,20 +19,20 @@ 258 - foo: (bool){ true } 259 - } 260 - _b: (struct){ 261 - - foo: (bool){ true } 262 - - y: (struct){ 263 - - } 264 - - } 265 - - concrete: (struct){ 266 - - } 267 - - } 268 - - _a: (struct){ 269 - - foo: (bool){ true } 270 - - } 271 - - _b: (struct){ 272 - - foo: (bool){ true } 273 - - y: (struct){ 274 - - } 275 - + y: (struct){ 276 - + } 277 - + foo: (bool){ true } 278 - + } 279 - + concrete: (struct){ 280 - + } 281 - + } 282 - + _a: (struct){ 283 - + foo: (bool){ true } 284 - + } 285 - + _b: (struct){ 286 - + y: (struct){ 287 - + } 288 - + foo: (bool){ true } 289 - } 290 - concrete: (struct){ 291 - } 292 - @@ -54,20 +43,20 @@ 293 - foo: (bool){ true } 294 - } 295 - _b: (struct){ 296 - - foo: (bool){ true } 297 - - y: (struct){ 298 - - } 299 - - } 300 - - concrete: (struct){ 301 - - } 302 - - } 303 - - _a: (struct){ 304 - - foo: (bool){ true } 305 - - } 306 - - _b: (struct){ 307 - - foo: (bool){ true } 308 - - y: (struct){ 309 - - } 310 - + y: (struct){ 311 - + } 312 - + foo: (bool){ true } 313 - + } 314 - + concrete: (struct){ 315 - + } 316 - + } 317 - + _a: (struct){ 318 - + foo: (bool){ true } 319 - + } 320 - + _b: (struct){ 321 - + y: (struct){ 322 - + } 323 - + foo: (bool){ true } 324 - } 325 - concrete: (struct){ 326 - } 327 - @@ -78,20 +67,20 @@ 328 - foo: (bool){ true } 329 - } 330 - _b: (#struct){ 331 - - foo: (bool){ true } 332 - - y: (#struct){ 333 - - } 334 - - } 335 - - concrete: (#struct){ 336 - - } 337 - - } 338 - - _a: (#struct){ 339 - - foo: (bool){ true } 340 - - } 341 - - _b: (#struct){ 342 - - foo: (bool){ true } 343 - - y: (#struct){ 344 - - } 345 - + y: (#struct){ 346 - + } 347 - + foo: (bool){ true } 348 - + } 349 - + concrete: (#struct){ 350 - + } 351 - + } 352 - + _a: (#struct){ 353 - + foo: (bool){ true } 354 - + } 355 - + _b: (#struct){ 356 - + y: (#struct){ 357 - + } 358 - + foo: (bool){ true } 359 - } 360 - concrete: (#struct){ 361 - } 362 - @@ -102,20 +91,20 @@ 363 - foo: (bool){ true } 364 - } 365 - _b: (#struct){ 366 - - foo: (bool){ true } 367 - - y: (#struct){ 368 - - } 369 - - } 370 - - concrete: (#struct){ 371 - - } 372 - - } 373 - - _a: (#struct){ 374 - - foo: (bool){ true } 375 - - } 376 - - _b: (#struct){ 377 - - foo: (bool){ true } 378 - - y: (#struct){ 379 - - } 380 - + y: (#struct){ 381 - + } 382 - + foo: (bool){ true } 383 - + } 384 - + concrete: (#struct){ 385 - + } 386 - + } 387 - + _a: (#struct){ 388 - + foo: (bool){ true } 389 - + } 390 - + _b: (#struct){ 391 - + y: (#struct){ 392 - + } 393 - + foo: (bool){ true } 394 - } 395 - concrete: (#struct){ 396 - } 397 - @@ -127,9 +116,9 @@ 398 - Foo: (bool){ true } 399 - } 400 - _dataWithExtra: (#struct){ 401 - - Foo: (bool){ true } 402 - Extra: (#struct){ 403 - } 404 - + Foo: (bool){ true } 405 - } 406 - out: (bool){ true } 407 - } 408 - @@ -137,10 +126,21 @@ 409 - Foo: (bool){ true } 410 - } 411 - _dataWithExtra: (#struct){ 412 - - Foo: (bool){ true } 413 - Extra: (#struct){ 414 - } 415 - + Foo: (bool){ true } 416 - } 417 - out: (bool){ true } 418 - } 419 - + _a: (struct){ 420 - + foo: (bool){ true } 421 - + } 422 - + _b: (struct){ 423 - + y: (struct){ 424 - + } 425 - + foo: (bool){ true } 426 - + } 427 - + concrete: (struct){ 428 - + } 429 - + isTrue: (bool){ true } 430 - } 431 - -- out/eval -- 432 - (struct){ 433 - X: (struct){ 434 - _a: (struct){ 435 - foo: (bool){ true } 436 - } 437 - _b: (struct){ 438 - foo: (bool){ true } 439 - y: (struct){ 440 - } 441 - } 442 - concrete: (struct){ 443 - } 444 - isTrue: (bool){ true } 445 - } 446 - _a: (struct){ 447 - foo: (bool){ true } 448 - } 449 - _b: (struct){ 450 - foo: (bool){ true } 451 - y: (struct){ 452 - } 453 - } 454 - concrete: (struct){ 455 - } 456 - isTrue: (bool){ true } 457 - sub: (struct){ 458 - t1: (struct){ 459 - X: (struct){ 460 - _a: (struct){ 461 - foo: (bool){ true } 462 - } 463 - _b: (struct){ 464 - foo: (bool){ true } 465 - y: (struct){ 466 - } 467 - } 468 - concrete: (struct){ 469 - } 470 - } 471 - _a: (struct){ 472 - foo: (bool){ true } 473 - } 474 - _b: (struct){ 475 - foo: (bool){ true } 476 - y: (struct){ 477 - } 478 - } 479 - concrete: (struct){ 480 - } 481 - } 482 - t2: (struct){ 483 - X: (struct){ 484 - _a: (struct){ 485 - foo: (bool){ true } 486 - } 487 - _b: (struct){ 488 - foo: (bool){ true } 489 - y: (struct){ 490 - } 491 - } 492 - concrete: (struct){ 493 - } 494 - } 495 - _a: (struct){ 496 - foo: (bool){ true } 497 - } 498 - _b: (struct){ 499 - foo: (bool){ true } 500 - y: (struct){ 501 - } 502 - } 503 - concrete: (struct){ 504 - } 505 - } 506 - t3: (#struct){ 507 - #X: (#struct){ 508 - _a: (#struct){ 509 - foo: (bool){ true } 510 - } 511 - _b: (#struct){ 512 - foo: (bool){ true } 513 - y: (#struct){ 514 - } 515 - } 516 - concrete: (#struct){ 517 - } 518 - } 519 - _a: (#struct){ 520 - foo: (bool){ true } 521 - } 522 - _b: (#struct){ 523 - foo: (bool){ true } 524 - y: (#struct){ 525 - } 526 - } 527 - concrete: (#struct){ 528 - } 529 - } 530 - t4: (#struct){ 531 - #X: (#struct){ 532 - _a: (#struct){ 533 - foo: (bool){ true } 534 - } 535 - _b: (#struct){ 536 - foo: (bool){ true } 537 - y: (#struct){ 538 - } 539 - } 540 - concrete: (#struct){ 541 - } 542 - } 543 - _a: (#struct){ 544 - foo: (bool){ true } 545 - } 546 - _b: (#struct){ 547 - foo: (bool){ true } 548 - y: (#struct){ 549 - } 550 - } 551 - concrete: (#struct){ 552 - } 553 - } 554 - } 555 - full: (#struct){ 556 - #Foo: (#struct){ 557 - _data: (#struct){ 558 - Foo: (bool){ true } 559 - } 560 - _dataWithExtra: (#struct){ 561 - Foo: (bool){ true } 562 - Extra: (#struct){ 563 - } 564 - } 565 - out: (bool){ true } 566 - } 567 - _data: (#struct){ 568 - Foo: (bool){ true } 569 - } 570 - _dataWithExtra: (#struct){ 571 - Foo: (bool){ true } 572 - Extra: (#struct){ 573 - } 574 - } 575 - out: (bool){ true } 576 - } 577 - } 164 + -- out/diff-v2-v3.txt -- 165 + Disjunction handling: _a: _ | close({y!: z?: _}) uses disjunction; needs @test(final) for precise testing. 166 + Verdict: cosmetic -- Disjunction with @test(final) annotation artifact. No semantic change. 578 167 -- out/compile -- 579 168 --- in.cue 580 169 {
+5 -68
cue/testdata/definitions/issue3851.txtar
··· 1 1 # Tests that a nested optional field structure combined with let bindings and 2 2 # disjunctions (#Output: null | #App) evaluates correctly without false errors. 3 3 # https://cuelang.org/issue/3851 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 #App: { 7 6 name?: string 8 7 sub1?: sub2?: null | _ 9 8 } 10 - #Output: null | #App 9 + #Output: null | #App @test(eq, null | {name?: string, sub1?: {sub2?: null | _}}) 11 10 out: #Output & { 12 11 name: "foo" 13 12 sub1: sub2: {} | _ ··· 17 16 foo: _let 18 17 } 19 18 } 20 - } 19 + } @test(eq, {name: "foo", sub1: {sub2: {sub3: {foo: "bar"}}}}) 21 20 -- out/eval/stats -- 22 21 Leaks: 8 23 22 Freed: 52 ··· 31 30 Notifications: 2 32 31 33 32 NumCloseIDs: 5 34 - -- out/evalalpha -- 35 - (struct){ 36 - #App: (#struct){ 37 - name?: (string){ string } 38 - sub1?: (#struct){ 39 - sub2?: (_){ |((null){ null }, (_){ _ }) } 40 - } 41 - } 42 - #Output: ((null|struct)){ |((null){ null }, (#struct){ 43 - name?: (string){ string } 44 - sub1?: (#struct){ 45 - sub2?: (_){ |((null){ null }, (_){ _ }) } 46 - } 47 - }) } 48 - out: (#struct){ 49 - name: (string){ "foo" } 50 - sub1: (#struct){ 51 - sub2: (#struct){ 52 - sub3: (struct){ 53 - let _let#1 = (string){ "bar" } 54 - foo: (string){ "bar" } 55 - } 56 - } 57 - } 58 - } 59 - } 60 - -- diff/-out/evalalpha<==>+out/eval -- 61 - diff old new 62 - --- old 63 - +++ new 64 - @@ -14,7 +14,7 @@ 65 - out: (#struct){ 66 - name: (string){ "foo" } 67 - sub1: (#struct){ 68 - - sub2: (struct){ 69 - + sub2: (#struct){ 70 - sub3: (struct){ 71 - let _let#1 = (string){ "bar" } 72 - foo: (string){ "bar" } 73 - -- out/eval -- 74 - (struct){ 75 - #App: (#struct){ 76 - name?: (string){ string } 77 - sub1?: (#struct){ 78 - sub2?: (_){ |((null){ null }, (_){ _ }) } 79 - } 80 - } 81 - #Output: ((null|struct)){ |((null){ null }, (#struct){ 82 - name?: (string){ string } 83 - sub1?: (#struct){ 84 - sub2?: (_){ |((null){ null }, (_){ _ }) } 85 - } 86 - }) } 87 - out: (#struct){ 88 - name: (string){ "foo" } 89 - sub1: (#struct){ 90 - sub2: (struct){ 91 - sub3: (struct){ 92 - let _let#1 = (string){ "bar" } 93 - foo: (string){ "bar" } 94 - } 95 - } 96 - } 97 - } 98 - } 99 33 -- out/compile -- 100 34 --- in.cue 101 35 { ··· 121 55 } 122 56 }) 123 57 } 58 + -- out/diff-v2-v3.txt -- 59 + Disjunctions with defaults: needs @test(final) for default field selection 60 + v3: sub2 is (#struct); v2: sub2 is (struct)
+16 -41
cue/testdata/definitions/issue483.txtar
··· 1 1 # Tests that optional nested fields within a definition unified with an open struct 2 2 # (#Root: {...}) correctly accept concrete values without "field not allowed" errors. 3 3 # https://cuelang.org/issue/483 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 4 -- in.cue -- 6 5 out: { 7 6 instance 8 - } 7 + } @test(eq, {alpha: bravo: charlie: true}) 8 + 9 9 instance: #Type & { 10 10 alpha: bravo: charlie: true 11 - } 11 + } @test(eq, {alpha: bravo: charlie: true}) 12 + 12 13 #Type: #Root & { 13 14 alpha?: bravo?: charlie?: bool 14 15 } 15 16 #Root: {...} 16 - -- out/eval/stats -- 17 - Leaks: 0 18 - Freed: 14 19 - Reused: 6 20 - Allocs: 8 21 - Retain: 0 22 - 23 - Unifications: 14 24 - Conjuncts: 32 25 - Disjuncts: 0 26 - 27 - NumCloseIDs: 8 28 - -- out/evalalpha -- 29 - (struct){ 30 - out: (#struct){ 31 - alpha: (#struct){ 32 - bravo: (#struct){ 33 - charlie: (bool){ true } 34 - } 35 - } 36 - } 37 - instance: (#struct){ 38 - alpha: (#struct){ 39 - bravo: (#struct){ 40 - charlie: (bool){ true } 41 - } 42 - } 43 - } 44 - #Type: (#struct){ 45 - alpha?: (#struct){ 46 - bravo?: (#struct){ 47 - charlie?: (bool){ bool } 48 - } 49 - } 50 - } 51 - #Root: (#struct){ 52 - } 53 - } 54 17 -- out/compile -- 55 18 --- in.cue 56 19 { ··· 75 38 ... 76 39 } 77 40 } 41 + -- out/eval/stats -- 42 + Leaks: 0 43 + Freed: 14 44 + Reused: 6 45 + Allocs: 8 46 + Retain: 0 47 + 48 + Unifications: 14 49 + Conjuncts: 32 50 + Disjuncts: 0 51 + 52 + NumCloseIDs: 8
+15 -56
cue/testdata/definitions/issue491.txtar
··· 1 1 # Tests that a definition used as a list element type correctly propagates default 2 2 # values and does not incorrectly reject fields like Pattern when unified. 3 3 # https://cuelang.org/issue/491 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 package x 7 6 ··· 25 24 x: [...#Repo] 26 25 x: [{ 27 26 Var: "REPO1" 28 - }] 27 + }] @test(eq, [{Var: "REPO1", Pattern: *"*" | string}]) 29 28 30 29 y: #Repo & { 31 30 Var: "REPO1" 32 - } 31 + } @test(eq, {Var: "REPO1", Pattern: *"*" | string}) 33 32 34 33 z: #PrestepNewUser & { 35 34 Args: { ··· 37 36 Var: "REPO1" 38 37 }] 39 38 } 40 - } 41 - -- out/eval/stats -- 42 - Leaks: 9 43 - Freed: 33 44 - Reused: 23 45 - Allocs: 19 46 - Retain: 0 47 - 48 - Unifications: 24 49 - Conjuncts: 60 50 - Disjuncts: 14 51 - 52 - NumCloseIDs: 8 53 - -- out/evalalpha -- 54 - (struct){ 55 - #Prestep: (#struct){ 56 - Args: (_){ |(*(null){ null }, (_){ _ }) } 57 - } 58 - #PrestepNewUser: (#struct){ 59 - Args: (#struct){ 60 - Repos: (list){ 61 - } 62 - } 63 - } 64 - #NewUser: (#struct){ 65 - Repos: (list){ 66 - } 67 - } 68 - #Repo: (#struct){ 69 - Var: (string){ string } 70 - Pattern: (string){ |(*(string){ "*" }, (string){ string }) } 71 - } 72 - x: (#list){ 73 - 0: (#struct){ 74 - Var: (string){ "REPO1" } 75 - Pattern: (string){ |(*(string){ "*" }, (string){ string }) } 76 - } 77 - } 78 - y: (#struct){ 79 - Var: (string){ "REPO1" } 80 - Pattern: (string){ |(*(string){ "*" }, (string){ string }) } 81 - } 82 - z: (#struct){ 83 - Args: (#struct){ 84 - Repos: (#list){ 85 - 0: (#struct){ 86 - Var: (string){ "REPO1" } 87 - Pattern: (string){ |(*(string){ "*" }, (string){ string }) } 88 - } 89 - } 90 - } 91 - } 92 - } 39 + } @test(eq, {Args: {Repos: [{Var: "REPO1", Pattern: *"*" | string}]}}) 93 40 -- out/compile -- 94 41 --- in.cue 95 42 { ··· 129 76 } 130 77 }) 131 78 } 79 + -- out/eval/stats -- 80 + Leaks: 9 81 + Freed: 33 82 + Reused: 23 83 + Allocs: 19 84 + Retain: 0 85 + 86 + Unifications: 24 87 + Conjuncts: 60 88 + Disjuncts: 14 89 + 90 + NumCloseIDs: 8
+18 -88
cue/testdata/definitions/issue493.txtar
··· 1 1 # Tests that a disjunction of identical definitions (#Both: #App | #Atom where 2 2 # both alias the same type) correctly unifies with an additional constraint. 3 3 # https://cuelang.org/issue/493 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 #Artifact: { 7 6 body: _ 8 7 other: [string]: int 9 - } 8 + } @test(shareID=appAtom) 10 9 11 - #App: #Artifact 12 - #Atom: #Artifact 10 + #App: #Artifact @test(shareID=appAtom) 11 + #Atom: #Artifact @test(shareID=appAtom) 13 12 14 13 #Both: #App | #Atom 15 14 16 - t1: #Both & {body: 3} 17 - -- out/eval/stats -- 18 - Leaks: 6 19 - Freed: 15 20 - Reused: 5 21 - Allocs: 16 22 - Retain: 0 23 - 24 - Unifications: 15 25 - Conjuncts: 27 26 - Disjuncts: 4 27 - 28 - NumCloseIDs: 5 29 - -- out/evalalpha -- 30 - (struct){ 31 - #Artifact: (#struct){ 32 - body: (_){ _ } 33 - other: (#struct){ 34 - } 35 - } 36 - #App: ~(#Artifact) 37 - #Atom: ~(#Artifact) 38 - #Both: (#struct){ 39 - body: (_){ _ } 40 - other: (#struct){ 41 - } 42 - } 43 - t1: (#struct){ 44 - body: (int){ 3 } 45 - other: (#struct){ 46 - } 47 - } 48 - } 49 - -- diff/-out/evalalpha<==>+out/eval -- 50 - diff old new 51 - --- old 52 - +++ new 53 - @@ -4,16 +4,8 @@ 54 - other: (#struct){ 55 - } 56 - } 57 - - #App: (#struct){ 58 - - body: (_){ _ } 59 - - other: (#struct){ 60 - - } 61 - - } 62 - - #Atom: (#struct){ 63 - - body: (_){ _ } 64 - - other: (#struct){ 65 - - } 66 - - } 67 - + #App: ~(#Artifact) 68 - + #Atom: ~(#Artifact) 69 - #Both: (#struct){ 70 - body: (_){ _ } 71 - other: (#struct){ 72 - -- out/eval -- 73 - (struct){ 74 - #Artifact: (#struct){ 75 - body: (_){ _ } 76 - other: (#struct){ 77 - } 78 - } 79 - #App: (#struct){ 80 - body: (_){ _ } 81 - other: (#struct){ 82 - } 83 - } 84 - #Atom: (#struct){ 85 - body: (_){ _ } 86 - other: (#struct){ 87 - } 88 - } 89 - #Both: (#struct){ 90 - body: (_){ _ } 91 - other: (#struct){ 92 - } 93 - } 94 - t1: (#struct){ 95 - body: (int){ 3 } 96 - other: (#struct){ 97 - } 98 - } 99 - } 15 + t1: #Both & {body: 3} @test(eq, {body: 3, other: {}}) 100 16 -- out/compile -- 101 17 --- in.cue 102 18 { ··· 113 29 body: 3 114 30 }) 115 31 } 32 + -- out/eval/stats -- 33 + Leaks: 6 34 + Freed: 15 35 + Reused: 5 36 + Allocs: 16 37 + Retain: 0 38 + 39 + Unifications: 15 40 + Conjuncts: 27 41 + Disjuncts: 4 42 + 43 + NumCloseIDs: 5 44 + -- out/diff-v2-v3.txt -- 45 + Reordering
+15 -53
cue/testdata/definitions/issue496.txtar
··· 1 1 # Tests that hidden fields within a definition unified with #A: _ are correctly 2 2 # handled and do not cause spurious "field not allowed" errors. 3 3 # https://cuelang.org/issue/496 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 4 -- in.cue -- 6 5 #A: _ 7 6 ··· 9 8 _E: { 10 9 name: "hello" 11 10 } 11 + } @test(shareID=lN) 12 + 13 + l: #N @test(shareID=lN) 14 + -- out/compile -- 15 + --- in.cue 16 + { 17 + #A: _ 18 + #N: (〈0;#A〉 & { 19 + _E: { 20 + name: "hello" 21 + } 22 + }) 23 + l: 〈0;#N〉 12 24 } 13 - 14 - l: #N 15 25 -- out/eval/stats -- 16 26 Leaks: 0 17 27 Freed: 6 ··· 24 34 Disjuncts: 0 25 35 26 36 NumCloseIDs: 1 27 - -- out/evalalpha -- 28 - (struct){ 29 - #A: (_){ _ } 30 - #N: (#struct){ 31 - _E: (#struct){ 32 - name: (string){ "hello" } 33 - } 34 - } 35 - l: ~(#N) 36 - } 37 - -- diff/-out/evalalpha<==>+out/eval -- 38 - diff old new 39 - --- old 40 - +++ new 41 - @@ -5,9 +5,5 @@ 42 - name: (string){ "hello" } 43 - } 44 - } 45 - - l: (#struct){ 46 - - _E: (#struct){ 47 - - name: (string){ "hello" } 48 - - } 49 - - } 50 - + l: ~(#N) 51 - } 52 - -- out/eval -- 53 - (struct){ 54 - #A: (_){ _ } 55 - #N: (#struct){ 56 - _E: (#struct){ 57 - name: (string){ "hello" } 58 - } 59 - } 60 - l: (#struct){ 61 - _E: (#struct){ 62 - name: (string){ "hello" } 63 - } 64 - } 65 - } 66 - -- out/compile -- 67 - --- in.cue 68 - { 69 - #A: _ 70 - #N: (〈0;#A〉 & { 71 - _E: { 72 - name: "hello" 73 - } 74 - }) 75 - l: 〈0;#N〉 76 - } 37 + -- out/diff-v2-v3.txt -- 38 + Reordering
+16 -62
cue/testdata/definitions/issue497.txtar
··· 1 1 # Tests that nested fields within a definition unified with #A: _ are accepted 2 2 # and do not produce spurious "field not allowed" errors on the nested structure. 3 3 # https://cuelang.org/issue/497 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 4 -- in.cue -- 6 5 #A: _ 7 6 ··· 9 8 f: j: { 10 9 n: "hi" 11 10 } 12 - } 13 - 14 - l: #N 15 - -- out/eval/stats -- 16 - Leaks: 0 17 - Freed: 7 18 - Reused: 0 19 - Allocs: 7 20 - Retain: 0 21 - 22 - Unifications: 7 23 - Conjuncts: 9 24 - Disjuncts: 0 11 + } @test(shareID=lN) @test(eq, {f: {j: {n: "hi"}}}) 25 12 26 - NumCloseIDs: 1 27 - -- out/evalalpha -- 28 - (struct){ 29 - #A: (_){ _ } 30 - #N: (#struct){ 31 - f: (#struct){ 32 - j: (#struct){ 33 - n: (string){ "hi" } 34 - } 35 - } 36 - } 37 - l: ~(#N) 38 - } 39 - -- diff/-out/evalalpha<==>+out/eval -- 40 - diff old new 41 - --- old 42 - +++ new 43 - @@ -7,11 +7,5 @@ 44 - } 45 - } 46 - } 47 - - l: (#struct){ 48 - - f: (#struct){ 49 - - j: (#struct){ 50 - - n: (string){ "hi" } 51 - - } 52 - - } 53 - - } 54 - + l: ~(#N) 55 - } 56 - -- out/eval -- 57 - (struct){ 58 - #A: (_){ _ } 59 - #N: (#struct){ 60 - f: (#struct){ 61 - j: (#struct){ 62 - n: (string){ "hi" } 63 - } 64 - } 65 - } 66 - l: (#struct){ 67 - f: (#struct){ 68 - j: (#struct){ 69 - n: (string){ "hi" } 70 - } 71 - } 72 - } 73 - } 13 + l: #N @test(shareID=lN) 74 14 -- out/compile -- 75 15 --- in.cue 76 16 { ··· 84 24 }) 85 25 l: 〈0;#N〉 86 26 } 27 + -- out/eval/stats -- 28 + Leaks: 0 29 + Freed: 7 30 + Reused: 0 31 + Allocs: 7 32 + Retain: 0 33 + 34 + Unifications: 7 35 + Conjuncts: 9 36 + Disjuncts: 0 37 + 38 + NumCloseIDs: 1 39 + -- out/diff-v2-v3.txt -- 40 + Reordering
+22 -96
cue/testdata/definitions/issue533.txtar
··· 1 1 # Tests that hidden definitions (_#x) enforce closedness the same way regular 2 2 # definitions (#x) do, rejecting extra fields not declared in the definition. 3 3 # https://cuelang.org/issue/533 4 - #todo:inline: medium — definitions with closedness; check @test(closed) support 5 4 -- in.cue -- 6 5 package x 7 6 ··· 15 14 16 15 x1: #x & { 17 16 Name: "hello" 18 - Age: 50 17 + Age: 50 @test(err, code=eval, contains="field not allowed", pos=[]) 19 18 } 20 19 21 20 x2: _#x & { 22 21 Name: "hello" 23 - Age: 50 22 + Age: 50 @test(err, code=eval, contains="field not allowed", pos=[]) 24 23 } 24 + -- out/errors.txt -- 25 25 -- out/eval/stats -- 26 26 Leaks: 0 27 27 Freed: 11 ··· 34 34 Disjuncts: 0 35 35 36 36 NumCloseIDs: 2 37 - -- out/evalalpha -- 38 - Errors: 39 - x1.Age: field not allowed: 40 - ./in.cue:13:2 41 - x2.Age: field not allowed: 42 - ./in.cue:18:2 43 - 44 - Result: 45 - (_|_){ 46 - // [eval] 47 - #x: (#struct){ 48 - Name: (string){ string } 37 + -- out/compile -- 38 + --- in.cue 39 + { 40 + #x: { 41 + Name: string 49 42 } 50 - _#x(:x): (#struct){ 51 - Name: (string){ string } 43 + _#x(:x): { 44 + Name: string 52 45 } 53 - x1: (_|_){ 54 - // [eval] 55 - Name: (string){ "hello" } 56 - Age: (_|_){ 57 - // [eval] x1.Age: field not allowed: 58 - // ./in.cue:13:2 59 - } 60 - } 61 - x2: (_|_){ 62 - // [eval] 63 - Name: (string){ "hello" } 64 - Age: (_|_){ 65 - // [eval] x2.Age: field not allowed: 66 - // ./in.cue:18:2 67 - } 68 - } 46 + x1: (〈0;#x〉 & { 47 + Name: "hello" 48 + Age: 50 49 + }) 50 + x2: (〈0;_#x(:x)〉 & { 51 + Name: "hello" 52 + Age: 50 53 + }) 69 54 } 70 - -- diff/-out/evalalpha<==>+out/eval -- 71 - diff old new 72 - --- old 73 - +++ new 74 - @@ -1,11 +1,7 @@ 75 - Errors: 76 - x1.Age: field not allowed: 77 - - ./in.cue:3:5 78 - - ./in.cue:11:5 79 - ./in.cue:13:2 80 - x2.Age: field not allowed: 81 - - ./in.cue:7:6 82 - - ./in.cue:16:5 83 - ./in.cue:18:2 84 - 85 - Result: 86 - @@ -22,8 +18,6 @@ 87 - Name: (string){ "hello" } 88 - Age: (_|_){ 89 - // [eval] x1.Age: field not allowed: 90 - - // ./in.cue:3:5 91 - - // ./in.cue:11:5 92 - // ./in.cue:13:2 93 - } 94 - } 95 - @@ -32,8 +26,6 @@ 96 - Name: (string){ "hello" } 97 - Age: (_|_){ 98 - // [eval] x2.Age: field not allowed: 99 - - // ./in.cue:7:6 100 - - // ./in.cue:16:5 101 - // ./in.cue:18:2 102 - } 103 - } 104 - -- diff/todo/p2 -- 105 - Positions. 106 - -- out/eval -- 55 + -- out/diff-v2-v3.txt -- 56 + Positions: v3 reports fewer positions than v2 for the "field not allowed" errors. 57 + Verdict: worsening -- v3 reports fewer error positions than v2. 58 + -- out/evalalpha -- 107 59 Errors: 108 60 x1.Age: field not allowed: 109 - ./in.cue:3:5 110 - ./in.cue:11:5 111 61 ./in.cue:13:2 112 62 x2.Age: field not allowed: 113 - ./in.cue:7:6 114 - ./in.cue:16:5 115 63 ./in.cue:18:2 116 64 117 65 Result: ··· 128 76 Name: (string){ "hello" } 129 77 Age: (_|_){ 130 78 // [eval] x1.Age: field not allowed: 131 - // ./in.cue:3:5 132 - // ./in.cue:11:5 133 79 // ./in.cue:13:2 134 80 } 135 81 } ··· 138 84 Name: (string){ "hello" } 139 85 Age: (_|_){ 140 86 // [eval] x2.Age: field not allowed: 141 - // ./in.cue:7:6 142 - // ./in.cue:16:5 143 87 // ./in.cue:18:2 144 88 } 145 89 } 146 90 } 147 - -- out/compile -- 148 - --- in.cue 149 - { 150 - #x: { 151 - Name: string 152 - } 153 - _#x(:x): { 154 - Name: string 155 - } 156 - x1: (〈0;#x〉 & { 157 - Name: "hello" 158 - Age: 50 159 - }) 160 - x2: (〈0;_#x(:x)〉 & { 161 - Name: "hello" 162 - Age: 50 163 - }) 164 - }
+5 -19
cue/testdata/definitions/issue539.txtar
··· 1 1 # Tests that combining a definition with open spread (`...`) and a non-definition 2 2 # struct preserves the expected fields including hidden definitions and defaults. 3 3 # Issue: https://cuelang.org/issue/539 4 - #todo:inline: medium — disjunctions; use @test(final) for default selection 5 4 -- in.cue -- 6 5 #Schema: { 7 6 ... ··· 15 14 } 16 15 } 17 16 18 - hello: #Schema & Component 17 + hello: #Schema & Component @test(closed) @test(eq, { 18 + hostname: *"localhost" | string 19 + _#foo: {hello: "world"} 20 + }) 21 + -- out/errors.txt -- 19 22 -- out/eval/stats -- 20 23 Leaks: 0 21 24 Freed: 14 ··· 28 31 Disjuncts: 4 29 32 30 33 NumCloseIDs: 2 31 - -- out/evalalpha -- 32 - (struct){ 33 - #Schema: (#struct){ 34 - } 35 - Component: (struct){ 36 - hostname: (string){ |(*(string){ "localhost" }, (string){ string }) } 37 - _#foo: (#struct){ 38 - hello: (string){ "world" } 39 - } 40 - } 41 - hello: (#struct){ 42 - hostname: (string){ |(*(string){ "localhost" }, (string){ string }) } 43 - _#foo: (#struct){ 44 - hello: (string){ "world" } 45 - } 46 - } 47 - } 48 34 -- out/compile -- 49 35 --- in.cue 50 36 {
+13 -32
cue/testdata/definitions/list.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 c: #R & { 4 3 w: [{}, {b: int}] 5 - } 4 + } @test(eq, {w: [{}, {b: int}]}) 6 5 #R: { 7 6 w: [{}, ...] 8 7 } 9 - -- out/eval/stats -- 10 - Leaks: 0 11 - Freed: 9 12 - Reused: 2 13 - Allocs: 7 14 - Retain: 0 15 - 16 - Unifications: 9 17 - Conjuncts: 14 18 - Disjuncts: 0 19 - 20 - NumCloseIDs: 1 21 - -- out/evalalpha -- 22 - (struct){ 23 - c: (#struct){ 24 - w: (#list){ 25 - 0: (#struct){ 26 - } 27 - 1: (#struct){ 28 - b: (int){ int } 29 - } 30 - } 31 - } 32 - #R: (#struct){ 33 - w: (list){ 34 - 0: (#struct){ 35 - } 36 - } 37 - } 38 - } 39 8 -- out/compile -- 40 9 --- in.cue 41 10 { ··· 54 23 ] 55 24 } 56 25 } 26 + -- out/eval/stats -- 27 + Leaks: 0 28 + Freed: 9 29 + Reused: 2 30 + Allocs: 7 31 + Retain: 0 32 + 33 + Unifications: 9 34 + Conjuncts: 14 35 + Disjuncts: 0 36 + 37 + NumCloseIDs: 1
+6 -11
cue/testdata/definitions/root1.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 // Test embedding at root of file 4 3 root1: 1 5 4 #Root1: x: {} 6 5 #Root1 & { } 6 + 7 + @test(eq, { 8 + root1: 1 9 + #Root1: x: {} 10 + x: {} 11 + }) 7 12 -- out/eval/stats -- 8 13 Leaks: 0 9 14 Freed: 5 ··· 17 22 Notifications: 1 18 23 19 24 NumCloseIDs: 2 20 - -- out/evalalpha -- 21 - (#struct){ 22 - root1: (int){ 1 } 23 - #Root1: (#struct){ 24 - x: (#struct){ 25 - } 26 - } 27 - x: (#struct){ 28 - } 29 - } 30 25 -- out/compile -- 31 26 --- in.cue 32 27 {
+5 -7
cue/testdata/definitions/root2.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 root2: 1 4 3 #Root2: {} 5 4 #Root2 5 + 6 + @test(eq, { 7 + root2: 1 8 + #Root2: {} 9 + }) 6 10 -- out/eval/stats -- 7 11 Leaks: 0 8 12 Freed: 3 ··· 16 20 Notifications: 1 17 21 18 22 NumCloseIDs: 2 19 - -- out/evalalpha -- 20 - (#struct){ 21 - root2: (int){ 1 } 22 - #Root2: (#struct){ 23 - } 24 - } 25 23 -- out/compile -- 26 24 --- in.cue 27 25 {
+7 -9
cue/testdata/definitions/root3.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 x: _ 4 3 #D: b: x 5 4 #D & { b: _ } 5 + 6 + @test(eq, { 7 + x: _ 8 + #D: b: _ 9 + b: _ 10 + }) 11 + -- out/errors.txt -- 6 12 -- out/eval/stats -- 7 13 Leaks: 0 8 14 Freed: 5 ··· 16 22 Notifications: 1 17 23 18 24 NumCloseIDs: 4 19 - -- out/evalalpha -- 20 - (#struct){ 21 - x: (_){ _ } 22 - #D: (#struct){ 23 - b: (_){ _ } 24 - } 25 - b: (_){ _ } 26 - } 27 25 -- out/compile -- 28 26 --- in.cue 29 27 {
+19 -87
cue/testdata/definitions/root4.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 #schema: a!: bool 4 3 _hidden & #schema // must fail here, but not elsewhere ··· 7 6 notAllowed: true 8 7 } 9 8 allowed: true 9 + 10 + @test(eq, { 11 + a: true 12 + #schema: a!: bool 13 + _hidden: { 14 + a: true 15 + notAllowed: true 16 + } 17 + allowed: true 18 + notAllowed: _|_ 19 + }) 20 + @test(err, code=eval, contains="field not allowed", pos=[in.cue:5:2]) 21 + -- out/errors.txt -- 22 + [eval] notAllowed: field not allowed: 23 + ./in.cue:5:2 10 24 -- out/eval/stats -- 11 25 Leaks: 0 12 26 Freed: 9 ··· 20 34 Notifications: 2 21 35 22 36 NumCloseIDs: 3 23 - -- out/evalalpha -- 24 - Errors: 25 - notAllowed: field not allowed: 26 - ./in.cue:5:2 27 - 28 - Result: 29 - (_|_){ 30 - // [eval] 31 - #schema: (#struct){ 32 - a!: (bool){ bool } 33 - } 34 - _hidden: (struct){ 35 - a: (bool){ true } 36 - notAllowed: (bool){ true } 37 - } 38 - allowed: (bool){ true } 39 - a: (bool){ true } 40 - notAllowed: (_|_){ 41 - // [eval] notAllowed: field not allowed: 42 - // ./in.cue:5:2 43 - } 44 - } 45 - -- diff/-out/evalalpha<==>+out/eval -- 46 - diff old new 47 - --- old 48 - +++ new 49 - @@ -1,9 +1,5 @@ 50 - Errors: 51 - notAllowed: field not allowed: 52 - - ./in.cue:1:1 53 - - ./in.cue:1:10 54 - - ./in.cue:2:1 55 - - ./in.cue:2:11 56 - ./in.cue:5:2 57 - 58 - Result: 59 - @@ -12,18 +8,14 @@ 60 - #schema: (#struct){ 61 - a!: (bool){ bool } 62 - } 63 - - a: (bool){ true } 64 - _hidden: (struct){ 65 - a: (bool){ true } 66 - notAllowed: (bool){ true } 67 - } 68 - allowed: (bool){ true } 69 - + a: (bool){ true } 70 - notAllowed: (_|_){ 71 - // [eval] notAllowed: field not allowed: 72 - - // ./in.cue:1:1 73 - - // ./in.cue:1:10 74 - - // ./in.cue:2:1 75 - - // ./in.cue:2:11 76 - // ./in.cue:5:2 77 - } 78 - } 79 - -- out/eval -- 80 - Errors: 81 - notAllowed: field not allowed: 82 - ./in.cue:1:1 83 - ./in.cue:1:10 84 - ./in.cue:2:1 85 - ./in.cue:2:11 86 - ./in.cue:5:2 87 - 88 - Result: 89 - (_|_){ 90 - // [eval] 91 - #schema: (#struct){ 92 - a!: (bool){ bool } 93 - } 94 - a: (bool){ true } 95 - _hidden: (struct){ 96 - a: (bool){ true } 97 - notAllowed: (bool){ true } 98 - } 99 - allowed: (bool){ true } 100 - notAllowed: (_|_){ 101 - // [eval] notAllowed: field not allowed: 102 - // ./in.cue:1:1 103 - // ./in.cue:1:10 104 - // ./in.cue:2:1 105 - // ./in.cue:2:11 106 - // ./in.cue:5:2 107 - } 108 - } 109 37 -- out/compile -- 110 38 --- in.cue 111 39 { ··· 119 47 } 120 48 allowed: true 121 49 } 50 + -- out/diff-v2-v3.txt -- 51 + Positions: v3 reports fewer positions than v2 for the "field not allowed" error. 52 + Reordering. 53 + notAllowed error: cannot add @test(err) to field created by embedding.
+76 -89
cue/testdata/definitions/root5.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 _schema // embed schema through indirections 4 - _schema: #Schema 5 - #Schema: a?: b?: string 3 + _schema: #Schema @test(shareID=topSchema) 4 + #Schema: { 5 + @test(shareID=topSchema) 6 + a?: b?: string 7 + } 6 8 a: b: "foo" 7 9 c: "foo" 8 10 9 11 10 12 x: { 11 13 _schema // embed schema through indirections 12 - _schema: #Schema 13 - #Schema: a?: b?: string 14 + _schema: #Schema @test(shareID=xSchema) 15 + #Schema: { 16 + @test(shareID=xSchema) 17 + a?: b?: string 18 + } 14 19 a: b: "foo" 15 20 c: "foo" 16 21 } 22 + 23 + @test(eq, { 24 + a: b: "foo" 25 + _schema: a?: b?: string 26 + #Schema: a?: b?: string 27 + c: "foo" 28 + x: { 29 + a: b: "foo" 30 + _schema: a?: b?: string 31 + #Schema: a?: b?: string 32 + c: "foo" 33 + } 34 + }) 35 + // TODO(inline): fix sharing detection across hidden fields. 36 + @test(debug, #""" 37 + (#struct){ 38 + _schema: ~(#Schema) 39 + #Schema: (#struct){ 40 + a?: (#struct){ 41 + b?: (string){ string } 42 + } 43 + } 44 + a: (#struct){ 45 + b: (string){ "foo" } 46 + } 47 + c: (string){ "foo" } 48 + x: (#struct){ 49 + _schema: ~(x.#Schema) 50 + #Schema: (#struct){ 51 + a?: (#struct){ 52 + b?: (string){ string } 53 + } 54 + } 55 + a: (#struct){ 56 + b: (string){ "foo" } 57 + } 58 + c: (string){ "foo" } 59 + } 60 + } 61 + """#) 17 62 -- out/eval/stats -- 18 63 Leaks: 0 19 64 Freed: 16 ··· 27 72 Notifications: 4 28 73 29 74 NumCloseIDs: 7 30 - -- out/evalalpha -- 31 - (#struct){ 32 - _schema: ~(#Schema) 33 - #Schema: (#struct){ 34 - a?: (#struct){ 35 - b?: (string){ string } 75 + -- out/compile -- 76 + --- in.cue 77 + { 78 + 〈0;_schema〉 79 + _schema: 〈0;#Schema〉 80 + #Schema: { 81 + a?: { 82 + b?: string 36 83 } 37 84 } 38 - a: (#struct){ 39 - b: (string){ "foo" } 85 + a: { 86 + b: "foo" 40 87 } 41 - c: (string){ "foo" } 42 - x: (#struct){ 43 - _schema: ~(x.#Schema) 44 - #Schema: (#struct){ 45 - a?: (#struct){ 46 - b?: (string){ string } 88 + c: "foo" 89 + x: { 90 + 〈0;_schema〉 91 + _schema: 〈0;#Schema〉 92 + #Schema: { 93 + a?: { 94 + b?: string 47 95 } 48 96 } 49 - a: (#struct){ 50 - b: (string){ "foo" } 97 + a: { 98 + b: "foo" 51 99 } 52 - c: (string){ "foo" } 100 + c: "foo" 53 101 } 54 102 } 55 - -- diff/-out/evalalpha<==>+out/eval -- 56 - diff old new 57 - --- old 58 - +++ new 59 - @@ -1,9 +1,5 @@ 60 - (#struct){ 61 - - _schema: (#struct){ 62 - - a?: (#struct){ 63 - - b?: (string){ string } 64 - - } 65 - - } 66 - + _schema: ~(#Schema) 67 - #Schema: (#struct){ 68 - a?: (#struct){ 69 - b?: (string){ string } 70 - @@ -14,11 +10,7 @@ 71 - } 72 - c: (string){ "foo" } 73 - x: (#struct){ 74 - - _schema: (#struct){ 75 - - a?: (#struct){ 76 - - b?: (string){ string } 77 - - } 78 - - } 79 - + _schema: ~(x.#Schema) 80 - #Schema: (#struct){ 81 - a?: (#struct){ 82 - b?: (string){ string } 83 - -- out/eval -- 103 + -- out/diff-v2-v3.txt -- 104 + Reordering 105 + Verdict: cosmetic -- Field reordering only. No semantic change. 106 + -- out/evalalpha -- 84 107 (#struct){ 85 - _schema: (#struct){ 86 - a?: (#struct){ 87 - b?: (string){ string } 88 - } 89 - } 108 + _schema: ~(#Schema) 90 109 #Schema: (#struct){ 91 110 a?: (#struct){ 92 111 b?: (string){ string } ··· 97 116 } 98 117 c: (string){ "foo" } 99 118 x: (#struct){ 100 - _schema: (#struct){ 101 - a?: (#struct){ 102 - b?: (string){ string } 103 - } 104 - } 119 + _schema: ~(x.#Schema) 105 120 #Schema: (#struct){ 106 121 a?: (#struct){ 107 122 b?: (string){ string } ··· 113 128 c: (string){ "foo" } 114 129 } 115 130 } 116 - -- out/compile -- 117 - --- in.cue 118 - { 119 - 〈0;_schema〉 120 - _schema: 〈0;#Schema〉 121 - #Schema: { 122 - a?: { 123 - b?: string 124 - } 125 - } 126 - a: { 127 - b: "foo" 128 - } 129 - c: "foo" 130 - x: { 131 - 〈0;_schema〉 132 - _schema: 〈0;#Schema〉 133 - #Schema: { 134 - a?: { 135 - b?: string 136 - } 137 - } 138 - a: { 139 - b: "foo" 140 - } 141 - c: "foo" 142 - } 143 - }
+13 -26
cue/testdata/definitions/root6.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 c: "foo" 4 3 a: b: int 5 4 #Schema 6 - #Schema: close({ a: b: int}) 5 + #Schema: close({ a: b: int}) @test(closed) 7 6 8 7 x: { 9 8 c: "foo" 10 9 a: b: int 11 10 #Schema 12 11 #Schema: close({ a: b: int}) 13 - } 12 + } @test(closed) 13 + 14 + @test(eq, { 15 + a: b: int 16 + c: "foo" 17 + #Schema: { a: b: int } 18 + x: { 19 + a: b: int 20 + c: "foo" 21 + #Schema: a: b: int 22 + } 23 + }) 14 24 -- out/eval/stats -- 15 25 Leaks: 0 16 26 Freed: 30 ··· 29 39 MaxConjunctInfos: 3 30 40 MaxReqSets: 7 31 41 MaxRedirect: 2 32 - -- out/evalalpha -- 33 - (#struct){ 34 - c: (string){ "foo" } 35 - a: (#struct){ 36 - b: (int){ int } 37 - } 38 - #Schema: (#struct){ 39 - a: (#struct){ 40 - b: (int){ int } 41 - } 42 - } 43 - x: (#struct){ 44 - c: (string){ "foo" } 45 - a: (#struct){ 46 - b: (int){ int } 47 - } 48 - #Schema: (#struct){ 49 - a: (#struct){ 50 - b: (int){ int } 51 - } 52 - } 53 - } 54 - } 55 42 -- out/compile -- 56 43 --- in.cue 57 44 {
+3 -12
cue/testdata/definitions/root7.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 root: input: #deps: root: {} 4 3 {root.input.#deps} 4 + 5 + @test(eq, { root: input: #deps: root: {} }) 6 + -- out/errors.txt -- 5 7 -- out/eval/stats -- 6 8 Leaks: 0 7 9 Freed: 5 ··· 15 17 Notifications: 1 16 18 17 19 NumCloseIDs: 3 18 - -- out/evalalpha -- 19 - (#struct){ 20 - root: (#struct){ 21 - input: (struct){ 22 - #deps: (#struct){ 23 - root: (#struct){ 24 - } 25 - } 26 - } 27 - } 28 - } 29 20 -- out/compile -- 30 21 --- in.cue 31 22 {
+11 -21
cue/testdata/definitions/root8.txtar
··· 1 - #todo:inline: medium — disjunctions; use @test(final) for default selection 2 1 -- in.cue -- 3 2 root: input: foo: { 4 3 metadata: name: *"foo" | string ··· 8 7 spec: replicas: 1 9 8 } 10 9 {root.input.foo.#deps} 10 + 11 + @test(eq, { 12 + root: input: foo: { 13 + metadata: name: *"foo" | string 14 + id: "id-foo" 15 + #deps: root: {} 16 + spec: replicas: 1 17 + } 18 + }) 11 19 -- out/eval/stats -- 12 20 Leaks: 0 13 21 Freed: 13 ··· 21 29 Notifications: 1 22 30 23 31 NumCloseIDs: 3 24 - -- out/evalalpha -- 25 - (#struct){ 26 - root: (#struct){ 27 - input: (struct){ 28 - foo: (struct){ 29 - metadata: (struct){ 30 - name: (string){ |(*(string){ "foo" }, (string){ string }) } 31 - } 32 - id: (string){ "id-foo" } 33 - #deps: (#struct){ 34 - root: (#struct){ 35 - } 36 - } 37 - spec: (struct){ 38 - replicas: (int){ 1 } 39 - } 40 - } 41 - } 42 - } 43 - } 44 32 -- out/compile -- 45 33 --- in.cue 46 34 { ··· 67 55 〈1;root〉.input.foo.#deps 68 56 } 69 57 } 58 + -- out/diff-v2-v3.txt -- 59 + Disjunctions with defaults: needs @test(final) for default field selection
+9 -45
cue/testdata/definitions/visibility.txtar
··· 1 - #todo:inline: medium — definitions with closedness; check @test(closed) support 2 1 -- in.cue -- 3 2 #foo: { 4 3 name: string ··· 9 8 _#name: "bar" 10 9 11 10 #name: "baz" 12 - } 11 + } @test(closed) @test(eq, { 12 + _name: "foo" 13 + _#name: "bar" 14 + #name: "baz" 15 + name: string 16 + }) 17 + -- out/errors.txt -- 13 18 -- out/eval/stats -- 14 19 Leaks: 0 15 20 Freed: 8 ··· 22 27 Disjuncts: 0 23 28 24 29 NumCloseIDs: 1 25 - -- out/evalalpha -- 26 - (struct){ 27 - #foo: (#struct){ 28 - name: (string){ string } 29 - } 30 - foo: (#struct){ 31 - _name: (string){ "foo" } 32 - _#name: (string){ "bar" } 33 - #name: (string){ "baz" } 34 - name: (string){ string } 35 - } 36 - } 37 - -- diff/-out/evalalpha<==>+out/eval -- 38 - diff old new 39 - --- old 40 - +++ new 41 - @@ -3,9 +3,9 @@ 42 - name: (string){ string } 43 - } 44 - foo: (#struct){ 45 - - name: (string){ string } 46 - _name: (string){ "foo" } 47 - _#name: (string){ "bar" } 48 - #name: (string){ "baz" } 49 - + name: (string){ string } 50 - } 51 - } 52 - -- diff/todo/p3 -- 53 - Reordering. 54 - -- diff/explanation -- 55 - New evaluator should ultimately disallow new definitions in closed structs. 56 - -- out/eval -- 57 - (struct){ 58 - #foo: (#struct){ 59 - name: (string){ string } 60 - } 61 - foo: (#struct){ 62 - name: (string){ string } 63 - _name: (string){ "foo" } 64 - _#name: (string){ "bar" } 65 - #name: (string){ "baz" } 66 - } 67 - } 68 30 -- out/compile -- 69 31 --- in.cue 70 32 { ··· 77 39 #name: "baz" 78 40 }) 79 41 } 42 + -- out/diff-v2-v3.txt -- 43 + Reordering: v3 outputs fields in different order than v2 (name appears after hidden fields in v3).