From 4519030f5bb12d4e2895868be76521ec56f4f6a0 Mon Sep 17 00:00:00 2001 From: flan6 Date: Fri, 23 Aug 2024 19:27:01 -0300 Subject: [PATCH] add test data for multi statements block formatter ensures that format removes empty lines at the top of a block unconditionally and bottom unless it is followed by an else-if statement. see issue #284 --- testdata/script/block-multi.txtar | 195 ++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 testdata/script/block-multi.txtar diff --git a/testdata/script/block-multi.txtar b/testdata/script/block-multi.txtar new file mode 100644 index 0000000..b276c44 --- /dev/null +++ b/testdata/script/block-multi.txtar @@ -0,0 +1,195 @@ +exec gofumpt -w foo.go +cmp foo.go foo.go.golden + +exec gofumpt -d foo.go.golden +! stdout . + +-- foo.go -- +package p + +func f() { + if true { + + println() + println() + + println() + } + + for true { + println() + println() + + println() + + } + + { + + + println(1, 2, + 3, 4, `foo + bar`) + + println(1, 2, + 3, 4, `foo + bar`) + + + + } + + { + + // comment directly before + println() + println() + + println() + + // comment after + + } + + { + + // comment before + + println() + println() + + println() + // comment directly after + + } + + // For readability; the empty line helps separate the multi-line + // condition from the body. + if true && + true { + + println() + println() + + println() + } + if true && + true { + println() + println() + + println() + + } else if true { + println() + println() + + println() + } + for true && + true { + + println() + println() + + println() + } + if true && + true { + + // documented multi statement + println() + println() + + println() + } +} +-- foo.go.golden -- +package p + +func f() { + if true { + println() + println() + + println() + } + + for true { + println() + println() + + println() + } + + { + println(1, 2, + 3, 4, `foo + bar`) + + println(1, 2, + 3, 4, `foo + bar`) + } + + { + // comment directly before + println() + println() + + println() + + // comment after + } + + { + // comment before + + println() + println() + + println() + // comment directly after + } + + // For readability; the empty line helps separate the multi-line + // condition from the body. + if true && + true { + + println() + println() + + println() + } + if true && + true { + println() + println() + + println() + + } else if true { + println() + println() + + println() + } + for true && + true { + + println() + println() + + println() + } + if true && + true { + + // documented multi statement + println() + println() + + println() + } +}