Module Name: src
Committed By: rillig
Date: Sat Oct 16 06:02:18 UTC 2021
Modified Files:
src/tests/usr.bin/indent: opt_bacc.c
Log Message:
tests/indent: restructure test for '-bacc' and '-nbacc'
To see the effects of the options, group the tests into sections, each
containing a small piece of code followed by the output of the two
options.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt_bacc.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_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.1 src/tests/usr.bin/indent/opt_bacc.c:1.2
--- src/tests/usr.bin/indent/opt_bacc.c:1.1 Sat Oct 16 03:20:13 2021
+++ src/tests/usr.bin/indent/opt_bacc.c Sat Oct 16 06:02:18 2021
@@ -1,94 +1,80 @@
-/* $NetBSD: opt_bacc.c,v 1.1 2021/10/16 03:20:13 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.2 2021/10/16 06:02:18 rillig Exp $ */
/* $FreeBSD$ */
-#indent input
/*
- * Test the option -bacc, which forces a blank line around every conditional
- * compilation block. For example, in front of every #ifdef and after every
- * #endif. Other blank lines surrounding such blocks are swallowed.
+ * Test the options '-bacc' and '-nbacc'.
*
- * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
- * process_decl resets prefix_blankline_requested unconditionally.
+ * The option '-bacc' forces a blank line around every conditional compilation
+ * block. For example, in front of every #ifdef and after every #endif.
+ * Other blank lines surrounding such blocks are swallowed.
+ *
+ * The option '-nbacc' TODO.
*/
+
+/* Example code without surrounding blank lines. */
+#indent input
int a;
-#if 0 /* FIXME: need blank line above */
+#if 0
int b;
-#endif /* FIXME: need blank line below */
-int c;
-
-
-int space_a;
-
-#if 0 /* FIXME: need blank line above */
-
-int space_b; /* FIXME: need no blank line above */
-
#endif
-
-int space_c;
-
-const char *
-os_name(void)
-{
-#if defined(__NetBSD__) || defined(__FreeBSD__)
- return "BSD";
-#else
- return "unknown";
-#endif
-}
+int c;
#indent end
-#indent run -bacc
/*
- * Test the option -bacc, which forces a blank line around every conditional
- * compilation block. For example, in front of every #ifdef and after every
- * #endif. Other blank lines surrounding such blocks are swallowed.
- *
* XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
* process_decl resets prefix_blankline_requested unconditionally.
*/
+#indent run -bacc
+int a;
+/* $ FIXME: expecting a blank line here */
+#if 0
+int b;
+#endif
+/* $ FIXME: expecting a blank line here */
+int c;
+#indent end
+/*
+ * With '-nbacc' the code is unchanged since there are no blank lines to
+ * remove.
+ */
+#indent run -nbacc
int a;
-#if 0 /* FIXME: need blank line above */
+#if 0
int b;
-#endif /* FIXME: need blank line below */
+#endif
int c;
+#indent end
+/* Example code containing blank lines. */
+#indent input
int space_a;
-#if 0 /* FIXME: need blank line above */
-
-int space_b; /* FIXME: need no blank line above */
-#endif
-int space_c;
-
-/* $ XXX: The '*' should not be set apart from the rest of the return type. */
-const char *
-os_name(void)
-{
-#if defined(__NetBSD__) || defined(__FreeBSD__)
+#if 0
-/* $ FIXME: This empty line _below_ the '#if' contradicts the manual page. */
- return "BSD";
-#else
+int space_b;
-/* $ FIXME: This empty line _below_ the '#else' contradicts the manual page. */
- return "unknown";
#endif
-/* $ FIXME: There should be an empty line after the '#endif'. */
-}
+
+int space_c;
#indent end
-#indent input
-int a;
+#indent run -bacc
+int space_a;
+/* $ FIXME: expecting a blank line here */
#if 0
-int b;
+
+/* $ FIXME: expecting NO blank line here */
+int space_b;
#endif
-int c;
+int space_c;
+#indent end
+/* The option '-nbacc' does not remove anything. */
+#indent run -nbacc
int space_a;
#if 0
@@ -98,7 +84,12 @@ int space_b;
#endif
int space_c;
+#indent end
+/*
+ * Preprocessing directives can also occur in function bodies.
+ */
+#indent input
const char *
os_name(void)
{
@@ -110,24 +101,26 @@ os_name(void)
}
#indent end
-#indent run -nbacc
-int a;
-#if 0
-int b;
-#endif
-int c;
-
-
-int space_a;
-
-#if 0
+#indent run -bacc
+/* $ XXX: The '*' should not be set apart from the rest of the return type. */
+const char *
+os_name(void)
+{
+/* $ FIXME: expecting a blank line here. */
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+/* $ FIXME: expecting NO blank line here. */
-int space_b;
+ return "BSD";
+#else
+/* $ FIXME: expecting NO blank line here. */
+ return "unknown";
#endif
+/* $ FIXME: expecting a blank line here. */
+}
+#indent end
-int space_c;
-
+#indent run -nbacc
const char *
os_name(void)
{