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: move tests for indent com...



details:   https://anonhg.NetBSD.org/src/rev/085a86800a5c
branches:  trunk
changeset: 989905:085a86800a5c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 19 20:41:42 2021 +0000

description:
tests/indent: move tests for indent comments

The special INDENT ON and INDENT OFF comments look like ordinary
comments but are handled in inbuf_read_line. Implementing this feature
in the input function has several unintended side effects regarding
indentation of these comments, as demonstrated by the tests.

diffstat:

 tests/usr.bin/indent/indent_off_on.c |  81 +++++++++++++++++++++++++++++-
 tests/usr.bin/indent/token_comment.c |  98 +-----------------------------------
 2 files changed, 81 insertions(+), 98 deletions(-)

diffs (204 lines):

diff -r 5fe746066e98 -r 085a86800a5c tests/usr.bin/indent/indent_off_on.c
--- a/tests/usr.bin/indent/indent_off_on.c      Tue Oct 19 20:20:24 2021 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c      Tue Oct 19 20:41:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.1 2021/10/19 20:20:25 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.2 2021/10/19 20:41:42 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -116,3 +116,82 @@
 /* INDENT              ON              */
 int decl;
 #indent end
+
+
+#indent input
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/*INDENT ON*/
+}}}
+#indent end
+
+#indent run
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/* $ XXX: Why is the INDENT ON comment indented? */
+/* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */
+                       /* INDENT ON */
+}
+}
+}
+#indent end
+
+
+#indent input
+/* INDENT OFF */
+void indent_off ( void ) ;
+/*  INDENT */
+void indent_on ( void ) ;
+/* INDENT OFF */
+void indent_off ( void ) ;
+       /* INDENT ON */
+void indent_on ( void ) ;      /* the comment may be indented */
+/* INDENT              OFF                                     */
+void indent_off ( void ) ;
+/* INDENTATION ON */
+void indent_still_off ( void ) ;       /* due to the word 'INDENTATION' */
+/* INDENT ON * */
+void indent_still_off ( void ) ;       /* due to the extra '*' at the end */
+/* INDENT ON */
+void indent_on ( void ) ;
+/* INDENT: OFF */
+void indent_still_on ( void ) ;        /* due to the colon in the middle */
+/* INDENT OFF */               /* extra comment */
+void indent_still_on ( void ) ;        /* due to the extra comment to the right */
+#indent end
+
+#indent run
+/* INDENT OFF */
+void indent_off ( void ) ;
+/* $ XXX: The double space from the below comment got merged to a single */
+/* $ XXX: space even though the comment might be regarded to be still in */
+/* $ XXX: the OFF section. */
+/* INDENT */
+void
+indent_on(void);
+/* INDENT OFF */
+void indent_off ( void ) ;
+/* $ XXX: The below comment got moved from column 9 to column 1. */
+/* INDENT ON */
+void
+indent_on(void);               /* the comment may be indented */
+/* INDENT              OFF                                     */
+void indent_off ( void ) ;
+/* INDENTATION ON */
+void indent_still_off ( void ) ;       /* due to the word 'INDENTATION' */
+/* INDENT ON * */
+void indent_still_off ( void ) ;       /* due to the extra '*' at the end */
+/* INDENT ON */
+void
+indent_on(void);
+/* INDENT: OFF */
+void
+indent_still_on(void);         /* due to the colon in the middle */
+/* $ The extra comment got moved to the left since there is no code in */
+/* $ that line. */
+/* INDENT OFF *//* extra comment */
+void
+indent_still_on(void);         /* due to the extra comment to the right */
+#indent end
diff -r 5fe746066e98 -r 085a86800a5c tests/usr.bin/indent/token_comment.c
--- a/tests/usr.bin/indent/token_comment.c      Tue Oct 19 20:20:24 2021 +0000
+++ b/tests/usr.bin/indent/token_comment.c      Tue Oct 19 20:41:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.4 2021/10/19 18:29:59 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.5 2021/10/19 20:41:42 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -508,102 +508,6 @@
 }
 #indent end
 
-#indent input
-void
-function(void)
-{
-       code();
-}
-
-/*INDENT OFF*/
-#indent end
-
-#indent run
-void
-function(void)
-{
-       code();
-}
-/* $ FIXME: Missing empty line. */
-/*INDENT OFF*/
-#indent end
-
-/*
- * The special comments 'INDENT OFF' and 'INDENT ON' toggle whether the code
- * is formatted or kept as is.
- */
-#indent input
-/*INDENT OFF*/
-/* No formatting takes place here. */
-int format( void ) {{{
-/*INDENT ON*/
-}}}
-
-/* INDENT OFF */
-void indent_off ( void ) ;
-/*  INDENT */
-void indent_on ( void ) ;
-/* INDENT OFF */
-void indent_off ( void ) ;
-       /* INDENT ON */
-void indent_on ( void ) ;      /* the comment may be indented */
-/* INDENT              OFF                                     */
-void indent_off ( void ) ;
-/* INDENTATION ON */
-void indent_still_off ( void ) ;       /* due to the word 'INDENTATION' */
-/* INDENT ON * */
-void indent_still_off ( void ) ;       /* due to the extra '*' at the end */
-/* INDENT ON */
-void indent_on ( void ) ;
-/* INDENT: OFF */
-void indent_still_on ( void ) ;        /* due to the colon in the middle */
-/* INDENT OFF */               /* extra comment */
-void indent_still_on ( void ) ;        /* due to the extra comment to the right */
-#indent end
-
-#indent run
-/*INDENT OFF*/
-/* No formatting takes place here. */
-int format( void ) {{{
-/* $ XXX: Why is the INDENT ON comment indented? */
-/* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */
-                       /* INDENT ON */
-}
-}
-}
-/* $ FIXME: The empty line disappeared but shouldn't. */
-/* INDENT OFF */
-void indent_off ( void ) ;
-/* $ XXX: The double space from the below comment got merged to a single */
-/* $ XXX: space even though the comment might be regarded to be still in */
-/* $ XXX: the OFF section. */
-/* INDENT */
-void
-indent_on(void);
-/* INDENT OFF */
-void indent_off ( void ) ;
-/* $ XXX: The below comment got moved from column 9 to column 1. */
-/* INDENT ON */
-void
-indent_on(void);               /* the comment may be indented */
-/* INDENT              OFF                                     */
-void indent_off ( void ) ;
-/* INDENTATION ON */
-void indent_still_off ( void ) ;       /* due to the word 'INDENTATION' */
-/* INDENT ON * */
-void indent_still_off ( void ) ;       /* due to the extra '*' at the end */
-/* INDENT ON */
-void
-indent_on(void);
-/* INDENT: OFF */
-void
-indent_still_on(void);         /* due to the colon in the middle */
-/* $ The extra comment got moved to the left since there is no code in */
-/* $ that line. */
-/* INDENT OFF *//* extra comment */
-void
-indent_still_on(void);         /* due to the extra comment to the right */
-#indent end
 
 #indent input
 /*



Home | Main Index | Thread Index | Old Index