Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/indent tests/indent: restructure test for '-ba...
details: https://anonhg.NetBSD.org/src/rev/cd6207abb1cf
branches: trunk
changeset: 1024279:cd6207abb1cf
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 16 06:02:18 2021 +0000
description:
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.
diffstat:
tests/usr.bin/indent/opt_bacc.c | 159 +++++++++++++++++++--------------------
1 files changed, 76 insertions(+), 83 deletions(-)
diffs (208 lines):
diff -r fc52bd90168c -r cd6207abb1cf tests/usr.bin/indent/opt_bacc.c
--- a/tests/usr.bin/indent/opt_bacc.c Sat Oct 16 05:40:46 2021 +0000
+++ b/tests/usr.bin/indent/opt_bacc.c Sat Oct 16 06:02:18 2021 +0000
@@ -1,33 +1,95 @@
-/* $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'.
+ *
+ * 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
+int b;
+#endif
+int c;
+#indent end
+
+/*
* 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;
-#if 0 /* FIXME: need blank line above */
+/* $ FIXME: expecting a blank line here */
+#if 0
int b;
-#endif /* FIXME: need blank line below */
+#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
+int b;
+#endif
+int c;
+#indent end
+/* Example code containing blank lines. */
+#indent input
int space_a;
-#if 0 /* FIXME: need blank line above */
+#if 0
-int space_b; /* FIXME: need no blank line above */
+int space_b;
#endif
int space_c;
+#indent end
+#indent run -bacc
+int space_a;
+/* $ FIXME: expecting a blank line here */
+#if 0
+
+/* $ FIXME: expecting NO blank line here */
+int space_b;
+#endif
+
+int space_c;
+#indent end
+
+/* The option '-nbacc' does not remove anything. */
+#indent run -nbacc
+int space_a;
+
+#if 0
+
+int space_b;
+
+#endif
+
+int space_c;
+#indent end
+
+/*
+ * Preprocessing directives can also occur in function bodies.
+ */
+#indent input
const char *
os_name(void)
{
@@ -40,94 +102,25 @@
#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.
- */
-
-int a;
-#if 0 /* FIXME: need blank line above */
-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;
-
/* $ 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. */
-/* $ FIXME: This empty line _below_ the '#if' contradicts the manual page. */
return "BSD";
#else
+/* $ FIXME: expecting NO blank line here. */
-/* $ FIXME: This empty line _below_ the '#else' contradicts the manual page. */
return "unknown";
#endif
-/* $ FIXME: There should be an empty line after the '#endif'. */
-}
-#indent end
-
-#indent input
-int a;
-#if 0
-int b;
-#endif
-int c;
-
-
-int space_a;
-
-#if 0
-
-int space_b;
-
-#endif
-
-int space_c;
-
-const char *
-os_name(void)
-{
-#if defined(__NetBSD__) || defined(__FreeBSD__)
- return "BSD";
-#else
- return "unknown";
-#endif
+/* $ FIXME: expecting a blank line here. */
}
#indent end
#indent run -nbacc
-int a;
-#if 0
-int b;
-#endif
-int c;
-
-
-int space_a;
-
-#if 0
-
-int space_b;
-
-#endif
-
-int space_c;
-
const char *
os_name(void)
{
Home |
Main Index |
Thread Index |
Old Index