Module Name:    src
Committed By:   rillig
Date:           Mon Oct 18 18:10:20 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/indent: Makefile t_options.sh
Added Files:
        src/tests/usr.bin/indent: token_ident.c
Removed Files:
        src/tests/usr.bin/indent: binary.0 binary.0.stdout cs.0 cs.0.pro
            cs.0.stdout float.0 float.0.stdout token-ident.0 token-ident.0.pro
            token-ident.0.stdout

Log Message:
tests/indent: merge tests for numbers into token_ident

The previous tests 'binary' and 'float' not only test binary and
floating point numbers, making their names too specific. Move them into
a new test token_ident that covers all "identifier-like" tokens, just as
in the code.

The test cases for the option '-cs' are already covered more
systematically in opt_cs.c, so remove that test.


To generate a diff of this commit:
cvs rdiff -u -r1.1141 -r1.1142 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/binary.0 \
    src/tests/usr.bin/indent/binary.0.stdout src/tests/usr.bin/indent/cs.0 \
    src/tests/usr.bin/indent/cs.0.pro src/tests/usr.bin/indent/cs.0.stdout \
    src/tests/usr.bin/indent/float.0 src/tests/usr.bin/indent/float.0.stdout \
    src/tests/usr.bin/indent/token-ident.0 \
    src/tests/usr.bin/indent/token-ident.0.pro \
    src/tests/usr.bin/indent/token-ident.0.stdout
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/t_options.sh
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/token_ident.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1141 src/distrib/sets/lists/tests/mi:1.1142
--- src/distrib/sets/lists/tests/mi:1.1141	Sat Oct 16 09:17:21 2021
+++ src/distrib/sets/lists/tests/mi	Mon Oct 18 18:10:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1141 2021/10/16 09:17:21 rillig Exp $
+# $NetBSD: mi,v 1.1142 2021/10/18 18:10:19 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4730,8 +4730,8 @@
 ./usr/tests/usr.bin/indent				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/Atffile					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/Kyuafile					tests-usr.bin-tests	compattestfile,atf,kyua
-./usr/tests/usr.bin/indent/binary.0					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/binary.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/binary.0					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/binary.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/block.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/block.0.stdout				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/comment-line-end.0				tests-usr.bin-tests	compattestfile,atf
@@ -4739,9 +4739,9 @@
 ./usr/tests/usr.bin/indent/comments.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/comments.0.pro				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/comments.0.stdout				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/cs.0						tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/cs.0.pro					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/cs.0.stdout					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/cs.0						tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/cs.0.pro					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/cs.0.stdout					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/declarations.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/declarations.0.stderr			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/declarations.0.stdout			tests-usr.bin-tests	compattestfile,atf
@@ -4750,8 +4750,8 @@
 ./usr/tests/usr.bin/indent/elsecomment.0.stdout				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/f_decls.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/f_decls.0.stdout				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/float.0					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/float.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/float.0					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/float.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/indent_variables.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.pro			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.stdout			tests-usr.bin-tests	compattestfile,atf
@@ -5067,9 +5067,9 @@
 ./usr/tests/usr.bin/indent/token-funcname.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-funcname.0.pro				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-funcname.0.stdout			tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token-ident.0				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token-ident.0.pro				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/token-ident.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token-ident.0				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/token-ident.0.pro				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/token-ident.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token-if_expr.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-if_expr.0.pro				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-if_expr.0.stdout			tests-usr.bin-tests	compattestfile,atf
@@ -5148,6 +5148,7 @@
 ./usr/tests/usr.bin/indent/token-while_expr.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.pro			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.stdout			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_ident.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0.list			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0.pro			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.16 src/tests/usr.bin/indent/Makefile:1.17
--- src/tests/usr.bin/indent/Makefile:1.16	Sat Oct 16 03:20:12 2021
+++ src/tests/usr.bin/indent/Makefile	Mon Oct 18 18:10:20 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2021/10/16 03:20:12 rillig Exp $
+#	$NetBSD: Makefile,v 1.17 2021/10/18 18:10:20 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -9,9 +9,7 @@ TESTS_SH+=	t_misc
 TESTS_SH+=	t_options
 
 FILESDIR=	${TESTSDIR}
-FILES=		binary.0
-FILES+=		binary.0.stdout
-FILES+=		block.0
+FILES=		block.0
 FILES+=		block.0.stdout
 FILES+=		comment-line-end.0
 FILES+=		comment-line-end.0.stdout
@@ -26,8 +24,6 @@ FILES+=		elsecomment.0.stdout
 FILES+=		elsecomment.0.pro
 FILES+=		f_decls.0
 FILES+=		f_decls.0.stdout
-FILES+=		float.0
-FILES+=		float.0.stdout
 FILES+=		indent_variables.0
 FILES+=		indent_variables.0.pro
 FILES+=		indent_variables.0.stdout
@@ -151,9 +147,6 @@ FILES+=		pcs.0.pro
 FILES+=		ps_ind_level.0
 FILES+=		ps_ind_level.0.pro
 FILES+=		ps_ind_level.0.stdout
-FILES+=		cs.0
-FILES+=		cs.0.stdout
-FILES+=		cs.0.pro
 FILES+=		struct.0
 FILES+=		struct.0.stdout
 FILES+=		surplusbad.0
@@ -192,9 +185,6 @@ FILES+=		token-form_feed.0.stdout
 FILES+=		token-funcname.0
 FILES+=		token-funcname.0.pro
 FILES+=		token-funcname.0.stdout
-FILES+=		token-ident.0
-FILES+=		token-ident.0.pro
-FILES+=		token-ident.0.stdout
 FILES+=		token-if_expr.0
 FILES+=		token-if_expr.0.pro
 FILES+=		token-if_expr.0.stdout
@@ -273,6 +263,7 @@ FILES+=		token-unary_op.0.stdout
 FILES+=		token-while_expr.0
 FILES+=		token-while_expr.0.pro
 FILES+=		token-while_expr.0.stdout
+FILES+=		token_ident.c
 FILES+=		types_from_file.0
 FILES+=		types_from_file.0.stdout
 FILES+=		types_from_file.0.list

Index: src/tests/usr.bin/indent/t_options.sh
diff -u src/tests/usr.bin/indent/t_options.sh:1.5 src/tests/usr.bin/indent/t_options.sh:1.6
--- src/tests/usr.bin/indent/t_options.sh:1.5	Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/t_options.sh	Mon Oct 18 18:10:20 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_options.sh,v 1.5 2021/10/18 07:11:31 rillig Exp $
+# $NetBSD: t_options.sh,v 1.6 2021/10/18 18:10:20 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -185,7 +185,7 @@ check()
 
 atf_init_test_cases()
 {
-	for fname in "$srcdir"/opt_*.c; do
+	for fname in "$srcdir"/*.c; do
 		test_name=${fname##*/}
 		test_name=${test_name%.c}
 

Added files:

Index: src/tests/usr.bin/indent/token_ident.c
diff -u /dev/null src/tests/usr.bin/indent/token_ident.c:1.1
--- /dev/null	Mon Oct 18 18:10:20 2021
+++ src/tests/usr.bin/indent/token_ident.c	Mon Oct 18 18:10:20 2021
@@ -0,0 +1,64 @@
+/* $NetBSD: token_ident.c,v 1.1 2021/10/18 18:10:20 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for identifiers, numbers and string literals.
+ */
+
+/* TODO: Add more systematic tests. */
+/* TODO: Completely cover each state transition in lex_number_state. */
+
+/* Binary number literals, a GCC extension that was added in C11. */
+#indent input
+#define b00101010 -1
+void t(void) {
+	unsigned a[] = {0b00101010, 0x00005678, 02, 17U};
+	float x[] = {.7f, 0.7f};
+	unsigned long ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
+
+	if (0 b00101010)
+		return;
+	/* $ '0r' is not a number base prefix, so the tokens are split. */
+	if (0r12345)
+		return;
+}
+#indent end
+
+#indent run
+#define b00101010 -1
+void
+t(void)
+{
+	unsigned	a[] = {0b00101010, 0x00005678, 02, 17U};
+	float		x[] = {.7f, 0.7f};
+	unsigned long	ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
+
+	if (0 b00101010)
+		return;
+	if (0 r12345)
+		return;
+}
+#indent end
+
+/* Floating point numbers. */
+#indent input
+void t(void) {
+	unsigned long x = 314UL;
+	double y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
+	int z = 0b0101;
+	DO_NOTHING;
+	x._y = 5;
+}
+#indent end
+
+#indent run
+void
+t(void)
+{
+	unsigned long	x = 314UL;
+	double		y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
+	int		z = 0b0101;
+	DO_NOTHING;
+	x._y = 5;
+}
+#indent end

Reply via email to