this repo has no description
0
fork

Configure Feed

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

cue/format: add test cases for issue 2496

Both supplied by Tony Worm; the first indents too much,
and the second inserts a newline where there was none.

While here, I noticed this indenting bug appears with parentheses
and selectors as well, and I also noticed that we sometimes indent
top-level comments, which seems like a bug as well.

For #2496.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I978f8acf5469e255d026f737c9b39d7098fd30b3
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196132
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Aram Hăvărneanu <aram@cue.works>

+71
+24
cue/format/testdata/comments.txtar
··· 329 329 330 330 // an ellipsis 331 331 } 332 + -- comment_alone.input -- 333 + // Just one comment on its own. 334 + -- comment_alone.golden -- 335 + // Just one comment on its own. 336 + -- comment_field.input -- 337 + // Just one comment on a field. TODO(mvdan): do not indent. 338 + foo: string 339 + -- comment_field.golden -- 340 + // Just one comment on a field. TODO(mvdan): do not indent. 341 + foo: string 342 + -- comments_alone.input -- 343 + // Just a few comments 344 + // on their own. 345 + -- comments_alone.golden -- 346 + // Just a few comments 347 + // on their own. 348 + -- comments_field.input -- 349 + // Just a few comments 350 + // on a field. 351 + foo: string 352 + -- comments_field.golden -- 353 + // Just a few comments 354 + // on a field. 355 + foo: string
+47
cue/format/testdata/expressions.txtar
··· 565 565 s: [string]: [string]: a 566 566 s: [string]: {s: string} 567 567 } 568 + -- issue2496.input -- 569 + // TODO(mvdan): we indent the list elements too much. 570 + machine_type: [ 571 + if arch == "amd" {"n2-standard-2"}, 572 + if arch == "arm" {"t2a-standard-2"}, 573 + "unknown arch", 574 + ][0] 575 + 576 + long_field_name: ([ 577 + "foo" 578 + ]) 579 + 580 + long_field_name: [ 581 + "foo" 582 + ].bar 583 + 584 + // TODO(mvdan): we insert an empty line between the definitions. 585 + _foo: { 586 + #tool: string 587 + #arch: string 588 + 589 + // skip_create_image: true 590 + } 591 + -- issue2496.golden -- 592 + // TODO(mvdan): we indent the list elements too much. 593 + machine_type: [ 594 + if arch == "amd" {"n2-standard-2"}, 595 + if arch == "arm" {"t2a-standard-2"}, 596 + "unknown arch", 597 + ][0] 598 + 599 + long_field_name: ([ 600 + "foo", 601 + ]) 602 + 603 + long_field_name: [ 604 + "foo", 605 + ].bar 606 + 607 + // TODO(mvdan): we insert an empty line between the definitions. 608 + _foo: { 609 + #tool: string 610 + 611 + #arch: string 612 + 613 + // skip_create_image: true 614 + }