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: migrate token_comma to ls...
details: https://anonhg.NetBSD.org/src/rev/8a586ccedda8
branches: trunk
changeset: 1026548:8a586ccedda8
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 28 15:26:22 2021 +0000
description:
tests/indent: migrate token_comma to lsym_comma
The section on initializer values is new.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/usr.bin/indent/Makefile | 3 +-
tests/usr.bin/indent/lsym_comma.c | 155 ++++++++++++++++++++++++++++++++++++-
tests/usr.bin/indent/token_comma.c | 60 --------------
4 files changed, 156 insertions(+), 66 deletions(-)
diffs (271 lines):
diff -r 1940af7f93ae -r 8a586ccedda8 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Nov 28 14:49:28 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Nov 28 15:26:22 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $
+# $NetBSD: mi,v 1.1171 2021/11/28 15:26:22 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5245,7 +5245,7 @@
./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-obsolete obsolete,atf
-./usr/tests/usr.bin/indent/token_comma.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/token_comma.c tests-obsolete obsolete,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
./usr/tests/usr.bin/indent/token_do_stmt.c tests-usr.bin-tests compattestfile,atf
diff -r 1940af7f93ae -r 8a586ccedda8 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile Sun Nov 28 14:49:28 2021 +0000
+++ b/tests/usr.bin/indent/Makefile Sun Nov 28 15:26:22 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $
+# $NetBSD: Makefile,v 1.37 2021/11/28 15:26:22 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_comma.c
FILES+= token_comment.c
FILES+= token_decl.c
FILES+= token_do_stmt.c
diff -r 1940af7f93ae -r 8a586ccedda8 tests/usr.bin/indent/lsym_comma.c
--- a/tests/usr.bin/indent/lsym_comma.c Sun Nov 28 14:49:28 2021 +0000
+++ b/tests/usr.bin/indent/lsym_comma.c Sun Nov 28 15:26:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comma.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */
+/* $NetBSD: lsym_comma.c,v 1.3 2021/11/28 15:26:22 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -22,10 +22,161 @@
* In a macro definition, a ',' separates the parameter names.
*
* In a macro invocation, a ',' separates the arguments.
+ *
+ * In an initializer list, a ',' separates the initializer expressions.
*/
+/*
+ * The ',' is a binary operator with very low precedence.
+ */
#indent input
-// TODO: add input
+int
+comma_expression(void)
+{
+ return 1, 3;
+ return a = b, c = d;
+}
#indent end
#indent run-equals-input
+
+
+/*
+ * In a declaration, a ',' separates the declarators.
+ */
+#indent input
+int decl, old_style(), prototype(const char *, double *);
+int a, b, c;
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a parameter list of a function type, a ',' separates the parameter
+ * declarations.
+ */
+#indent input
+double dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double));
+double dbl_reduce(double, const double *, const double *, double (*)(double, double));
+void debug_printf(const char *, ...);
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a traditional function definition, a ',' separates the parameter names.
+ */
+#indent input
+double
+trad_dbl_reduce(init, s, e, merge)
+ double init;
+ double *s, *e;
+ double (*merge)()
+{
+ double x = init;
+ while (s < e)
+ x = merge(x, *s++);
+ return x;
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a prototype function definition, a ',' separates the parameter
+ * declarations.
+ */
+#indent input
+void
+dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double))
+{
+ double x = init;
+ while (s < e)
+ x = merge(x, *s++);
+ return x;
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a function call expression, a ',' separates the arguments.
+ */
+#indent input
+void
+function(void)
+{
+ function_call(arg1, arg2);
+ (*indirect_function_call)(arg1, arg2);
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a macro definition, a ',' separates the parameter names.
+ */
+#indent input
+#define no_space(a,b) a ## b
+#define normal_space(a, b) a ## b
+#define wide_space(a , b) a ## b
+#indent end
+
+/*
+ * Indent does not touch preprocessor directives, except for the spacing
+ * between the '#' and the directive.
+ */
+#indent run-equals-input
+
+
+/*
+ * In a macro invocation, a ',' separates the arguments.
+ */
+#indent input
+void
+function(void)
+{
+ macro_invocation(arg1, arg2);
+ empty_arguments(,,,);
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In an initializer list, a ',' separates the initializer expressions.
+ *
+ * If a ',' starts a line, indent doesn't put a space before it.
+ */
+#indent input
+int arr[] = {1, 2, 3};
+int arr[] = {
+ 1,
+ 2,
+ 3, /* there may be a trailing comma */
+};
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * If a ',' starts a line, indent doesn't put a space before it. This style is
+ * uncommon and looks unbalanced since the '1' is not aligned to the other
+ * numbers.
+ */
+#indent input
+int arr[] = {
+ 1
+ ,2
+ ,3
+};
+#indent end
+
+#indent run-equals-input -di0
diff -r 1940af7f93ae -r 8a586ccedda8 tests/usr.bin/indent/token_comma.c
--- a/tests/usr.bin/indent/token_comma.c Sun Nov 28 14:49:28 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/* $NetBSD: token_comma.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tests for the comma, which is used in the following contexts:
- *
- * The binary operator ',' inserts a sequence point between the evaluation of
- * its operands.
- *
- * The parameters of a function declaration or a macro definition are
- * separated by a comma.
- *
- * The arguments of a function call expression or a macro invocation are
- * separated by a comma.
- */
-
-#indent input
-int
-comma_expression(void)
-{
- return 1,3;
- return a=b,c=d;
-}
-#indent end
-
-#indent run
-int
-comma_expression(void)
-{
- return 1, 3;
- return a = b, c = d;
-}
-#indent end
-
-
-/*
- * A comma that occurs at the beginning of a line is probably part of an
- * initializer list, placed there for alignment.
- */
-#indent input
-int
-comma_at_beginning_of_line(void)
-{
- return 1,
- 3;
- return 1
- ,3;
-}
-#indent end
-
-#indent run -ci4
-int
-comma_at_beginning_of_line(void)
-{
- return 1,
- 3;
- return 1
- ,3;
-}
-#indent end
Home |
Main Index |
Thread Index |
Old Index