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



details:   https://anonhg.NetBSD.org/src/rev/065cdaa31a60
branches:  trunk
changeset: 990574:065cdaa31a60
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 30 13:06:43 2021 +0000

description:
tests/indent: add more tests for the assertion in search_stmt_comment

diffstat:

 tests/usr.bin/indent/token_comment.c |  133 +++++++++++++++++++++++++++++-----
 1 files changed, 111 insertions(+), 22 deletions(-)

diffs (190 lines):

diff -r b6b613ac1c4d -r 065cdaa31a60 tests/usr.bin/indent/token_comment.c
--- a/tests/usr.bin/indent/token_comment.c      Sat Oct 30 12:28:42 2021 +0000
+++ b/tests/usr.bin/indent/token_comment.c      Sat Oct 30 13:06:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.11 2021/10/30 12:28:42 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.12 2021/10/30 13:06:43 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -134,9 +134,44 @@
  *
  * The other Christmas tree is a standalone block comment, therefore the
  * comment starts in the code column.
+ *
+ * Since the comments occur between psym_if_expr and the following statement,
+ * they are handled by search_stmt_comment.
  */
 #indent input
-int c(void)
+{
+       if (1) /*- a Christmas tree  *  search_stmt_comment
+                                   ***
+                                  ***** */
+                   /*- another one *  search_stmt_comment
+                                  ***
+                                 ***** */
+               1;
+}
+#indent end
+
+#indent run -bbb
+{
+       if (1)                  /*- a Christmas tree  *  search_stmt_comment
+                                                    ***
+                                                   ***** */
+               /*- another one *  search_stmt_comment
+                              ***
+                             ***** */
+               1;
+}
+#indent end
+
+
+/*
+ * The first Christmas tree is to the right of the code, therefore the comment
+ * is moved to the code comment column; the follow-up lines of that comment
+ * are moved by the same distance, to preserve the internal layout.
+ *
+ * The other Christmas tree is a standalone block comment, therefore the
+ * comment starts in the code column.
+ */
+#indent input
 {
        if (7) { /*- a Christmas tree  *
                                      ***
@@ -144,22 +179,12 @@
                    /*- another one *
                                   ***
                                  ***** */
-               7;
+               stmt();
        }
-
-       if (1) /*- a Christmas tree  *
-                                   ***
-                                  ***** */
-                   /*- another one *
-                                  ***
-                                 ***** */
-               1;
 }
 #indent end
 
 #indent run -bbb
-int
-c(void)
 {
        if (7) {                /*- a Christmas tree  *
                                                     ***
@@ -167,16 +192,8 @@
                /*- another one *
                               ***
                              ***** */
-               7;
+               stmt();
        }
-
-       if (1)                  /*- a Christmas tree  *
-                                                    ***
-                                                   ***** */
-               /*- another one *
-                              ***
-                             ***** */
-               1;
 }
 #indent end
 
@@ -196,6 +213,23 @@
  */
 
 
+#indent input
+{
+       if (0)/*-search_stmt_comment   |
+          search_stmt_comment         |*/
+               ;
+}
+#indent end
+
+#indent run -di0
+{
+       if (0)                  /*-search_stmt_comment   |
+                            search_stmt_comment         |*/
+               ;
+}
+#indent end
+
+
 /*
  * Ensure that all text of the comment is preserved when the comment is moved
  * to the right.
@@ -213,6 +247,29 @@
 
 /*
  * Ensure that all text of the comment is preserved when the comment is moved
+ * to the right.
+ *
+ * This comment is handled by search_stmt_comment.
+ */
+#indent input
+{
+       if(0)/*-search_stmt_comment
+123456789ab search_stmt_comment   |*/
+           ;
+}
+#indent end
+
+#indent run -di0
+{
+       if (0)                  /*-search_stmt_comment
+                  123456789ab search_stmt_comment   |*/
+               ;
+}
+#indent end
+
+
+/*
+ * Ensure that all text of the comment is preserved when the comment is moved
  * to the left. In this case, the internal layout of the comment cannot be
  * preserved since the second line already starts in column 1.
  */
@@ -236,6 +293,38 @@
 
 
 /*
+ * Ensure that all text of the comment is preserved when the comment is moved
+ * to the left. In this case, the internal layout of the comment cannot be
+ * preserved since the second line already starts in column 1.
+ *
+ * This comment is processed by search_stmt_comment.
+ */
+#indent input
+{
+       if(0)                                       /*-|search_stmt_comment
+                                       | minus 12     |
+               | tabs inside           |
+           |---|
+|-----------|
+tab1+++        tab2--- tab3+++ tab4--- tab5+++ tab6--- tab7+++fixed comment*/
+               ;
+}
+#indent end
+
+#indent run -di0
+{
+       if (0)                  /*-|search_stmt_comment
+                   | minus 12     |
+| tabs inside          |
+|---|
+|-----------|
+tab1+++        tab2--- tab3+++ tab4--- tab5+++ tab6--- tab7+++fixed comment*/
+               ;
+}
+#indent end
+
+
+/*
  * The following comments test line breaking when the comment ends with a
  * space.
  */



Home | Main Index | Thread Index | Old Index