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 test for INDENT OFF/O...



details:   https://anonhg.NetBSD.org/src/rev/318339eb6fac
branches:  trunk
changeset: 1024338:318339eb6fac
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 19 20:20:24 2021 +0000

description:
tests/indent: add test for INDENT OFF/ON comments

Just to prevent unintended side effects when fixing bugs in this area.

diffstat:

 distrib/sets/lists/tests/mi          |    3 +-
 tests/usr.bin/indent/Makefile        |    3 +-
 tests/usr.bin/indent/indent_off_on.c |  118 +++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 2 deletions(-)

diffs (156 lines):

diff -r eb61c4619054 -r 318339eb6fac distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Oct 19 20:01:09 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Oct 19 20:20:24 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1147 2021/10/18 23:01:10 rillig Exp $
+# $NetBSD: mi,v 1.1148 2021/10/19 20:20:24 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4752,6 +4752,7 @@
 ./usr/tests/usr.bin/indent/f_decls.0.stdout                            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/float.0                                     tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/float.0.stdout                              tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/indent_off_on.c                             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.pro                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.stdout                   tests-usr.bin-tests     compattestfile,atf
diff -r eb61c4619054 -r 318339eb6fac tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Tue Oct 19 20:01:09 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Tue Oct 19 20:20:24 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.23 2021/10/19 19:59:05 rillig Exp $
+#      $NetBSD: Makefile,v 1.24 2021/10/19 20:20:24 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -19,6 +19,7 @@
 FILES+=                elsecomment.0.pro
 FILES+=                f_decls.0
 FILES+=                f_decls.0.stdout
+FILES+=                indent_off_on.c
 FILES+=                indent_variables.0
 FILES+=                indent_variables.0.pro
 FILES+=                indent_variables.0.stdout
diff -r eb61c4619054 -r 318339eb6fac tests/usr.bin/indent/indent_off_on.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c      Tue Oct 19 20:20:24 2021 +0000
@@ -0,0 +1,118 @@
+/* $NetBSD: indent_off_on.c,v 1.1 2021/10/19 20:20:25 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the comments 'INDENT OFF' and 'INDENT ON', which temporarily
+ * disable formatting.
+ */
+
+#indent input
+{}
+
+/*INDENT OFF*/
+/*INDENT ON*/
+
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is kept as is, while 'INDENT ON'
+ * gets enclosed with spaces.
+ */
+#indent run
+{
+}
+/* $ FIXME: This empty line must stay. */
+/*INDENT OFF*/
+/* INDENT ON */
+
+{
+}
+#indent end
+
+
+#indent input
+{}
+ /* INDENT OFF */
+ /* INDENT ON */
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run
+{
+}
+ /* INDENT OFF */
+/* INDENT ON */
+{
+}
+#indent end
+
+
+#indent input
+{}
+       /* INDENT OFF */
+       /* INDENT ON */
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run
+{
+}
+       /* INDENT OFF */
+/* INDENT ON */
+{
+}
+#indent end
+
+/*
+ * The INDENT comments can be written without space between the words, but
+ * nobody does this.
+ */
+#indent input
+int   decl   ;
+/*INDENTOFF*/
+int   decl   ;
+/*INDENTON*/
+int   decl   ;
+#indent end
+
+#indent run -di0
+int decl;
+/*INDENTOFF*/
+int   decl   ;
+/* INDENTON */
+int decl;
+#indent end
+
+
+/*
+ * Any whitespace around the 'INDENT ON/OFF' is ignored, as is any whitespace
+ * between the two words.
+ */
+#indent input
+int decl;
+/*             INDENT          OFF             */
+int   decl   ;
+/*             INDENT          ON              */
+int decl;
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run -di0
+int decl;
+/*             INDENT          OFF             */
+int   decl   ;
+/* INDENT              ON              */
+int decl;
+#indent end



Home | Main Index | Thread Index | Old Index