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: clean up tests for '-bad'...



details:   https://anonhg.NetBSD.org/src/rev/ce5fc6460d4a
branches:  trunk
changeset: 989530:ce5fc6460d4a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 16 09:39:21 2021 +0000

description:
tests/indent: clean up tests for '-bad' and '-badp'

diffstat:

 tests/usr.bin/indent/opt_bad.c  |  71 +++++++++++++++++++++-------------------
 tests/usr.bin/indent/opt_badp.c |  47 ++++++--------------------
 2 files changed, 48 insertions(+), 70 deletions(-)

diffs (183 lines):

diff -r 7264aea236e0 -r ce5fc6460d4a tests/usr.bin/indent/opt_bad.c
--- a/tests/usr.bin/indent/opt_bad.c    Sat Oct 16 09:17:21 2021 +0000
+++ b/tests/usr.bin/indent/opt_bad.c    Sat Oct 16 09:39:21 2021 +0000
@@ -1,34 +1,52 @@
-/* $NetBSD: opt_bad.c,v 1.1 2021/10/16 03:20:13 rillig Exp $ */
+/* $NetBSD: opt_bad.c,v 1.2 2021/10/16 09:39:21 rillig Exp $ */
 /* $FreeBSD$ */
 
-#indent input
 /*
- * The option -bad only affects declarations of local variables.  It does not
- * affect file-scoped declarations or definitions.
+ * Tests for the options '-bad' and '-nbad'.
+ *
+ * The option '-bad' forces a blank line after every block of declarations.
+ * It only affects declarations of local variables.  It does not affect
+ * file-scoped declarations or definitions.
+ *
+ * The option '-nbad' leaves everything as is.
  */
 
+/* Test global declarations. */
+#indent input
 int global_variable;
 void function_declaration(void);
 #if 0
 #endif
+/* comment */
+#indent end
+
+#indent run -bad
+int            global_variable;
+void           function_declaration(void);
+#if 0
+#endif
+/* comment */
+#indent end
+
+#indent run -nbad
+int            global_variable;
+void           function_declaration(void);
+#if 0
+#endif
+/* comment */
+#indent end
+
+/* Test local declarations. */
+#indent input
 void function_definition(void) {
-       int local_variable;
-       function_call();
-       int local_variable_after_statement;
-       function_call();
+    int local_variable;
+    function_call();
+    int local_variable_after_statement;
+    function_call();
 }
 #indent end
 
 #indent run -bad
-/*
- * The option -bad only affects declarations of local variables.  It does not
- * affect file-scoped declarations or definitions.
- */
-
-int            global_variable;
-void           function_declaration(void);
-#if 0
-#endif
 void
 function_definition(void)
 {
@@ -41,30 +59,15 @@
 }
 #indent end
 
-#indent input
-int global_variable;
-void function_declaration(void);
-#if 0
-#endif
-void function_definition(void) {
-       int local_variable;
-       function_call();
-       int local_variable_after_statement;
-       function_call();
-}
-#indent end
-
 #indent run -nbad
-int            global_variable;
-void           function_declaration(void);
-#if 0
-#endif
 void
 function_definition(void)
 {
        int             local_variable;
+       /* $ No blank line here. */
        function_call();
        int             local_variable_after_statement;
+       /* $ No blank line here. */
        function_call();
 }
 #indent end
diff -r 7264aea236e0 -r ce5fc6460d4a tests/usr.bin/indent/opt_badp.c
--- a/tests/usr.bin/indent/opt_badp.c   Sat Oct 16 09:17:21 2021 +0000
+++ b/tests/usr.bin/indent/opt_badp.c   Sat Oct 16 09:39:21 2021 +0000
@@ -1,6 +1,13 @@
-/* $NetBSD: opt_badp.c,v 1.1 2021/10/16 03:20:13 rillig Exp $ */
+/* $NetBSD: opt_badp.c,v 1.2 2021/10/16 09:39:21 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-badp' and '-nbadp'.
+ *
+ * The option '-badp' forces a blank line after the first set of declarations
+ * in a function. It produces a blank line even if there are no declarations.
+ */
+
 #indent input
 static void
 no_declarations(void)
@@ -12,7 +19,7 @@
 declarations_without_blank_line(void)
 {
        int local_variable;
-       action();               /* FIXME: need empty line above */
+       action();
 }
 
 static void
@@ -46,7 +53,8 @@
 declarations_without_blank_line(void)
 {
        int             local_variable;
-       action();               /* FIXME: need empty line above */
+       /* $ FIXME: need empty line here */
+       action();
 }
 
 static void
@@ -68,39 +76,6 @@
 }
 #indent end
 
-#indent input
-static void
-no_declarations(void)
-{
-       action();
-}
-
-static void
-declarations_without_blank_line(void)
-{
-       int local_variable;
-       action();
-}
-
-static void
-declaration_with_blank_line(void)
-{
-       int local_variable;
-
-       action();
-}
-
-static void
-declaration_with_several_blank_lines(void)
-{
-       int local_variable;
-
-
-
-       action();
-}
-#indent end
-
 #indent run -nbadp
 static void
 no_declarations(void)



Home | Main Index | Thread Index | Old Index