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/lint: document and extend the tes...



details:   https://anonhg.NetBSD.org/src/rev/e4edecd3af2d
branches:  trunk
changeset: 989535:e4edecd3af2d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 16 21:32:10 2021 +0000

description:
tests/lint: document and extend the tests for options

diffstat:

 tests/usr.bin/indent/opt_bap.c |   47 ++++++-----------
 tests/usr.bin/indent/opt_bbb.c |   10 +++-
 tests/usr.bin/indent/opt_bc.c  |   10 +++-
 tests/usr.bin/indent/opt_bs.c  |   11 +++-
 tests/usr.bin/indent/opt_cdb.c |   88 ++++++++++++++++++++++-----------
 tests/usr.bin/indent/opt_ce.c  |   11 +++-
 tests/usr.bin/indent/opt_cs.c  |   10 +++-
 tests/usr.bin/indent/opt_dj.c  |   49 +++++++++++++-----
 tests/usr.bin/indent/opt_eei.c |   51 +++++++++++++++++++-
 tests/usr.bin/indent/opt_ei.c  |   12 ++++-
 tests/usr.bin/indent/opt_fbs.c |   14 ++++-
 tests/usr.bin/indent/opt_fc1.c |  107 ++++++++++++++++++++++++++--------------
 tests/usr.bin/indent/opt_fcb.c |   72 ++++++++++++++++-----------
 tests/usr.bin/indent/opt_ip.c  |   16 +++--
 tests/usr.bin/indent/opt_lp.c  |   14 ++++-
 tests/usr.bin/indent/opt_lpl.c |   19 ++++++-
 tests/usr.bin/indent/opt_pcs.c |   16 ++++-
 tests/usr.bin/indent/opt_psl.c |   56 +++++++++++++++++++-
 tests/usr.bin/indent/opt_sc.c  |   63 ++++++++++++++++-------
 tests/usr.bin/indent/opt_sob.c |   19 ++++++-
 tests/usr.bin/indent/opt_ut.c  |   35 ++++++++----
 tests/usr.bin/indent/opt_v.c   |   13 ++++-
 22 files changed, 540 insertions(+), 203 deletions(-)

diffs (truncated from 1181 to 300 lines):

diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_bap.c
--- a/tests/usr.bin/indent/opt_bap.c    Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_bap.c    Sat Oct 16 21:32:10 2021 +0000
@@ -1,13 +1,21 @@
-/* $NetBSD: opt_bap.c,v 1.1 2021/10/16 03:20:13 rillig Exp $ */
+/* $NetBSD: opt_bap.c,v 1.2 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-bap' and '-nbap'.
+ *
+ * The option '-bap' forces a blank line after every function body.
+ *
+ * The option '-nbap' keeps everything as is.
+ */
+
 #indent input
-static void one_liner(void) { /* FIXME: needs empty line below */ }
-static void several_lines(void) {
+static void one_liner(void){}
+static void several_lines(void)
+{
        action();
-       /* FIXME: needs empty line below */
 }
-int main(void){/* FIXME: needs empty line below */}
+int main(void){}
 int global_variable;
 
 void already_has_blank_line_below(void)
@@ -26,18 +34,20 @@
 #indent run -bap
 static void
 one_liner(void)
-{                              /* FIXME: needs empty line below */
+{
 }
+/* $ FIXME: needs a blank line here */
 static void
 several_lines(void)
 {
        action();
-       /* FIXME: needs empty line below */
 }
+/* $ FIXME: needs a blank line here */
 int
 main(void)
-{                              /* FIXME: needs empty line below */
+{
 }
+/* $ FIXME: needs a blank line here */
 int            global_variable;
 
 void
@@ -55,27 +65,6 @@
 int            the_end;
 #indent end
 
-#indent input
-static void one_liner(void) {}
-static void several_lines(void) {
-       action();
-}
-int main(void){}
-int global_variable;
-
-void already_has_blank_line_below(void)
-{
-}
-
-void has_several_blank_lines_below(void)
-{
-}
-
-
-
-int            the_end;
-#indent end
-
 #indent run -nbap
 static void
 one_liner(void)
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_bbb.c
--- a/tests/usr.bin/indent/opt_bbb.c    Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_bbb.c    Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,14 @@
-/* $NetBSD: opt_bbb.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_bbb.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-bbb' and '-nbbb'.
+ *
+ * The option '-bbb' forces a blank line before every block comment.
+ *
+ * The option '-nbbb' keeps everything as is.
+ */
+
 #indent input
 /*
  * This is a block comment.
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_bc.c
--- a/tests/usr.bin/indent/opt_bc.c     Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_bc.c     Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,14 @@
-/* $NetBSD: opt_bc.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_bc.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-bc' and '-nbc'.
+ *
+ * The option '-bc' forces a newline after each comma in a declaration.
+ *
+ * The option '-nbc' keeps everything as is.
+ */
+
 #indent input
 int a,b,c;
 void function_declaration(int a,int b,int c);
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_bs.c
--- a/tests/usr.bin/indent/opt_bs.c     Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_bs.c     Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,15 @@
-/* $NetBSD: opt_bs.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_bs.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-bs' and '-nbs'.
+ *
+ * The option '-bs' forces a space after the keyword 'sizeof'.
+ *
+ * The option '-nbs' removes all whitespace after the keyword 'sizeof', unless
+ * the next token is a word as well.
+ */
+
 #indent input
 void
 example(int i)
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_cdb.c
--- a/tests/usr.bin/indent/opt_cdb.c    Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_cdb.c    Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,17 @@
-/* $NetBSD: opt_cdb.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_cdb.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-cdb' and '-ncdb'.
+ *
+ * The option '-cdb' forces the comment delimiter '/' '*' and '*' '/' to be on
+ * a separate line. This only affects block comments, not comments to the
+ * right of the code.
+ *
+ * The option '-ncdb' compresses multi-line comments to single-line comments,
+ * as far as possible.
+ */
+
 #indent input
 /* A single-line comment. */
 
@@ -13,7 +24,33 @@
  * multi-line
  * comment.
  */
+#indent end
 
+#indent run -cdb
+/* A single-line comment. */
+
+/*
+ * A multi-line comment.
+ */
+
+/*
+ * A multi-line comment.
+ */
+#indent end
+
+#indent run -ncdb
+/* A single-line comment. */
+
+/* A multi-line comment. */
+
+/* A multi-line comment. */
+#indent end
+
+
+/*
+ * Code comments on global declarations.
+ */
+#indent input
 int            ga;             /* A single-line comment. */
 
 int            gb;             /* A
@@ -25,7 +62,28 @@
                                 * multi-line
                                 * comment.
                                 */
+#indent end
 
+#indent run -cdb
+int            ga;             /* A single-line comment. */
+
+int            gb;             /* A multi-line comment. */
+
+int            gc;             /* A multi-line comment. */
+#indent end
+
+#indent run -ncdb
+int            ga;             /* A single-line comment. */
+
+int            gb;             /* A multi-line comment. */
+
+int            gc;             /* A multi-line comment. */
+#indent end
+
+/*
+ * Block comments that are inside a function.
+ */
+#indent input
 void
 example(void)
 {
@@ -47,22 +105,6 @@
 #indent end
 
 #indent run -cdb
-/* A single-line comment. */
-
-/*
- * A multi-line comment.
- */
-
-/*
- * A multi-line comment.
- */
-
-int            ga;             /* A single-line comment. */
-
-int            gb;             /* A multi-line comment. */
-
-int            gc;             /* A multi-line comment. */
-
 void
 example(void)
 {
@@ -82,18 +124,6 @@
 #indent end
 
 #indent run -ncdb
-/* A single-line comment. */
-
-/* A multi-line comment. */
-
-/* A multi-line comment. */
-
-int            ga;             /* A single-line comment. */
-
-int            gb;             /* A multi-line comment. */
-
-int            gc;             /* A multi-line comment. */
-
 void
 example(void)
 {
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_ce.c
--- a/tests/usr.bin/indent/opt_ce.c     Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_ce.c     Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,15 @@
-/* $NetBSD: opt_ce.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_ce.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-ce' and '-nce'.
+ *
+ * The option '-ce' places the 'else if' in a single line, as if it were only
+ * a single keyword.
+ *
+ * The option '-nce' places the 'else' on the next line.
+ */
+
 #indent input
 void
 example(int n)
diff -r a3993c942806 -r e4edecd3af2d tests/usr.bin/indent/opt_cs.c
--- a/tests/usr.bin/indent/opt_cs.c     Sat Oct 16 14:05:48 2021 +0000
+++ b/tests/usr.bin/indent/opt_cs.c     Sat Oct 16 21:32:10 2021 +0000
@@ -1,6 +1,14 @@
-/* $NetBSD: opt_cs.c,v 1.2 2021/10/16 05:40:17 rillig Exp $ */
+/* $NetBSD: opt_cs.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for the options '-cs' and '-ncs'.
+ *
+ * The option '-cs' forces a space after the parentheses of a cast.
+ *



Home | Main Index | Thread Index | Old Index