this repo has no description
0
fork

Configure Feed

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

internal/core/adt: add tests for Issue 3929

This got fixed somewhere along the way.

Fixes #3929

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

+647
+647
cue/testdata/comprehensions/issue3929.txtar
··· 1 + -- in.cue -- 2 + package main 3 + 4 + import "strings" 5 + 6 + reduced: { 7 + #Input: { 8 + name: string 9 + age: "one" | "two" 10 + if name != _|_ { 11 + if true { 12 + age: "one" 13 + } 14 + } 15 + } 16 + 17 + #def1: { 18 + IN=_in: _ 19 + def1: #def2 & {_in: IN} 20 + } 21 + 22 + #def2: { 23 + IN=_in: _ 24 + def2: #def3 & {_in: IN} 25 + } 26 + 27 + #def3: { 28 + _in: #Input 29 + def3: _in.age 30 + } 31 + 32 + in: name: "foobar" 33 + 34 + out: (#def1 & {_in: in}).def1 35 + } 36 + 37 + full: { 38 + cronjob: [string]: #CronjobConfig 39 + 40 + #CronjobConfig: { 41 + #PodConfig 42 + } 43 + 44 + #PodConfig: { 45 + #ContainerConfig 46 + } 47 + 48 + #ContainerConfig: { 49 + image: string 50 + imagePullPolicy: "IfNotPresent" | "Always" | "Never" 51 + if image != _|_ { 52 + if strings.HasSuffix(image, ":latest") == true { 53 + imagePullPolicy: "IfNotPresent" | *"Always" | "Never" 54 + } 55 + if strings.HasSuffix(image, ":latest") != true { 56 + imagePullPolicy: *"IfNotPresent" | "Always" | "Never" 57 + } 58 + } 59 + } 60 + 61 + _#cronjob: { 62 + c=_config: #CronjobConfig 63 + 64 + out: spec: jobTemplate: spec: template: _#pod & {_config: c} 65 + } 66 + 67 + _#pod: { 68 + c=_config: #PodConfig 69 + 70 + spec: containers: [{ 71 + _#container & { 72 + _config: c 73 + } 74 + }] 75 + } 76 + 77 + _#container: { 78 + c=_config: #ContainerConfig 79 + 80 + imagePullPolicy: c.imagePullPolicy 81 + } 82 + 83 + cronjob: "foobar": image: "foobar:latest" 84 + 85 + for k, v in cronjob { 86 + objects: cronjob: "\(k)": (_#cronjob & {_config: v}).out 87 + } 88 + } 89 + -- out/evalalpha/stats -- 90 + Leaks: 154 91 + Freed: 0 92 + Reused: 0 93 + Allocs: 154 94 + Retain: 0 95 + 96 + Unifications: 97 97 + Conjuncts: 266 98 + Disjuncts: 53 99 + 100 + CloseIDElems: 1972 101 + NumCloseIDs: 101 102 + -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 103 + diff old new 104 + --- old 105 + +++ new 106 + @@ -1,12 +1,12 @@ 107 + -Leaks: 3 108 + -Freed: 652 109 + -Reused: 632 110 + -Allocs: 23 111 + -Retain: 93 112 + - 113 + -Unifications: 132 114 + -Conjuncts: 966 115 + -Disjuncts: 708 116 + - 117 + -CloseIDElems: 0 118 + -NumCloseIDs: 30 119 + +Leaks: 154 120 + +Freed: 0 121 + +Reused: 0 122 + +Allocs: 154 123 + +Retain: 0 124 + + 125 + +Unifications: 97 126 + +Conjuncts: 266 127 + +Disjuncts: 53 128 + + 129 + +CloseIDElems: 1972 130 + +NumCloseIDs: 101 131 + -- out/eval/stats -- 132 + Leaks: 3 133 + Freed: 652 134 + Reused: 632 135 + Allocs: 23 136 + Retain: 93 137 + 138 + Unifications: 132 139 + Conjuncts: 966 140 + Disjuncts: 708 141 + 142 + CloseIDElems: 0 143 + NumCloseIDs: 30 144 + -- out/evalalpha -- 145 + (struct){ 146 + reduced: (struct){ 147 + #Input: (#struct){ 148 + name: (string){ string } 149 + age: (string){ |((string){ "one" }, (string){ "two" }) } 150 + } 151 + #def1: (#struct){ 152 + _in(:main): (_){ _ } 153 + def1: (#struct){ 154 + _in(:main): (_){ _ } 155 + def2: (#struct){ 156 + _in(:main): (#struct){ 157 + name: (string){ string } 158 + age: (string){ |((string){ "one" }, (string){ "two" }) } 159 + } 160 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 161 + } 162 + } 163 + } 164 + #def2: (#struct){ 165 + _in(:main): (_){ _ } 166 + def2: (#struct){ 167 + _in(:main): (#struct){ 168 + name: (string){ string } 169 + age: (string){ |((string){ "one" }, (string){ "two" }) } 170 + } 171 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 172 + } 173 + } 174 + #def3: (#struct){ 175 + _in(:main): ~(reduced.#Input) 176 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 177 + } 178 + in: (struct){ 179 + name: (string){ "foobar" } 180 + } 181 + out: (#struct){ 182 + _in(:main): (#struct){ 183 + name: (string){ "foobar" } 184 + } 185 + def2: (#struct){ 186 + _in(:main): (#struct){ 187 + name: (string){ "foobar" } 188 + age: (string){ |((string){ "one" }, (string){ "two" }) } 189 + } 190 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 191 + } 192 + } 193 + } 194 + full: (struct){ 195 + cronjob: (struct){ 196 + foobar: (#struct){ 197 + image: (string){ "foobar:latest" } 198 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 199 + } 200 + } 201 + #CronjobConfig: (#struct){ 202 + image: (string){ string } 203 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 204 + } 205 + #PodConfig: (#struct){ 206 + image: (string){ string } 207 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 208 + } 209 + #ContainerConfig: (#struct){ 210 + image: (string){ string } 211 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 212 + } 213 + _#cronjob(:main): (#struct){ 214 + _config(:main): ~(full.#CronjobConfig) 215 + out: (#struct){ 216 + spec: (#struct){ 217 + jobTemplate: (#struct){ 218 + spec: (#struct){ 219 + template: (#struct){ 220 + _config(:main): (#struct){ 221 + image: (string){ string } 222 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 223 + } 224 + spec: (#struct){ 225 + containers: (#list){ 226 + 0: (#struct){ 227 + _config(:main): (#struct){ 228 + image: (string){ string } 229 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 230 + } 231 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 232 + } 233 + } 234 + } 235 + } 236 + } 237 + } 238 + } 239 + } 240 + } 241 + _#pod(:main): (#struct){ 242 + _config(:main): ~(full.#PodConfig) 243 + spec: (#struct){ 244 + containers: (#list){ 245 + 0: (#struct){ 246 + _config(:main): (#struct){ 247 + image: (string){ string } 248 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 249 + } 250 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 251 + } 252 + } 253 + } 254 + } 255 + _#container(:main): (#struct){ 256 + _config(:main): ~(full.#ContainerConfig) 257 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 258 + } 259 + objects: (struct){ 260 + cronjob: (struct){ 261 + foobar: (#struct){ 262 + spec: (#struct){ 263 + jobTemplate: (#struct){ 264 + spec: (#struct){ 265 + template: (#struct){ 266 + _config(:main): (#struct){ 267 + image: (string){ "foobar:latest" } 268 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 269 + } 270 + spec: (#struct){ 271 + containers: (#list){ 272 + 0: (#struct){ 273 + _config(:main): (#struct){ 274 + image: (string){ "foobar:latest" } 275 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 276 + } 277 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 278 + } 279 + } 280 + } 281 + } 282 + } 283 + } 284 + } 285 + } 286 + } 287 + } 288 + } 289 + } 290 + -- diff/-out/evalalpha<==>+out/eval -- 291 + diff old new 292 + --- old 293 + +++ new 294 + @@ -28,10 +28,7 @@ 295 + } 296 + } 297 + #def3: (#struct){ 298 + - _in(:main): (#struct){ 299 + - name: (string){ string } 300 + - age: (string){ |((string){ "one" }, (string){ "two" }) } 301 + - } 302 + + _in(:main): ~(reduced.#Input) 303 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 304 + } 305 + in: (struct){ 306 + @@ -38,15 +35,15 @@ 307 + name: (string){ "foobar" } 308 + } 309 + out: (#struct){ 310 + - _in(:main): (struct){ 311 + + _in(:main): (#struct){ 312 + name: (string){ "foobar" } 313 + } 314 + def2: (#struct){ 315 + _in(:main): (#struct){ 316 + name: (string){ "foobar" } 317 + - age: (string){ "one" } 318 + - } 319 + - def3: (string){ "one" } 320 + + age: (string){ |((string){ "one" }, (string){ "two" }) } 321 + + } 322 + + def3: (string){ |((string){ "one" }, (string){ "two" }) } 323 + } 324 + } 325 + } 326 + @@ -70,10 +67,7 @@ 327 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 328 + } 329 + _#cronjob(:main): (#struct){ 330 + - _config(:main): (#struct){ 331 + - image: (string){ string } 332 + - imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 333 + - } 334 + + _config(:main): ~(full.#CronjobConfig) 335 + out: (#struct){ 336 + spec: (#struct){ 337 + jobTemplate: (#struct){ 338 + @@ -101,10 +95,7 @@ 339 + } 340 + } 341 + _#pod(:main): (#struct){ 342 + - _config(:main): (#struct){ 343 + - image: (string){ string } 344 + - imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 345 + - } 346 + + _config(:main): ~(full.#PodConfig) 347 + spec: (#struct){ 348 + containers: (#list){ 349 + 0: (#struct){ 350 + @@ -118,18 +109,15 @@ 351 + } 352 + } 353 + _#container(:main): (#struct){ 354 + - _config(:main): (#struct){ 355 + - image: (string){ string } 356 + - imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 357 + - } 358 + + _config(:main): ~(full.#ContainerConfig) 359 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 360 + } 361 + objects: (struct){ 362 + cronjob: (struct){ 363 + - foobar: (struct){ 364 + - spec: (struct){ 365 + - jobTemplate: (struct){ 366 + - spec: (struct){ 367 + + foobar: (#struct){ 368 + + spec: (#struct){ 369 + + jobTemplate: (#struct){ 370 + + spec: (#struct){ 371 + template: (#struct){ 372 + _config(:main): (#struct){ 373 + image: (string){ "foobar:latest" } 374 + @@ -140,9 +128,9 @@ 375 + 0: (#struct){ 376 + _config(:main): (#struct){ 377 + image: (string){ "foobar:latest" } 378 + - imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 379 + + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 380 + } 381 + - imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 382 + + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 383 + } 384 + } 385 + } 386 + -- out/eval -- 387 + (struct){ 388 + reduced: (struct){ 389 + #Input: (#struct){ 390 + name: (string){ string } 391 + age: (string){ |((string){ "one" }, (string){ "two" }) } 392 + } 393 + #def1: (#struct){ 394 + _in(:main): (_){ _ } 395 + def1: (#struct){ 396 + _in(:main): (_){ _ } 397 + def2: (#struct){ 398 + _in(:main): (#struct){ 399 + name: (string){ string } 400 + age: (string){ |((string){ "one" }, (string){ "two" }) } 401 + } 402 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 403 + } 404 + } 405 + } 406 + #def2: (#struct){ 407 + _in(:main): (_){ _ } 408 + def2: (#struct){ 409 + _in(:main): (#struct){ 410 + name: (string){ string } 411 + age: (string){ |((string){ "one" }, (string){ "two" }) } 412 + } 413 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 414 + } 415 + } 416 + #def3: (#struct){ 417 + _in(:main): (#struct){ 418 + name: (string){ string } 419 + age: (string){ |((string){ "one" }, (string){ "two" }) } 420 + } 421 + def3: (string){ |((string){ "one" }, (string){ "two" }) } 422 + } 423 + in: (struct){ 424 + name: (string){ "foobar" } 425 + } 426 + out: (#struct){ 427 + _in(:main): (struct){ 428 + name: (string){ "foobar" } 429 + } 430 + def2: (#struct){ 431 + _in(:main): (#struct){ 432 + name: (string){ "foobar" } 433 + age: (string){ "one" } 434 + } 435 + def3: (string){ "one" } 436 + } 437 + } 438 + } 439 + full: (struct){ 440 + cronjob: (struct){ 441 + foobar: (#struct){ 442 + image: (string){ "foobar:latest" } 443 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 444 + } 445 + } 446 + #CronjobConfig: (#struct){ 447 + image: (string){ string } 448 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 449 + } 450 + #PodConfig: (#struct){ 451 + image: (string){ string } 452 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 453 + } 454 + #ContainerConfig: (#struct){ 455 + image: (string){ string } 456 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 457 + } 458 + _#cronjob(:main): (#struct){ 459 + _config(:main): (#struct){ 460 + image: (string){ string } 461 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 462 + } 463 + out: (#struct){ 464 + spec: (#struct){ 465 + jobTemplate: (#struct){ 466 + spec: (#struct){ 467 + template: (#struct){ 468 + _config(:main): (#struct){ 469 + image: (string){ string } 470 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 471 + } 472 + spec: (#struct){ 473 + containers: (#list){ 474 + 0: (#struct){ 475 + _config(:main): (#struct){ 476 + image: (string){ string } 477 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 478 + } 479 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 480 + } 481 + } 482 + } 483 + } 484 + } 485 + } 486 + } 487 + } 488 + } 489 + _#pod(:main): (#struct){ 490 + _config(:main): (#struct){ 491 + image: (string){ string } 492 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 493 + } 494 + spec: (#struct){ 495 + containers: (#list){ 496 + 0: (#struct){ 497 + _config(:main): (#struct){ 498 + image: (string){ string } 499 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 500 + } 501 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 502 + } 503 + } 504 + } 505 + } 506 + _#container(:main): (#struct){ 507 + _config(:main): (#struct){ 508 + image: (string){ string } 509 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 510 + } 511 + imagePullPolicy: (string){ |((string){ "IfNotPresent" }, (string){ "Always" }, (string){ "Never" }) } 512 + } 513 + objects: (struct){ 514 + cronjob: (struct){ 515 + foobar: (struct){ 516 + spec: (struct){ 517 + jobTemplate: (struct){ 518 + spec: (struct){ 519 + template: (#struct){ 520 + _config(:main): (#struct){ 521 + image: (string){ "foobar:latest" } 522 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 523 + } 524 + spec: (#struct){ 525 + containers: (#list){ 526 + 0: (#struct){ 527 + _config(:main): (#struct){ 528 + image: (string){ "foobar:latest" } 529 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 530 + } 531 + imagePullPolicy: (string){ |(*(string){ "Always" }, (string){ "IfNotPresent" }, (string){ "Never" }) } 532 + } 533 + } 534 + } 535 + } 536 + } 537 + } 538 + } 539 + } 540 + } 541 + } 542 + } 543 + } 544 + -- out/compile -- 545 + --- in.cue 546 + { 547 + reduced: { 548 + #Input: { 549 + name: string 550 + age: ("one"|"two") 551 + if (〈0;name〉 != _|_(explicit error (_|_ literal) in source)) { 552 + if true { 553 + age: "one" 554 + } 555 + } 556 + } 557 + #def1: { 558 + _in: _ 559 + def1: (〈1;#def2〉 & { 560 + _in: 〈1;_in〉 561 + }) 562 + } 563 + #def2: { 564 + _in: _ 565 + def2: (〈1;#def3〉 & { 566 + _in: 〈1;_in〉 567 + }) 568 + } 569 + #def3: { 570 + _in: 〈1;#Input〉 571 + def3: 〈0;_in〉.age 572 + } 573 + in: { 574 + name: "foobar" 575 + } 576 + out: (〈0;#def1〉 & { 577 + _in: 〈1;in〉 578 + }).def1 579 + } 580 + full: { 581 + cronjob: { 582 + [string]: 〈1;#CronjobConfig〉 583 + } 584 + #CronjobConfig: { 585 + 〈1;#PodConfig〉 586 + } 587 + #PodConfig: { 588 + 〈1;#ContainerConfig〉 589 + } 590 + #ContainerConfig: { 591 + image: string 592 + imagePullPolicy: ("IfNotPresent"|"Always"|"Never") 593 + if (〈0;image〉 != _|_(explicit error (_|_ literal) in source)) { 594 + if (〈import;strings〉.HasSuffix(〈1;image〉, ":latest") == true) { 595 + imagePullPolicy: ("IfNotPresent"|*"Always"|"Never") 596 + } 597 + if (〈import;strings〉.HasSuffix(〈1;image〉, ":latest") != true) { 598 + imagePullPolicy: (*"IfNotPresent"|"Always"|"Never") 599 + } 600 + } 601 + } 602 + _#cronjob: { 603 + _config: 〈1;#CronjobConfig〉 604 + out: { 605 + spec: { 606 + jobTemplate: { 607 + spec: { 608 + template: (〈5;_#pod〉 & { 609 + _config: 〈5;_config〉 610 + }) 611 + } 612 + } 613 + } 614 + } 615 + } 616 + _#pod: { 617 + _config: 〈1;#PodConfig〉 618 + spec: { 619 + containers: [ 620 + { 621 + (〈4;_#container〉 & { 622 + _config: 〈4;_config〉 623 + }) 624 + }, 625 + ] 626 + } 627 + } 628 + _#container: { 629 + _config: 〈1;#ContainerConfig〉 630 + imagePullPolicy: 〈0;_config〉.imagePullPolicy 631 + } 632 + cronjob: { 633 + foobar: { 634 + image: "foobar:latest" 635 + } 636 + } 637 + for k, v in 〈0;cronjob〉 { 638 + objects: { 639 + cronjob: { 640 + "\(〈3;k〉)": (〈4;_#cronjob〉 & { 641 + _config: 〈4;v〉 642 + }).out 643 + } 644 + } 645 + } 646 + } 647 + }