Module Name: src
Committed By: rillig
Date: Mon Jun 26 11:01:08 UTC 2023
Modified Files:
src/tests/usr.bin/indent: opt_badp.c
Log Message:
tests/indent: extend test for -badp option
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_badp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/opt_badp.c
diff -u src/tests/usr.bin/indent/opt_badp.c:1.12 src/tests/usr.bin/indent/opt_badp.c:1.13
--- src/tests/usr.bin/indent/opt_badp.c:1.12 Sun Jun 4 19:28:54 2023
+++ src/tests/usr.bin/indent/opt_badp.c Mon Jun 26 11:01:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_badp.c,v 1.12 2023/06/04 19:28:54 rillig Exp $ */
+/* $NetBSD: opt_badp.c,v 1.13 2023/06/26 11:01:08 rillig Exp $ */
/*
* Tests for the options '-badp' and '-nbadp'.
@@ -8,6 +8,8 @@
* even if there are no declarations.
*/
+
+/* An empty function body does not need a blank line. */
//indent input
void
empty(void)
@@ -20,6 +22,7 @@ empty(void)
//indent run-equals-input -nbadp
+/* If an empty function body already has a blank line, it is kept. */
//indent input
void
blank(void)
@@ -33,6 +36,10 @@ blank(void)
//indent run-equals-input -nbadp
+/*
+ * If a function body has only declarations (doesn't occur in practice), it
+ * does not need an empty line.
+ */
//indent input
void
declaration(void)
@@ -46,6 +53,10 @@ declaration(void)
//indent run-equals-input -nbadp
+/*
+ * A function body without declarations gets an empty line above the first
+ * statement.
+ */
//indent input
void
statement(void)
@@ -60,6 +71,10 @@ statement(void)
//indent run-equals-input -nbadp
+/*
+ * A function body with a declaration and a statement gets a blank line between
+ * those.
+ */
//indent input
void
declaration_statement(void)
@@ -82,6 +97,7 @@ declaration_statement(void)
//indent run-equals-input -nbadp
+/* If there already is a blank line in the right place, it is kept. */
//indent input
static void
declaration_blank_statement(void)
@@ -97,6 +113,7 @@ declaration_blank_statement(void)
//indent run-equals-input -nbadp
+/* Additional blank lines are kept. To remove them, see the '-sob' option. */
//indent input
static void
declaration_blank_blank_statement(void)
@@ -115,6 +132,26 @@ declaration_blank_blank_statement(void)
/*
+ * The blank line is only inserted at the top of a function body, not in nested
+ * block statements.
+ */
+//indent input
+static void
+nested(void)
+{
+ {
+ int decl;
+ stmt();
+ }
+}
+//indent end
+
+//indent run-equals-input -badp
+
+//indent run-equals-input -nbadp
+
+
+/*
* A struct declaration or an initializer are not function bodies, so don't
* add a blank line after them.
*/