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 another test for inde...
details: https://anonhg.NetBSD.org/src/rev/14787cddc3d7
branches: trunk
changeset: 361161:14787cddc3d7
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 12 19:46:56 2022 +0000
description:
tests/indent: add another test for indentation of enum constants
To prevent an overzealous quick hack for indenting enum constants in a
typedef, as part of fixing PR#55453.
diffstat:
tests/usr.bin/indent/lsym_tag.c | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
diffs (50 lines):
diff -r f4635ad0202f -r 14787cddc3d7 tests/usr.bin/indent/lsym_tag.c
--- a/tests/usr.bin/indent/lsym_tag.c Sat Feb 12 17:17:53 2022 +0000
+++ b/tests/usr.bin/indent/lsym_tag.c Sat Feb 12 19:46:56 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_tag.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $NetBSD: lsym_tag.c,v 1.2 2022/02/12 19:46:56 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -6,8 +6,38 @@
* 'struct', 'union' or 'enum' that declare, define or use a tagged type.
*/
+/* TODO: Add systematic tests for 'struct'. */
+/* TODO: Add systematic tests for 'union'. */
+/* TODO: Add systematic tests for 'enum'. */
+
+
#indent input
-// TODO: add input
+int
+indent_enum_constants(void)
+{
+ enum color {
+ red,
+ green
+ };
+ enum color colors[] = {
+ red,
+ red,
+ red,
+ };
+ /*
+ * Ensure that the token sequence 'enum type {' only matches if there
+ * are no other tokens in between, to prevent statement continuations
+ * from being indented like enum constant declarations.
+ *
+ * See https://gnats.netbsd.org/55453.
+ */
+ if (colors[0] == (enum color)1) {
+ return 1
+ + 2
+ + 3;
+ }
+ return 0;
+}
#indent end
-#indent run-equals-input
+#indent run-equals-input -ci2
Home |
Main Index |
Thread Index |
Old Index