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 4000

Issue #4000

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

+488
+488
cue/testdata/definitions/issue4000.txtar
··· 1 + -- in.cue -- 2 + import "list" 3 + 4 + items: list.Sort(#List.items, { 5 + x: {} 6 + y: {} 7 + less: x.kind < y.kind 8 + }) 9 + 10 + #List: items: list.Concat(_items) 11 + 12 + _items: [#VMRuleList] 13 + 14 + #VMRuleList: [...null | #VMRule] & [{ 15 + spec: [{ 16 + rules: [{expr: "x"}] 17 + }] 18 + }, { 19 + spec: [{ 20 + rules: [{expr: "y"}] 21 + }] 22 + }] 23 + 24 + #RuleGroup: rules: [...#Rule] 25 + 26 + #Rule: expr: string 27 + 28 + #VMRule: { 29 + #TypeMeta 30 + spec: [...#RuleGroup] 31 + } 32 + #TypeMeta: kind: string | *"default" 33 + -- out/evalalpha -- 34 + Errors: 35 + items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 36 + ./in.cue:3:8 37 + 38 + Result: 39 + (_|_){ 40 + // [eval] 41 + items: (_|_){ 42 + // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 43 + // ./in.cue:3:8 44 + } 45 + #List: (#struct){ 46 + items: (#list){ 47 + 0: ~(#VMRuleList.0) 48 + 1: ~(#VMRuleList.1) 49 + } 50 + } 51 + _items: (#list){ 52 + 0: ~(#VMRuleList) 53 + } 54 + #VMRuleList: (#list){ 55 + 0: (#struct){ 56 + spec: (#list){ 57 + 0: (#struct){ 58 + rules: (#list){ 59 + 0: (#struct){ 60 + expr: (string){ "x" } 61 + } 62 + } 63 + } 64 + } 65 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 66 + } 67 + 1: (#struct){ 68 + spec: (#list){ 69 + 0: (#struct){ 70 + rules: (#list){ 71 + 0: (#struct){ 72 + expr: (string){ "y" } 73 + } 74 + } 75 + } 76 + } 77 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 78 + } 79 + } 80 + #RuleGroup: (#struct){ 81 + rules: (list){ 82 + } 83 + } 84 + #Rule: (#struct){ 85 + expr: (string){ string } 86 + } 87 + #VMRule: (#struct){ 88 + spec: (list){ 89 + } 90 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 91 + } 92 + #TypeMeta: (#struct){ 93 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 94 + } 95 + } 96 + -- out/compile -- 97 + --- in.cue 98 + { 99 + items: 〈import;list〉.Sort(〈0;#List〉.items, { 100 + x: {} 101 + y: {} 102 + less: (〈0;x〉.kind < 〈0;y〉.kind) 103 + }) 104 + #List: { 105 + items: 〈import;list〉.Concat(〈1;_items〉) 106 + } 107 + _items: [ 108 + 〈1;#VMRuleList〉, 109 + ] 110 + #VMRuleList: ([ 111 + ...(null|〈1;#VMRule〉), 112 + ] & [ 113 + { 114 + spec: [ 115 + { 116 + rules: [ 117 + { 118 + expr: "x" 119 + }, 120 + ] 121 + }, 122 + ] 123 + }, 124 + { 125 + spec: [ 126 + { 127 + rules: [ 128 + { 129 + expr: "y" 130 + }, 131 + ] 132 + }, 133 + ] 134 + }, 135 + ]) 136 + #RuleGroup: { 137 + rules: [ 138 + ...〈2;#Rule〉, 139 + ] 140 + } 141 + #Rule: { 142 + expr: string 143 + } 144 + #VMRule: { 145 + 〈1;#TypeMeta〉 146 + spec: [ 147 + ...〈2;#RuleGroup〉, 148 + ] 149 + } 150 + #TypeMeta: { 151 + kind: (string|*"default") 152 + } 153 + } 154 + -- out/evalalpha/stats -- 155 + Leaks: 0 156 + Freed: 52 157 + Reused: 20 158 + Allocs: 32 159 + Retain: 0 160 + 161 + Unifications: 36 162 + Conjuncts: 74 163 + Disjuncts: 12 164 + 165 + NumCloseIDs: 16 166 + -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 167 + diff old new 168 + --- old 169 + +++ new 170 + @@ -1,9 +1,11 @@ 171 + Leaks: 0 172 + -Freed: 159 173 + -Reused: 147 174 + -Allocs: 12 175 + -Retain: 6 176 + - 177 + -Unifications: 135 178 + -Conjuncts: 273 179 + -Disjuncts: 165 180 + +Freed: 52 181 + +Reused: 20 182 + +Allocs: 32 183 + +Retain: 0 184 + + 185 + +Unifications: 36 186 + +Conjuncts: 74 187 + +Disjuncts: 12 188 + + 189 + +NumCloseIDs: 16 190 + -- out/eval/stats -- 191 + Leaks: 0 192 + Freed: 152 193 + Reused: 137 194 + Allocs: 15 195 + Retain: 9 196 + 197 + Unifications: 116 198 + Conjuncts: 257 199 + Disjuncts: 161 200 + -- diff/-out/evalalpha<==>+out/eval -- 201 + diff old new 202 + --- old 203 + +++ new 204 + @@ -1,103 +1,62 @@ 205 + -(struct){ 206 + - items: (#list){ 207 + +Errors: 208 + +items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 209 + + ./in.cue:3:8 210 + + 211 + +Result: 212 + +(_|_){ 213 + + // [eval] 214 + + items: (_|_){ 215 + + // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 216 + + // ./in.cue:3:8 217 + + } 218 + + #List: (#struct){ 219 + + items: (#list){ 220 + + 0: ~(#VMRuleList.0) 221 + + 1: ~(#VMRuleList.1) 222 + + } 223 + + } 224 + + _items: (#list){ 225 + + 0: ~(#VMRuleList) 226 + + } 227 + + #VMRuleList: (#list){ 228 + 0: (#struct){ 229 + - kind: (string){ "1_first" } 230 + - rules: (#list){ 231 + - 0: (#struct){ 232 + - expr: (string){ "c" } 233 + - } 234 + - 1: (#struct){ 235 + - expr: (string){ "d" } 236 + - } 237 + - } 238 + - } 239 + - 1: (#struct){ 240 + - kind: (string){ "2_second" } 241 + - rules: (#list){ 242 + - 0: (#struct){ 243 + - expr: (string){ "a" } 244 + - } 245 + - 1: (#struct){ 246 + - expr: (string){ "b" } 247 + - } 248 + - } 249 + - } 250 + - 2: (#struct){ |(*(struct){ 251 + - kind: (string){ "9_last" } 252 + - }, (#struct){ 253 + - kind!: (string){ string } 254 + - rules?: (list){ 255 + - } 256 + - }) } 257 + - } 258 + - #GroupListAgain: (#list){ 259 + - 0: (#struct){ |(*(#struct){ 260 + - kind: (string){ "9_last" } 261 + - }, (#struct){ 262 + - kind!: (string){ string } 263 + - rules?: (list){ 264 + - } 265 + - }) } 266 + - 1: (#struct){ 267 + - kind: (string){ "2_second" } 268 + - rules: (#list){ 269 + - 0: (#struct){ 270 + - expr: (string){ "a" } 271 + - } 272 + - 1: (#struct){ 273 + - expr: (string){ "b" } 274 + - } 275 + - } 276 + - } 277 + - 2: (#struct){ 278 + - kind: (string){ "1_first" } 279 + - rules: (#list){ 280 + - 0: (#struct){ 281 + - expr: (string){ "c" } 282 + - } 283 + - 1: (#struct){ 284 + - expr: (string){ "d" } 285 + - } 286 + - } 287 + - } 288 + - } 289 + - #GroupList: (#list){ 290 + - 0: (#struct){ |(*(#struct){ 291 + - kind: (string){ "9_last" } 292 + - }, (#struct){ 293 + - kind!: (string){ string } 294 + - rules?: (list){ 295 + - } 296 + - }) } 297 + - 1: (#struct){ 298 + - kind: (string){ "2_second" } 299 + - rules: (#list){ 300 + - 0: (#struct){ 301 + - expr: (string){ "a" } 302 + - } 303 + - 1: (#struct){ 304 + - expr: (string){ "b" } 305 + - } 306 + - } 307 + - } 308 + - 2: (#struct){ 309 + - kind: (string){ "1_first" } 310 + - rules: (#list){ 311 + - 0: (#struct){ 312 + - expr: (string){ "c" } 313 + - } 314 + - 1: (#struct){ 315 + - expr: (string){ "d" } 316 + - } 317 + - } 318 + - } 319 + - } 320 + - #Group: (#struct){ 321 + - kind!: (string){ string } 322 + - rules?: (list){ 323 + + spec: (#list){ 324 + + 0: (#struct){ 325 + + rules: (#list){ 326 + + 0: (#struct){ 327 + + expr: (string){ "x" } 328 + + } 329 + + } 330 + + } 331 + + } 332 + + kind: (string){ |(*(string){ "default" }, (string){ string }) } 333 + + } 334 + + 1: (#struct){ 335 + + spec: (#list){ 336 + + 0: (#struct){ 337 + + rules: (#list){ 338 + + 0: (#struct){ 339 + + expr: (string){ "y" } 340 + + } 341 + + } 342 + + } 343 + + } 344 + + kind: (string){ |(*(string){ "default" }, (string){ string }) } 345 + + } 346 + + } 347 + + #RuleGroup: (#struct){ 348 + + rules: (list){ 349 + } 350 + } 351 + #Rule: (#struct){ 352 + expr: (string){ string } 353 + } 354 + + #VMRule: (#struct){ 355 + + spec: (list){ 356 + + } 357 + + kind: (string){ |(*(string){ "default" }, (string){ string }) } 358 + + } 359 + + #TypeMeta: (#struct){ 360 + + kind: (string){ |(*(string){ "default" }, (string){ string }) } 361 + + } 362 + } 363 + -- out/eval -- 364 + (struct){ 365 + items: (#list){ 366 + 0: (#struct){ 367 + spec: (#list){ 368 + 0: (#struct){ 369 + rules: (#list){ 370 + 0: (#struct){ 371 + expr: (string){ "x" } 372 + } 373 + } 374 + } 375 + } 376 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 377 + } 378 + 1: (#struct){ 379 + spec: (#list){ 380 + 0: (#struct){ 381 + rules: (#list){ 382 + 0: (#struct){ 383 + expr: (string){ "y" } 384 + } 385 + } 386 + } 387 + } 388 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 389 + } 390 + } 391 + #List: (#struct){ 392 + items: (#list){ 393 + 0: (#struct){ 394 + spec: (#list){ 395 + 0: (#struct){ 396 + rules: (#list){ 397 + 0: (#struct){ 398 + expr: (string){ "x" } 399 + } 400 + } 401 + } 402 + } 403 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 404 + } 405 + 1: (#struct){ 406 + spec: (#list){ 407 + 0: (#struct){ 408 + rules: (#list){ 409 + 0: (#struct){ 410 + expr: (string){ "y" } 411 + } 412 + } 413 + } 414 + } 415 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 416 + } 417 + } 418 + } 419 + _items: (#list){ 420 + 0: (#list){ 421 + 0: (#struct){ 422 + spec: (#list){ 423 + 0: (#struct){ 424 + rules: (#list){ 425 + 0: (#struct){ 426 + expr: (string){ "x" } 427 + } 428 + } 429 + } 430 + } 431 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 432 + } 433 + 1: (#struct){ 434 + spec: (#list){ 435 + 0: (#struct){ 436 + rules: (#list){ 437 + 0: (#struct){ 438 + expr: (string){ "y" } 439 + } 440 + } 441 + } 442 + } 443 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 444 + } 445 + } 446 + } 447 + #VMRuleList: (#list){ 448 + 0: (#struct){ 449 + spec: (#list){ 450 + 0: (#struct){ 451 + rules: (#list){ 452 + 0: (#struct){ 453 + expr: (string){ "x" } 454 + } 455 + } 456 + } 457 + } 458 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 459 + } 460 + 1: (#struct){ 461 + spec: (#list){ 462 + 0: (#struct){ 463 + rules: (#list){ 464 + 0: (#struct){ 465 + expr: (string){ "y" } 466 + } 467 + } 468 + } 469 + } 470 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 471 + } 472 + } 473 + #RuleGroup: (#struct){ 474 + rules: (list){ 475 + } 476 + } 477 + #Rule: (#struct){ 478 + expr: (string){ string } 479 + } 480 + #VMRule: (#struct){ 481 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 482 + spec: (list){ 483 + } 484 + } 485 + #TypeMeta: (#struct){ 486 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 487 + } 488 + }