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 skeletons for testing...
details: https://anonhg.NetBSD.org/src/rev/977e0f0a6b07
branches: trunk
changeset: 1026315:977e0f0a6b07
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Nov 18 21:19:18 2021 +0000
description:
tests/indent: add skeletons for testing tokens and parser symbols
The constants that were previously defined in indent_codes.h were a wild
mixture of tokens from the lexer and symbols on the parser stack. They
were split into separate types starting at indent.h 1.49 from 2021-10-25
and finishing at 1.73 from 2021-10-31.
To match the tests with the new token names, the old tests need to be
migrated to the newly added tests. This will take some time so first
add the skeletons and migrate them in smaller steps, cleaning them up
and extending them on the way.
diffstat:
distrib/sets/lists/tests/mi | 52 ++++++++++++++++++-
tests/usr.bin/indent/Makefile | 56 ++++++++++++++++++-
tests/usr.bin/indent/lsym_binary_op.c | 29 ++++++++++
tests/usr.bin/indent/lsym_case_label.c | 22 +++++++
tests/usr.bin/indent/lsym_colon.c | 20 +++++++
tests/usr.bin/indent/lsym_comma.c | 29 ++++++++++
tests/usr.bin/indent/lsym_comment.c | 19 ++++++
tests/usr.bin/indent/lsym_do.c | 19 ++++++
tests/usr.bin/indent/lsym_else.c | 13 ++++
tests/usr.bin/indent/lsym_eof.c | 12 ++++
tests/usr.bin/indent/lsym_for.c | 13 ++++
tests/usr.bin/indent/lsym_form_feed.c | 15 +++++
tests/usr.bin/indent/lsym_funcname.c | 16 +++++
tests/usr.bin/indent/lsym_if.c | 13 ++++
tests/usr.bin/indent/lsym_lbrace.c | 20 +++++++
tests/usr.bin/indent/lsym_lparen_or_lbracket.c | 28 ++++++++++
tests/usr.bin/indent/lsym_newline.c | 18 ++++++
tests/usr.bin/indent/lsym_offsetof.c | 13 ++++
tests/usr.bin/indent/lsym_period.c | 23 ++++++++
tests/usr.bin/indent/lsym_postfix_op.c | 16 +++++
tests/usr.bin/indent/lsym_preprocessing.c | 20 +++++++
tests/usr.bin/indent/lsym_question.c | 13 ++++
tests/usr.bin/indent/lsym_rbrace.c | 16 +++++
tests/usr.bin/indent/lsym_return.c | 13 ++++
tests/usr.bin/indent/lsym_rparen_or_rbracket.c | 16 +++++
tests/usr.bin/indent/lsym_semicolon.c | 19 ++++++
tests/usr.bin/indent/lsym_sizeof.c | 17 ++++++
tests/usr.bin/indent/lsym_storage_class.c | 13 ++++
tests/usr.bin/indent/lsym_string_prefix.c | 18 ++++++
tests/usr.bin/indent/lsym_switch.c | 17 ++++++
tests/usr.bin/indent/lsym_tag.c | 13 ++++
tests/usr.bin/indent/lsym_type_in_parentheses.c | 19 ++++++
tests/usr.bin/indent/lsym_type_outside_parentheses.c | 14 +++++
tests/usr.bin/indent/lsym_typedef.c | 13 ++++
tests/usr.bin/indent/lsym_unary_op.c | 18 ++++++
tests/usr.bin/indent/lsym_while.c | 13 ++++
tests/usr.bin/indent/lsym_word.c | 20 +++++++
tests/usr.bin/indent/psym_decl.c | 19 ++++++
tests/usr.bin/indent/psym_do.c | 13 ++++
tests/usr.bin/indent/psym_do_stmt.c | 14 +++++
tests/usr.bin/indent/psym_else.c | 15 +++++
tests/usr.bin/indent/psym_for_exprs.c | 14 +++++
tests/usr.bin/indent/psym_if_expr.c | 14 +++++
tests/usr.bin/indent/psym_if_expr_stmt.c | 15 +++++
tests/usr.bin/indent/psym_if_expr_stmt_else.c | 16 +++++
tests/usr.bin/indent/psym_lbrace.c | 17 ++++++
tests/usr.bin/indent/psym_rbrace.c | 16 +++++
tests/usr.bin/indent/psym_semicolon.c | 15 +++++
tests/usr.bin/indent/psym_stmt.c | 15 +++++
tests/usr.bin/indent/psym_stmt_list.c | 15 +++++
tests/usr.bin/indent/psym_switch_expr.c | 14 +++++
tests/usr.bin/indent/psym_while_expr.c | 14 +++++
52 files changed, 940 insertions(+), 4 deletions(-)
diffs (truncated from 1193 to 300 lines):
diff -r b6a2059acb17 -r 977e0f0a6b07 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Thu Nov 18 18:14:47 2021 +0000
+++ b/distrib/sets/lists/tests/mi Thu Nov 18 21:19:18 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1167 2021/11/18 18:14:47 rillig Exp $
+# $NetBSD: mi,v 1.1168 2021/11/18 21:19:18 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4797,6 +4797,41 @@
./usr/tests/usr.bin/indent/lineno.0.stdout tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/list_head.0 tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/list_head.0.stdout tests-obsolete obsolete,atf
+./usr/tests/usr.bin/indent/lsym_binary_op.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_case_label.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_colon.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_comma.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_comment.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_do.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_else.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_eof.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_for.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_form_feed.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_funcname.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_if.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_lbrace.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_lparen_or_lbracket.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_newline.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_offsetof.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_period.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_postfix_op.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_preprocessing.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_question.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_rbrace.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_return.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_rparen_or_rbracket.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_semicolon.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_sizeof.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_storage_class.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_string_prefix.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_switch.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_tag.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_type_in_parentheses.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_type_outside_parentheses.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_typedef.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_unary_op.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_while.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_word.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/ncs.0 tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/ncs.0.pro tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/ncs.0.stdout tests-obsolete obsolete,atf
@@ -5068,6 +5103,21 @@
./usr/tests/usr.bin/indent/ps_ind_level.0.pro tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/ps_ind_level.0.stdout tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/ps_ind_level.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_decl.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_do.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_do_stmt.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_else.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_for_exprs.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_if_expr.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_if_expr_stmt.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_if_expr_stmt_else.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_lbrace.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_rbrace.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_semicolon.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_stmt.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_stmt_list.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_switch_expr.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_while_expr.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/struct.0 tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/struct.0.stdout tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/surplusbad.0 tests-obsolete obsolete,atf
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile Thu Nov 18 18:14:47 2021 +0000
+++ b/tests/usr.bin/indent/Makefile Thu Nov 18 21:19:18 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.33 2021/10/23 21:45:14 rillig Exp $
+# $NetBSD: Makefile,v 1.34 2021/11/18 21:19:19 rillig Exp $
.include <bsd.own.mk>
@@ -8,15 +8,50 @@
TESTS_SH+= t_options
FILESDIR= ${TESTSDIR}
-FILES= fmt_block.c
+FILES+= fmt_block.c
FILES+= fmt_decl.c
FILES+= fmt_else_comment.c
FILES+= fmt_expr.c
FILES+= indent_off_on.c
FILES+= label.c
+FILES+= lex_char.c
FILES+= lex_ident.c
-FILES+= lex_char.c
FILES+= lex_string.c
+FILES+= lsym_binary_op.c
+FILES+= lsym_case_label.c
+FILES+= lsym_colon.c
+FILES+= lsym_comma.c
+FILES+= lsym_comment.c
+FILES+= lsym_do.c
+FILES+= lsym_else.c
+FILES+= lsym_eof.c
+FILES+= lsym_for.c
+FILES+= lsym_form_feed.c
+FILES+= lsym_funcname.c
+FILES+= lsym_if.c
+FILES+= lsym_lbrace.c
+FILES+= lsym_lparen_or_lbracket.c
+FILES+= lsym_newline.c
+FILES+= lsym_offsetof.c
+FILES+= lsym_period.c
+FILES+= lsym_postfix_op.c
+FILES+= lsym_preprocessing.c
+FILES+= lsym_question.c
+FILES+= lsym_rbrace.c
+FILES+= lsym_return.c
+FILES+= lsym_rparen_or_rbracket.c
+FILES+= lsym_semicolon.c
+FILES+= lsym_sizeof.c
+FILES+= lsym_storage_class.c
+FILES+= lsym_string_prefix.c
+FILES+= lsym_switch.c
+FILES+= lsym_tag.c
+FILES+= lsym_type_in_parentheses.c
+FILES+= lsym_type_outside_parentheses.c
+FILES+= lsym_typedef.c
+FILES+= lsym_unary_op.c
+FILES+= lsym_while.c
+FILES+= lsym_word.c
FILES+= opt_P.c
FILES+= opt_T.c
FILES+= opt_bacc.c
@@ -60,6 +95,21 @@
FILES+= opt_v.c
FILES+= opt_version.c
FILES+= ps_ind_level.c
+FILES+= psym_decl.c
+FILES+= psym_do.c
+FILES+= psym_do_stmt.c
+FILES+= psym_else.c
+FILES+= psym_for_exprs.c
+FILES+= psym_if_expr.c
+FILES+= psym_if_expr_stmt.c
+FILES+= psym_if_expr_stmt_else.c
+FILES+= psym_lbrace.c
+FILES+= psym_rbrace.c
+FILES+= psym_semicolon.c
+FILES+= psym_stmt.c
+FILES+= psym_stmt_list.c
+FILES+= psym_switch_expr.c
+FILES+= psym_while_expr.c
FILES+= t_options.awk
FILES+= token_binary_op.c
FILES+= token_case_label.c
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_binary_op.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_binary_op.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,29 @@
+/* $NetBSD: lsym_binary_op.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the token lsym_binary_op, which represents a binary operator in
+ * an expression. Examples for binary operators are '>>', '=', '+', '&&'.
+ *
+ * Binary operators are surrounded by blanks.
+ *
+ * Some tokens like '+', '*' or '&' can be either binary or unary operators,
+ * with an entirely different meaning.
+ *
+ * The token '*' is not only a binary or a unary operator, it is used in types
+ * as well, to derive a pointer type.
+ *
+ * See also:
+ * lsym_postfix_op.c for postfix unary operators
+ * lsym_unary_op.c for prefix unary operators
+ * lsym_colon.c for ':'
+ * lsym_question.c for '?'
+ * lsym_comma.c for ','
+ * C99 6.4.6 "Punctuators"
+ */
+
+#indent input
+// TODO: add input
+#indent end
+
+#indent run-equals-input
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_case_label.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_case_label.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,22 @@
+/* $NetBSD: lsym_case_label.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the token lsym_case_label, which represents either the keyword
+ * 'case' or the keyword 'default', which are both used in 'switch'
+ * statements.
+ *
+ * Since C11, the keyword 'default' is used in _Generic selections as well.
+ *
+ * See also:
+ * psym_switch_expr.c
+ * C11 6.5.1.1 "Generic selection"
+ */
+
+// TODO: test C11 _Generic
+
+#indent input
+// TODO: add input
+#indent end
+
+#indent run-equals-input
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_colon.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_colon.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,20 @@
+/* $NetBSD: lsym_colon.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the token lsym_colon, which represents a ':' in these contexts:
+ *
+ * After a label that is the target of a 'goto' statement.
+ *
+ * In a 'switch' statement, after a 'case' label or a 'default' label.
+ *
+ * As part of the conditional operator '?:'.
+ *
+ * In the declaration of a struct member that is a bit-field.
+ */
+
+#indent input
+// TODO: add input
+#indent end
+
+#indent run-equals-input
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_comma.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_comma.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,29 @@
+/* $NetBSD: lsym_comma.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the token lsym_comma, which represents a ',' in these contexts:
+ *
+ * In an expression, the binary operator ',' evaluates its left operand before
+ * its right operand, inserting a sequence point.
+ *
+ * In a parameter list of a function type, a ',' separates the parameter
+ * declarations.
+ *
+ * In a traditional function definition, a ',' separates the parameter names.
+ *
+ * In a prototype function definition, a ',' separates the parameter
+ * declarations.
+ *
+ * In a function call expression, a ',' separates the arguments.
+ *
+ * In a macro definition, a ',' separates the parameter names.
+ *
+ * In a macro invocation, a ',' separates the arguments.
+ */
+
+#indent input
+// TODO: add input
+#indent end
+
+#indent run-equals-input
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_comment.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_comment.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,19 @@
+/* $NetBSD: lsym_comment.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the token lsym_comment, which starts a comment.
+ *
+ * C11 distinguishes block comments and end-of-line comments. Indent further
+ * distinguishes box comments that are a special kind of block comments.
+ *
+ * See also:
+ * opt_fc1.c
+ * token_comment.c
+ */
+
+#indent input
+// TODO: add input
+#indent end
+
+#indent run-equals-input
diff -r b6a2059acb17 -r 977e0f0a6b07 tests/usr.bin/indent/lsym_do.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/lsym_do.c Thu Nov 18 21:19:18 2021 +0000
@@ -0,0 +1,19 @@
Home |
Main Index |
Thread Index |
Old Index