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: refine a few tests
details: https://anonhg.NetBSD.org/src/rev/7b4d2e839fcc
branches: trunk
changeset: 375955:7b4d2e839fcc
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 22 23:01:27 2023 +0000
description:
tests/indent: refine a few tests
diffstat:
tests/usr.bin/indent/edge_cases.c | 14 +++++++++-----
tests/usr.bin/indent/lsym_do.c | 26 +++++++++++++++++++++++++-
tests/usr.bin/indent/lsym_funcname.c | 8 +++-----
3 files changed, 37 insertions(+), 11 deletions(-)
diffs (92 lines):
diff -r d270f88f76d4 -r 7b4d2e839fcc tests/usr.bin/indent/edge_cases.c
--- a/tests/usr.bin/indent/edge_cases.c Mon May 22 22:36:53 2023 +0000
+++ b/tests/usr.bin/indent/edge_cases.c Mon May 22 23:01:27 2023 +0000
@@ -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
diff -r d270f88f76d4 -r 7b4d2e839fcc tests/usr.bin/indent/lsym_do.c
--- a/tests/usr.bin/indent/lsym_do.c Mon May 22 22:36:53 2023 +0000
+++ b/tests/usr.bin/indent/lsym_do.c Mon May 22 23:01:27 2023 +0000
@@ -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
diff -r d270f88f76d4 -r 7b4d2e839fcc tests/usr.bin/indent/lsym_funcname.c
--- a/tests/usr.bin/indent/lsym_funcname.c Mon May 22 22:36:53 2023 +0000
+++ b/tests/usr.bin/indent/lsym_funcname.c Mon May 22 23:01:27 2023 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index