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 tests for the remaini...



details:   https://anonhg.NetBSD.org/src/rev/c180e3f0a1ae
branches:  trunk
changeset: 1019326:c180e3f0a1ae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 07 10:12:18 2021 +0000

description:
tests/indent: add tests for the remaining command line options

diffstat:

 tests/usr.bin/indent/opt-P.0           |   8 ++++++--
 tests/usr.bin/indent/opt-P.0.stdout    |   8 ++++++--
 tests/usr.bin/indent/opt-T.0           |  13 +++++++++++--
 tests/usr.bin/indent/opt-T.0.stdout    |  13 +++++++++++--
 tests/usr.bin/indent/opt-U.0           |  10 ++++++++--
 tests/usr.bin/indent/opt-U.0.stdout    |  10 ++++++++--
 tests/usr.bin/indent/opt-lpl.0         |  24 ++++++++++++++++++++++--
 tests/usr.bin/indent/opt-lpl.0.stdout  |  27 +++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-nlpl.0        |  24 ++++++++++++++++++++++--
 tests/usr.bin/indent/opt-nlpl.0.stdout |  27 +++++++++++++++++++++++++--
 tests/usr.bin/indent/opt-npcs.0        |  10 ++++++++--
 tests/usr.bin/indent/opt-npcs.0.stdout |  10 ++++++++--
 tests/usr.bin/indent/opt-npro.0        |   8 ++++++--
 tests/usr.bin/indent/opt-npro.0.stdout |   8 ++++++--
 tests/usr.bin/indent/opt-npsl.0        |   6 ++++--
 tests/usr.bin/indent/opt-npsl.0.stdout |   8 ++++++--
 tests/usr.bin/indent/opt-nsc.0         |  15 +++++++++++++--
 tests/usr.bin/indent/opt-nsc.0.stdout  |  15 +++++++++++++--
 tests/usr.bin/indent/opt-nsob.0        |  22 ++++++++++++++++++++--
 tests/usr.bin/indent/opt-nsob.0.stdout |  22 ++++++++++++++++++++--
 tests/usr.bin/indent/opt-nut.0         |  13 +++++++++++--
 tests/usr.bin/indent/opt-nut.0.stdout  |  13 +++++++++++--
 tests/usr.bin/indent/opt-nv.0          |   9 +++++++--
 tests/usr.bin/indent/opt-nv.0.stdout   |  11 +++++++++--
 tests/usr.bin/indent/opt-pcs.0         |  10 ++++++++--
 tests/usr.bin/indent/opt-pcs.0.stdout  |  10 ++++++++--
 tests/usr.bin/indent/opt-psl.0         |   6 ++++--
 tests/usr.bin/indent/opt-psl.0.stdout  |   9 +++++++--
 tests/usr.bin/indent/opt-sc.0          |  15 +++++++++++++--
 tests/usr.bin/indent/opt-sc.0.stdout   |  15 +++++++++++++--
 tests/usr.bin/indent/opt-sob.0         |  24 ++++++++++++++++++++++--
 tests/usr.bin/indent/opt-sob.0.stdout  |  22 ++++++++++++++++++++--
 tests/usr.bin/indent/opt-ta.0          |  10 ++++++++--
 tests/usr.bin/indent/opt-ta.0.stdout   |  10 ++++++++--
 tests/usr.bin/indent/opt-ts.0          |  16 ++++++++++++++--
 tests/usr.bin/indent/opt-ts.0.stdout   |  16 ++++++++++++++--
 tests/usr.bin/indent/opt-ut.0          |  12 ++++++++++--
 tests/usr.bin/indent/opt-ut.0.stdout   |  12 ++++++++++--
 tests/usr.bin/indent/opt-v.0           |  11 +++++++++--
 tests/usr.bin/indent/opt-v.0.stdout    |  15 +++++++++++----
 40 files changed, 465 insertions(+), 82 deletions(-)

diffs (truncated from 787 to 300 lines):

diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-P.0
--- a/tests/usr.bin/indent/opt-P.0      Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-P.0      Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-P.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-P.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning another profile via -P has no effect since only a single
+ * profile can be specified on the command line, and there is no 'include'
+ * option.
+ */
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-P.0.stdout
--- a/tests/usr.bin/indent/opt-P.0.stdout       Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-P.0.stdout       Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-P.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-P.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning another profile via -P has no effect since only a single
+ * profile can be specified on the command line, and there is no 'include'
+ * option.
+ */
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-T.0
--- a/tests/usr.bin/indent/opt-T.0      Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-T.0      Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,13 @@
-/* $NetBSD: opt-T.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-T.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void *arg)
+{
+       int cast = (custom_type_name)   *   arg;
+
+       int mult = (unknown_type_name)   *   arg;
+
+       /* See the option -ta for handling these types. */
+       int suff = (unknown_type_name_t)   *   arg;
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-T.0.stdout
--- a/tests/usr.bin/indent/opt-T.0.stdout       Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-T.0.stdout       Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,13 @@
-/* $NetBSD: opt-T.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-T.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void *arg)
+{
+       int             cast = (custom_type_name)*arg;
+
+       int             mult = (unknown_type_name) * arg;
+
+       /* See the option -ta for handling these types. */
+       int             suff = (unknown_type_name_t) * arg;
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-U.0
--- a/tests/usr.bin/indent/opt-U.0      Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-U.0      Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,10 @@
-/* $NetBSD: opt-U.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-U.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void *arg)
+{
+       int known_1 = (size_t)   *   arg;
+       int known_2 = (off_t)   *   arg;
+       int ignored = (ignored_t)   *   arg;
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-U.0.stdout
--- a/tests/usr.bin/indent/opt-U.0.stdout       Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-U.0.stdout       Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,10 @@
-/* $NetBSD: opt-U.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-U.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void *arg)
+{
+       int             known_1 = (size_t)*arg;
+       int             known_2 = (off_t)*arg;
+       int             ignored = (ignored_t) * arg;
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-lpl.0
--- a/tests/usr.bin/indent/opt-lpl.0    Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-lpl.0    Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,24 @@
-/* $NetBSD: opt-lpl.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-lpl.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+       int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
+       int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
+
+       int sum3 = 1+2+3+4+5+
+               6+7+8+9+10+
+               11+12+13+14+15+
+               16+17+18+19+20+
+               21;
+       int sum4 = (1+2+3+4+5+
+               6+7+8+9+10+
+               11+12+13+14+15+
+               16+17+18+19+20+
+               21);
+
+       call_function(call_function(call_function(call_function(call_function(call_function())))));
+
+       call_function((call_function(call_function(call_function(call_function(call_function()))))));
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-lpl.0.stdout
--- a/tests/usr.bin/indent/opt-lpl.0.stdout     Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-lpl.0.stdout     Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,27 @@
-/* $NetBSD: opt-lpl.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-lpl.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* $ TODO: Add code that differs between -lpl and -nlpl. */
+void
+example(void)
+{
+       int             sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
+       int             sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
+
+/* $ XXX: There should be at least _some_ indentation for the */
+/* $ continuation lines. */
+       int             sum3 = 1 + 2 + 3 + 4 + 5 +
+       6 + 7 + 8 + 9 + 10 +
+       11 + 12 + 13 + 14 + 15 +
+       16 + 17 + 18 + 19 + 20 +
+       21;
+       int             sum4 = (1 + 2 + 3 + 4 + 5 +
+                               6 + 7 + 8 + 9 + 10 +
+                               11 + 12 + 13 + 14 + 15 +
+                               16 + 17 + 18 + 19 + 20 +
+                               21);
+
+       call_function(call_function(call_function(call_function(call_function(call_function())))));
+
+       call_function((call_function(call_function(call_function(call_function(call_function()))))));
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-nlpl.0
--- a/tests/usr.bin/indent/opt-nlpl.0   Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-nlpl.0   Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,24 @@
-/* $NetBSD: opt-nlpl.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nlpl.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+       int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
+       int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
+
+       int sum3 = 1+2+3+4+5+
+               6+7+8+9+10+
+               11+12+13+14+15+
+               16+17+18+19+20+
+               21;
+       int sum4 = (1+2+3+4+5+
+               6+7+8+9+10+
+               11+12+13+14+15+
+               16+17+18+19+20+
+               21);
+
+       call_function(call_function(call_function(call_function(call_function(call_function())))));
+
+       call_function((call_function(call_function(call_function(call_function(call_function()))))));
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-nlpl.0.stdout
--- a/tests/usr.bin/indent/opt-nlpl.0.stdout    Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-nlpl.0.stdout    Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,27 @@
-/* $NetBSD: opt-nlpl.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nlpl.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* $ TODO: Add code that differs between -lpl and -nlpl. */
+void
+example(void)
+{
+       int             sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
+       int             sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
+
+/* $ XXX: There should be at least _some_ indentation for the */
+/* $ continuation lines. */
+       int             sum3 = 1 + 2 + 3 + 4 + 5 +
+       6 + 7 + 8 + 9 + 10 +
+       11 + 12 + 13 + 14 + 15 +
+       16 + 17 + 18 + 19 + 20 +
+       21;
+       int             sum4 = (1 + 2 + 3 + 4 + 5 +
+                               6 + 7 + 8 + 9 + 10 +
+                               11 + 12 + 13 + 14 + 15 +
+                               16 + 17 + 18 + 19 + 20 +
+                               21);
+
+       call_function(call_function(call_function(call_function(call_function(call_function())))));
+
+       call_function((call_function(call_function(call_function(call_function(call_function()))))));
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npcs.0
--- a/tests/usr.bin/indent/opt-npcs.0   Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npcs.0   Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,10 @@
-/* $NetBSD: opt-npcs.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-npcs.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+       function_call();
+       function_call(1);
+       function_call(1,2,3);
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npcs.0.stdout
--- a/tests/usr.bin/indent/opt-npcs.0.stdout    Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npcs.0.stdout    Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,10 @@
-/* $NetBSD: opt-npcs.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-npcs.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+       function_call();
+       function_call(1);
+       function_call(1, 2, 3);
+}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npro.0
--- a/tests/usr.bin/indent/opt-npro.0   Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npro.0   Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-npro.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-npro.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning the option -npro in a .pro file has no effect since at that
+ * point, indent has already decided to load the .pro file, and it only
+ * decides once.
+ */
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npro.0.stdout
--- a/tests/usr.bin/indent/opt-npro.0.stdout    Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npro.0.stdout    Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-npro.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-npro.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning the option -npro in a .pro file has no effect since at that
+ * point, indent has already decided to load the .pro file, and it only
+ * decides once.
+ */
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npsl.0
--- a/tests/usr.bin/indent/opt-npsl.0   Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npsl.0   Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,6 @@
-/* $NetBSD: opt-npsl.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-npsl.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void function_declaration(void);
+
+void function_definition(void) {}
diff -r 3abb33394857 -r c180e3f0a1ae tests/usr.bin/indent/opt-npsl.0.stdout
--- a/tests/usr.bin/indent/opt-npsl.0.stdout    Sun Mar 07 10:02:33 2021 +0000
+++ b/tests/usr.bin/indent/opt-npsl.0.stdout    Sun Mar 07 10:12:18 2021 +0000
@@ -1,4 +1,8 @@



Home | Main Index | Thread Index | Old Index