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: add 11 test cases, demons...



details:   https://anonhg.NetBSD.org/src/rev/054765aacbb7
branches:  trunk
changeset: 953338:054765aacbb7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 06 19:30:44 2021 +0000

description:
tests/indent: add 11 test cases, demonstrate 8 bugs

diffstat:

 tests/usr.bin/indent/opt--version.0    |   6 ++++--
 tests/usr.bin/indent/opt-bacc.0        |  19 +++++++++++++++++--
 tests/usr.bin/indent/opt-bacc.0.stdout |  17 +++++++++++++++--
 tests/usr.bin/indent/opt-bad.0         |  18 ++++++++++++++++--
 tests/usr.bin/indent/opt-bad.0.stdout  |  22 ++++++++++++++++++++--
 tests/usr.bin/indent/opt-badp.0        |  33 +++++++++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-badp.0.stdout |  34 ++++++++++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-bap.0         |  22 ++++++++++++++++++++--
 tests/usr.bin/indent/opt-bap.0.stdout  |  32 ++++++++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-bbb.0         |  26 ++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-bbb.0.stdout  |  30 ++++++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-bc.0          |   5 +++--
 tests/usr.bin/indent/opt-bc.0.stdout   |   7 +++++--
 tests/usr.bin/indent/opt-bl.0          |  15 +++++++++++++--
 tests/usr.bin/indent/opt-bl.0.stdout   |  23 +++++++++++++++++++++--
 tests/usr.bin/indent/opt-br.0          |  11 +++++++++--
 tests/usr.bin/indent/opt-br.0.stdout   |  16 ++++++++++++++--
 tests/usr.bin/indent/opt-bs.0          |  17 +++++++++++++++--
 tests/usr.bin/indent/opt-bs.0.stdout   |  17 +++++++++++++++--
 tests/usr.bin/indent/opt-c.0           |  12 ++++++++++--
 tests/usr.bin/indent/opt-c.0.stdout    |  12 ++++++++++--
 21 files changed, 352 insertions(+), 42 deletions(-)

diffs (truncated from 520 to 300 lines):

diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt--version.0
--- a/tests/usr.bin/indent/opt--version.0       Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt--version.0       Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,6 @@
-/* $NetBSD: opt--version.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt--version.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+When the option '--version' is given, any other options are ignored.
+Therefore the source file, if given, can contain arbitrary text that
+even might generate syntax errors when given to a C compiler.
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bacc.0
--- a/tests/usr.bin/indent/opt-bacc.0   Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bacc.0   Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,19 @@
-/* $NetBSD: opt-bacc.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bacc.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+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;
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bacc.0.stdout
--- a/tests/usr.bin/indent/opt-bacc.0.stdout    Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bacc.0.stdout    Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,17 @@
-/* $NetBSD: opt-bacc.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bacc.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+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;
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bad.0
--- a/tests/usr.bin/indent/opt-bad.0    Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bad.0    Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,18 @@
-/* $NetBSD: opt-bad.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bad.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * 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) {
+       int local_variable;
+       function_call();
+       int local_variable_after_statement;
+       function_call();
+}
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bad.0.stdout
--- a/tests/usr.bin/indent/opt-bad.0.stdout     Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bad.0.stdout     Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,22 @@
-/* $NetBSD: opt-bad.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bad.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * 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)
+{
+       int             local_variable;
+
+       function_call();
+       int             local_variable_after_statement;
+
+       function_call();
+}
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-badp.0
--- a/tests/usr.bin/indent/opt-badp.0   Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-badp.0   Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,33 @@
-/* $NetBSD: opt-badp.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-badp.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+static void
+no_declarations(void)
+{
+       action();
+}
+
+static void
+declarations_without_blank_line(void)
+{
+       int local_variable;
+       action();               /* FIXME: need empty line above */
+}
+
+static void
+declaration_with_blank_line(void)
+{
+       int local_variable;
+
+       action();
+}
+
+static void
+declaration_with_several_blank_lines(void)
+{
+       int local_variable;
+
+
+
+       action();
+}
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-badp.0.stdout
--- a/tests/usr.bin/indent/opt-badp.0.stdout    Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-badp.0.stdout    Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,34 @@
-/* $NetBSD: opt-badp.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-badp.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+static void
+no_declarations(void)
+{
+
+       action();
+}
+
+static void
+declarations_without_blank_line(void)
+{
+       int             local_variable;
+       action();               /* FIXME: need empty line above */
+}
+
+static void
+declaration_with_blank_line(void)
+{
+       int             local_variable;
+
+       action();
+}
+
+static void
+declaration_with_several_blank_lines(void)
+{
+       int             local_variable;
+
+
+
+       action();
+}
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bap.0
--- a/tests/usr.bin/indent/opt-bap.0    Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bap.0    Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,22 @@
-/* $NetBSD: opt-bap.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-bap.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+static void one_liner(void) { /* FIXME: needs empty line below */ }
+static void several_lines(void) {
+       action();
+       /* FIXME: needs empty line below */
+}
+int main(void){/* FIXME: needs empty line below */}
+int global_variable;
+
+void already_has_blank_line_below(void)
+{
+}
+
+void has_several_blank_lines_below(void)
+{
+}
+
+
+
+int            the_end;
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bap.0.stdout
--- a/tests/usr.bin/indent/opt-bap.0.stdout     Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bap.0.stdout     Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,32 @@
-/* $NetBSD: opt-bap.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-bap.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+static void
+one_liner(void)
+{                              /* FIXME: needs empty line below */
+}
+static void
+several_lines(void)
+{
+       action();
+       /* FIXME: needs empty line below */
+}
+int
+main(void)
+{                              /* FIXME: needs empty line below */
+}
+int            global_variable;
+
+void
+already_has_blank_line_below(void)
+{
+}
+
+void
+has_several_blank_lines_below(void)
+{
+}
+
+
+
+int            the_end;
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bbb.0
--- a/tests/usr.bin/indent/opt-bbb.0    Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bbb.0    Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,26 @@
-/* $NetBSD: opt-bbb.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-bbb.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * This is a block comment.
+ */
+/* This is not a block comment since it is single-line. */
+/*
+ * This is a second block comment.
+ */
+/* This is not a block comment. */
+/*
+ * Documentation of global_variable.
+ */
+int global_variable;
+/*
+ * Documentation of function_declaration.
+ */
+void function_declaration(void);
+/*
+ * Documentation of function_definition.
+ */
+void
+function_definition(void)
+{
+}
diff -r cd8af8ddc03c -r 054765aacbb7 tests/usr.bin/indent/opt-bbb.0.stdout
--- a/tests/usr.bin/indent/opt-bbb.0.stdout     Sat Mar 06 19:16:45 2021 +0000
+++ b/tests/usr.bin/indent/opt-bbb.0.stdout     Sat Mar 06 19:30:44 2021 +0000
@@ -1,4 +1,30 @@
-/* $NetBSD: opt-bbb.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-bbb.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * This is a block comment.



Home | Main Index | Thread Index | Old Index