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 fixing of invalid pr...



details:   https://anonhg.NetBSD.org/src/rev/45d8b7d6e023
branches:  trunk
changeset: 989001:45d8b7d6e023
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 09 10:56:13 2021 +0000

description:
tests/indent: test fixing of invalid preprocessor directives

diffstat:

 tests/usr.bin/indent/token-preprocessing.0        |  26 ++++++++++++++++++++++-
 tests/usr.bin/indent/token-preprocessing.0.stdout |  26 ++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 2 deletions(-)

diffs (74 lines):

diff -r dbaf5ca58d89 -r 45d8b7d6e023 tests/usr.bin/indent/token-preprocessing.0
--- a/tests/usr.bin/indent/token-preprocessing.0        Sat Oct 09 09:07:20 2021 +0000
+++ b/tests/usr.bin/indent/token-preprocessing.0        Sat Oct 09 10:56:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.5 2021/10/08 21:32:28 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.6 2021/10/09 10:56:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -68,3 +68,27 @@
 int unary_plus =
 #define intermediate 1
        + 4;
+
+/*
+ * Preprocessing lines that don't expect an argument but have one are fixed.
+ * They are indented with a single tab.
+ */
+#if 0
+#elif 1
+#else if 3
+#endif 0
+
+/*
+ * Existing comments are indented just like code comments.
+ *
+ * This means that the above wrong preprocessing lines need to be fed through
+ * indent twice until they become stable. Since compilers issue warnings about
+ * these invalid lines, not much code still has these.
+ */
+#if 0          /* comment */
+#else          /* comment */
+#endif         /* comment */
+
+#if 0/* comment */
+#else/* comment */
+#endif/* comment */
diff -r dbaf5ca58d89 -r 45d8b7d6e023 tests/usr.bin/indent/token-preprocessing.0.stdout
--- a/tests/usr.bin/indent/token-preprocessing.0.stdout Sat Oct 09 09:07:20 2021 +0000
+++ b/tests/usr.bin/indent/token-preprocessing.0.stdout Sat Oct 09 10:56:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.7 2021/10/08 21:32:28 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.8 2021/10/09 10:56:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -69,3 +69,27 @@
 int            unary_plus =
 #define intermediate 1
 +4;
+
+/*
+ * Preprocessing lines that don't expect an argument but have one are fixed.
+ * They are indented with a single tab.
+ */
+#if 0
+#elif 1
+#else  /* if 3 */
+#endif /* 0 */
+
+/*
+ * Existing comments are indented just like code comments.
+ *
+ * This means that the above wrong preprocessing lines need to be fed through
+ * indent twice until they become stable. Since compilers issue warnings about
+ * these invalid lines, not much code still has these.
+ */
+#if 0                          /* comment */
+#else                          /* comment */
+#endif                         /* comment */
+
+#if 0                          /* comment */
+#else                          /* comment */
+#endif                         /* comment */



Home | Main Index | Thread Index | Old Index