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: move test for ':' to lsym...



details:   https://anonhg.NetBSD.org/src/rev/1940af7f93ae
branches:  trunk
changeset: 1026547:1940af7f93ae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 28 14:49:28 2021 +0000

description:
tests/indent: move test for ':' to lsym_token.c

diffstat:

 distrib/sets/lists/tests/mi        |   4 +-
 tests/usr.bin/indent/Makefile      |   3 +-
 tests/usr.bin/indent/lsym_colon.c  |  90 +++++++++++++++++++++++++++++++++++++-
 tests/usr.bin/indent/token_colon.c |  74 -------------------------------
 4 files changed, 91 insertions(+), 80 deletions(-)

diffs (220 lines):

diff -r f366794487fe -r 1940af7f93ae distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Nov 28 14:29:03 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Nov 28 14:49:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1169 2021/11/28 14:29:03 rillig Exp $
+# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5244,7 +5244,7 @@
 ./usr/tests/usr.bin/indent/token-while_expr.0.stdout                   tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/token_binary_op.c                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_case_label.c                          tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/token_colon.c                               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/token_colon.c                               tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/token_comma.c                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_comment.c                             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_decl.c                                        tests-usr.bin-tests     compattestfile,atf
diff -r f366794487fe -r 1940af7f93ae tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Sun Nov 28 14:29:03 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Sun Nov 28 14:49:28 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.35 2021/11/28 14:29:03 rillig Exp $
+#      $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -112,7 +112,6 @@
 FILES+=                t_options.awk
 FILES+=                token_binary_op.c
 FILES+=                token_case_label.c
-FILES+=                token_colon.c
 FILES+=                token_comma.c
 FILES+=                token_comment.c
 FILES+=                token_decl.c
diff -r f366794487fe -r 1940af7f93ae tests/usr.bin/indent/lsym_colon.c
--- a/tests/usr.bin/indent/lsym_colon.c Sun Nov 28 14:29:03 2021 +0000
+++ b/tests/usr.bin/indent/lsym_colon.c Sun Nov 28 14:49:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_colon.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $NetBSD: lsym_colon.c,v 1.2 2021/11/28 14:49:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -11,10 +11,96 @@
  * As part of the conditional operator '?:'.
  *
  * In the declaration of a struct member that is a bit-field.
+ *
+ * See also:
+ *     label.c
+ *     lsym_question.c
  */
 
+/*
+ * The ':' marks a label that can be used in a 'goto' statement.
+ */
 #indent input
-// TODO: add input
+void endless(void)
+{
+label1:
+goto label2;
+
+    if (true)if (true)if (true)if (true)label2 :goto label1;
+}
+#indent end
+
+#indent run
+void
+endless(void)
+{
+label1:
+       goto label2;
+
+       if (true)
+               if (true)
+                       if (true)
+                               if (true)
+                       label2:         goto label1;
+}
+#indent end
+
+
+/*
+ * The ':' is used in a 'switch' statement, after a 'case' label or a
+ * 'default' label.
+ */
+#indent input
+void
+example(void)
+{
+       switch (expr) {
+       case 'x':
+               return;
+       default:
+               return;
+       }
+}
 #indent end
 
 #indent run-equals-input
+
+
+/*
+ * The ':' is used as part of the conditional operator '?:'.
+ */
+#indent input
+int constant_expression = true?4:12345;
+#indent end
+
+#indent run
+int            constant_expression = true ? 4 : 12345;
+#indent end
+
+
+/*
+ * The ':' is used in the declaration of a struct member that is a bit-field.
+ */
+#indent input
+struct bit_field {
+       bool flag:1;
+       int maybe_signed : 4;
+       signed int definitely_signed:3;
+       signed int : 0;/* padding */
+       unsigned int definitely_unsigned:3;
+       unsigned int:0;/* padding */
+};
+#indent end
+
+#indent run
+struct bit_field {
+       bool            flag:1;
+       int             maybe_signed:4;
+       signed int      definitely_signed:3;
+/* $ XXX: Placing the colon directly at the type looks inconsistent. */
+       signed int:     0;      /* padding */
+       unsigned int    definitely_unsigned:3;
+/* $ XXX: Placing the colon directly at the type looks inconsistent. */
+       unsigned int:   0;      /* padding */
+};
+#indent end
diff -r f366794487fe -r 1940af7f93ae tests/usr.bin/indent/token_colon.c
--- a/tests/usr.bin/indent/token_colon.c        Sun Nov 28 14:29:03 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/* $NetBSD: token_colon.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tests for formatting of the colon token, which is used in the following
- * contexts:
- *
- * After a label that is the target of a goto statement.
- *
- * In a switch statement, after a case label or the default label.
- *
- * As part of the conditional expression operator '?:'.
- *
- * In the declaration of a struct member that is a bit-field.
- */
-
-#indent input
-void endless(void)
-{
-label1:
-goto label2;
-
-    if (true)if (true)if (true)if (true)label2 :goto label1;
-}
-#indent end
-
-#indent run
-void
-endless(void)
-{
-label1:
-       goto label2;
-
-       if (true)
-               if (true)
-                       if (true)
-                               if (true)
-                       label2:         goto label1;
-}
-#indent end
-
-
-#indent input
-int constant_expression = true?4:12345;
-#indent end
-
-#indent run
-int            constant_expression = true ? 4 : 12345;
-#indent end
-
-
-#indent input
-struct bit_field {
-bool flag:1;
-int maybe_signed : 4;
-signed int definitely_signed:3;
-signed int : 0;/* finish the storage unit for the bit-field */
-unsigned int definitely_unsigned:3;
-unsigned int:0;/* finish the storage unit for the bit-field */
-};
-#indent end
-
-#indent run
-struct bit_field {
-       bool            flag:1;
-       int             maybe_signed:4;
-       signed int      definitely_signed:3;
-/* $ XXX: Placing the colon directly at the type looks inconsistent. */
-       signed int:     0;      /* finish the storage unit for the bit-field */
-       unsigned int    definitely_unsigned:3;
-/* $ XXX: Placing the colon directly at the type looks inconsistent. */
-       unsigned int:   0;      /* finish the storage unit for the bit-field */
-};
-#indent end



Home | Main Index | Thread Index | Old Index