Module Name: src
Committed By: rillig
Date: Sat Oct 30 12:24:03 UTC 2021
Modified Files:
src/tests/usr.bin/indent: token_comment.c
Log Message:
tests/lint: explain and extend the tests for box comments
These tests are in preparation of removing the magic number 4 from
search_stmt_comment.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/tests/usr.bin/indent/token_comment.c:1.10
--- src/tests/usr.bin/indent/token_comment.c:1.9 Fri Oct 29 17:50:37 2021
+++ src/tests/usr.bin/indent/token_comment.c Sat Oct 30 12:24:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.9 2021/10/29 17:50:37 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.10 2021/10/30 12:24:03 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -126,25 +126,34 @@ t(void)
}
#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 (1) { /*- a christmas tree *
+ if (7) { /*- a Christmas tree *
***
***** */
/*- another one *
***
***** */
- 7;
+ 7;
}
- if (1) /*- a christmas tree *
+ if (1) /*- a Christmas tree *
***
***** */
/*- another one *
***
***** */
- 1;
+ 1;
}
#indent end
@@ -152,7 +161,7 @@ int c(void)
int
c(void)
{
- if (1) { /*- a christmas tree *
+ if (7) { /*- a Christmas tree *
***
***** */
/*- another one *
@@ -161,7 +170,7 @@ c(void)
7;
}
- if (1) /*- a christmas tree *
+ if (1) /*- a Christmas tree *
***
***** */
/*- another one *
@@ -171,6 +180,53 @@ c(void)
}
#indent end
+
+#indent input
+int decl;/*-fixed comment
+ fixed comment*/
+#indent end
+
+#indent run -di0
+int decl; /*-fixed comment
+ fixed comment*/
+#indent end
+/*
+ * XXX: The second line of the above comment contains 11 spaces in a row,
+ * instead of using as many tabs as possible.
+ */
+
+
+/*
+ * Ensure that all text of the comment is preserved when the comment is moved
+ * to the right.
+ */
+#indent input
+int decl;/*-fixed comment
+123456789ab fixed comment*/
+#indent end
+
+#indent run -di0
+int decl; /*-fixed comment
+ 123456789ab fixed 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.
+ */
+#indent input
+int decl; /*-fixed comment
+tab1+++ tab2--- tab3+++ tab4--- tab5+++ tab6--- tab7+++fixed comment*/
+#indent end
+
+#indent run -di0
+int decl; /*-fixed comment
+tab1+++ tab2--- tab3+++ tab4--- tab5+++ tab6--- tab7+++fixed comment*/
+#indent end
+
+
/*
* The following comments test line breaking when the comment ends with a
* space.