Module Name:    src
Committed By:   rillig
Date:           Mon May 22 23:01:27 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: edge_cases.c lsym_do.c lsym_funcname.c

Log Message:
tests/indent: refine a few tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/edge_cases.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_funcname.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/edge_cases.c
diff -u src/tests/usr.bin/indent/edge_cases.c:1.1 src/tests/usr.bin/indent/edge_cases.c:1.2
--- src/tests/usr.bin/indent/edge_cases.c:1.1	Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/edge_cases.c	Mon May 22 23:01:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: edge_cases.c,v 1.1 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: edge_cases.c,v 1.2 2023/05/22 23:01:27 rillig Exp $ */
 
 /*
  * Tests for edge cases in the C programming language that indent does not
@@ -7,7 +7,8 @@
 
 /*
  * Digraphs are replacements for the characters '[', '{' and '#', which are
- * missing in some exotic restricted source character sets.
+ * missing in some exotic restricted source character sets.  They are not used
+ * in practice, therefore indent doesn't need to support them.
  *
  * See C99 6.4.6
  */
@@ -28,12 +29,15 @@ void
 digraphs(void)
 {
 	/* same as 'array[subscript]' */
-// $ XXX: The indentation is completely wrong.
-// $ XXX: The space between 'array' and '<' doesn't belong there.
+// $ Indent interprets everything before the second ':' as a label name,
+// $ therefore the statement is indented that far to the left.
+// $
+// $ The space between 'array' and '<' comes from the binary operator '<'.
 number = array <:subscript:>;
 
 	/* same as '(int){ initializer }' */
-// $ XXX: The space between '%' and '>' doesn't belong there.
+// $ The opening '<' and '%' are interpreted as unary operators.
+// $ The closing '%' and '>' are interpreted as a binary and unary operator.
 	number = (int)<%initializer % >;
 }
 //indent end

Index: src/tests/usr.bin/indent/lsym_do.c
diff -u src/tests/usr.bin/indent/lsym_do.c:1.6 src/tests/usr.bin/indent/lsym_do.c:1.7
--- src/tests/usr.bin/indent/lsym_do.c:1.6	Sat May 13 06:52:48 2023
+++ src/tests/usr.bin/indent/lsym_do.c	Mon May 22 23:01:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_do.c,v 1.6 2023/05/13 06:52:48 rillig Exp $ */
+/* $NetBSD: lsym_do.c,v 1.7 2023/05/22 23:01:27 rillig Exp $ */
 
 /*
  * Tests for the token lsym_do, which represents the keyword 'do' that starts
@@ -86,3 +86,27 @@ variants(void)
 		} while (0);
 }
 //indent end
+
+//indent run -bl
+void
+variants(void)
+{
+	do
+		stmt();
+	while (0);
+
+	do
+	{
+		stmt();
+	} while (0);
+
+	do			/* comment */
+		stmt();
+	while (0);
+
+	while (0)
+		do
+		{
+		} while (0);
+}
+//indent end

Index: src/tests/usr.bin/indent/lsym_funcname.c
diff -u src/tests/usr.bin/indent/lsym_funcname.c:1.4 src/tests/usr.bin/indent/lsym_funcname.c:1.5
--- src/tests/usr.bin/indent/lsym_funcname.c:1.4	Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/lsym_funcname.c	Mon May 22 23:01:27 2023
@@ -1,10 +1,8 @@
-/* $NetBSD: lsym_funcname.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: lsym_funcname.c,v 1.5 2023/05/22 23:01:27 rillig Exp $ */
 
 /*
- * Tests for the token lsym_funcname, which is an identifier that is followed
- * by an opening parenthesis.
- *
- * TODO: Document how lsym_funcname is handled differently from lsym_word.
+ * Tests for the token lsym_funcname, which is the name of a function, but only
+ * in a function definition, not in a declaration or a call expression.
  *
  * See also:
  *	lsym_word.c

Reply via email to