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: test the -badp option



details:   https://anonhg.NetBSD.org/src/rev/e23e6ec1c455
branches:  trunk
changeset: 376643:e23e6ec1c455
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jun 27 04:28:16 2023 +0000

description:
tests/indent: test the -badp option

diffstat:

 tests/usr.bin/indent/opt_badp.c |  78 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 1 deletions(-)

diffs (89 lines):

diff -r 5c51600d21b4 -r e23e6ec1c455 tests/usr.bin/indent/opt_badp.c
--- a/tests/usr.bin/indent/opt_badp.c   Tue Jun 27 01:19:44 2023 +0000
+++ b/tests/usr.bin/indent/opt_badp.c   Tue Jun 27 04:28:16 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_badp.c,v 1.14 2023/06/26 20:03:09 rillig Exp $ */
+/* $NetBSD: opt_badp.c,v 1.15 2023/06/27 04:28:16 rillig Exp $ */
 
 /*
  * Tests for the options '-badp' and '-nbadp'.
@@ -210,3 +210,79 @@ f(void) {
        stmt;
 }
 //indent end
+
+
+/* The '}' of an initializer does not end a block. */
+//indent input
+void
+f(void)
+{
+       int decl1[2][2] = {
+               {1, 2},
+               {3, 4},
+       };
+       int decl2 = 5;
+       stmt;
+}
+//indent end
+
+//indent run -di0
+void
+f(void)
+{
+       int decl1[2][2] = {
+               {1, 2},
+               {3, 4},
+       };
+       int decl2 = 5;
+// $ FIXME: Add blank line here.
+       stmt;
+}
+//indent end
+
+
+/*
+ * Due to its limited lookahead, indent cannot know whether the comment is
+ * followed by a declaration or a statement.
+ */
+//indent input
+void f(void) {
+       int             decl1;
+       /* comment */
+       int             decl2;
+       stmt;
+}
+//indent end
+
+//indent run -badp
+void
+f(void)
+{
+       int             decl1;
+// $ FIXME: No blank line here.
+
+       /* comment */
+       int             decl2;
+// $ FIXME: Add blank line here.
+       stmt;
+}
+//indent end
+
+
+/* Combining -bad and -badp only adds a single blank line. */
+//indent input
+void f(void) { int decl; stmt1; stmt2; }
+//indent end
+
+//indent run -bad -badp
+void
+f(void)
+{
+       int             decl;
+
+       stmt1;
+// $ FIXME: Remove this blank line.
+
+       stmt2;
+}
+//indent end



Home | Main Index | Thread Index | Old Index