Module Name: src
Committed By: rillig
Date: Sat Oct 30 13:06:43 UTC 2021
Modified Files:
src/tests/usr.bin/indent: token_comment.c
Log Message:
tests/indent: add more tests for the assertion in search_stmt_comment
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/token_comment.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.11 src/tests/usr.bin/indent/token_comment.c:1.12
--- src/tests/usr.bin/indent/token_comment.c:1.11 Sat Oct 30 12:28:42 2021
+++ src/tests/usr.bin/indent/token_comment.c Sat Oct 30 13:06:43 2021
@@ -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 @@ t(void)
*
* 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
+{
+ 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
-int c(void)
{
if (7) { /*- a Christmas tree *
***
@@ -144,22 +179,12 @@ int c(void)
/*- 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 @@ c(void)
/*- another one *
***
***** */
- 7;
+ stmt();
}
-
- if (1) /*- a Christmas tree *
- ***
- ***** */
- /*- another one *
- ***
- ***** */
- 1;
}
#indent end
@@ -196,6 +213,23 @@ int decl; /*-fixed comment
*/
+#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 @@ int decl; /*-fixed comment
/*
* 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 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++
/*
+ * 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.
*/