From a74d05b939d35a10b2b3621caed9e0a38dbb71e5 Mon Sep 17 00:00:00 2001 From: William Escande Date: Tue, 16 May 2023 18:46:33 -0700 Subject: [PATCH] bpfmt: Test comment line while sorting arrays Test: bpfmt test Change-Id: I4a11ac200a7b10d3abb76db78f4be2ef772763cf --- parser/printer_test.go | 110 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/parser/printer_test.go b/parser/printer_test.go index c889b2a..b708441 100644 --- a/parser/printer_test.go +++ b/parser/printer_test.go @@ -447,6 +447,116 @@ stuff { }, ], } +`, + }, + { + input: ` +// test +foo { + stuff: [ + "a", // great comment + "b", + ], +} +`, + output: ` +// test +foo { + stuff: [ + "a", // great comment + "b", + ], +} +`, + }, + { + input: ` +// test +foo { + stuff: [ + "a", + // b comment + "b", + ], +} +`, + output: ` +// test +foo { + stuff: [ + "a", + // b comment + "b", + ], +} +`, + }, + { + input: ` +// test +foo { + stuff: [ + "a", // a comment + // b comment + "b", + ], +} +`, + output: ` +// test +foo { + stuff: [ + "a", // a comment + // b comment + "b", + ], +} +`, + }, + { + input: ` +// test +foo { + stuff: [ + "a", + // b comment + // on multiline + "b", + ], +} +`, + output: ` +// test +foo { + stuff: [ + "a", + // b comment + // on multiline + "b", + ], +} +`, + }, + { // Line comment are treat as groups separator + input: ` +// test +foo { + stuff: [ + "b", + // a comment + "a", + ], +} +`, + output: ` +// test +foo { + stuff: [ + "b", + // a comment + "a", + ], +} `, }, }