Skip to content

Commit da852fe

Browse files
mvdancueckoo
authored andcommitted
cue/format: add test case for formatting empty and near-empty files
They all behave as expected, but as I investigated the report at https://cuelang.org/issue/3895 I noticed we lacked some test cases. Note that the empty.input file has zero bytes, and empty.golden has one, which is just a newline. Formatting empty CUE source files as one newline seems reasonable given that we always end CUE source with one newline. Modern text editors seem to do the same with empty files. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I58caeb2f2709a84adfd0f2aa223a8068e5de72bb Dispatch-Trailer: {"type":"trybot","CL":1214303,"patchset":1,"ref":"refs/changes/03/1214303/1","targetBranch":"master"}
1 parent 4b194d7 commit da852fe

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cue/format/testdata/comments.txtar

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
simplify
22

3+
-- empty.input --
4+
-- empty.golden --
5+
36
-- comments.input --
47
// Package line 1 group 1
58
// Package line 2 group 1

cue/format/testdata/imports.txtar

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
sort-imports
22

3+
-- pkgonly.input --
4+
package foo
5+
-- pkgonly.golden --
6+
package foo
7+
-- attronly.input --
8+
@attr(foo)
9+
-- attronly.golden --
10+
@attr(foo)
11+
-- importonly.input --
12+
import "foo"
13+
-- importonly.golden --
14+
import "foo"
315
-- imports.input --
416
package foo
517

0 commit comments

Comments
 (0)