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: merge tests for numbers i...



details:   https://anonhg.NetBSD.org/src/rev/22fe99d8f42d
branches:  trunk
changeset: 1024320:22fe99d8f42d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Oct 18 18:10:19 2021 +0000

description:
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.

diffstat:

 distrib/sets/lists/tests/mi               |  23 +++++-----
 tests/usr.bin/indent/Makefile             |  15 +-----
 tests/usr.bin/indent/binary.0             |  11 -----
 tests/usr.bin/indent/binary.0.stdout      |  13 ------
 tests/usr.bin/indent/cs.0                 |   5 --
 tests/usr.bin/indent/cs.0.pro             |   3 -
 tests/usr.bin/indent/cs.0.stdout          |   7 ---
 tests/usr.bin/indent/float.0              |   9 ----
 tests/usr.bin/indent/float.0.stdout       |  11 -----
 tests/usr.bin/indent/t_options.sh         |   4 +-
 tests/usr.bin/indent/token-ident.0        |   8 ---
 tests/usr.bin/indent/token-ident.0.pro    |   8 ---
 tests/usr.bin/indent/token-ident.0.stdout |   8 ---
 tests/usr.bin/indent/token_ident.c        |  64 +++++++++++++++++++++++++++++++
 14 files changed, 81 insertions(+), 108 deletions(-)

diffs (truncated from 332 to 300 lines):

diff -r c1b46bd9ea6e -r 22fe99d8f42d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Oct 18 14:16:49 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Oct 18 18:10:19 2021 +0000
@@ -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
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Mon Oct 18 14:16:49 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Mon Oct 18 18:10:19 2021 +0000
@@ -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_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.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+=                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-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-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
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/binary.0
--- a/tests/usr.bin/indent/binary.0     Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*     $NetBSD: binary.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
-/* $FreeBSD: head/usr.bin/indent/tests/binary.0 318471 2017-05-18 17:15:58Z pstef $ */
-#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;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/binary.0.stdout
--- a/tests/usr.bin/indent/binary.0.stdout      Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*     $NetBSD: binary.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $  */
-/* $FreeBSD: head/usr.bin/indent/tests/binary.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
-#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;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/cs.0
--- a/tests/usr.bin/indent/cs.0 Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-/*     $NetBSD: cs.0,v 1.1 2019/04/04 15:27:35 kamil Exp $     */
-/* $FreeBSD: head/usr.bin/indent/tests/cs.0 334944 2018-06-11 05:35:57Z pstef $ */
-void t(void) {
-       int a = (double) 8;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/cs.0.pro
--- a/tests/usr.bin/indent/cs.0.pro     Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-/*     $NetBSD: cs.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
-/* $FreeBSD: head/usr.bin/indent/tests/cs.0.pro 334944 2018-06-11 05:35:57Z pstef $ */
--cs
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/cs.0.stdout
--- a/tests/usr.bin/indent/cs.0.stdout  Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-/*     $NetBSD: cs.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $      */
-/* $FreeBSD: head/usr.bin/indent/tests/cs.0.stdout 334944 2018-06-11 05:35:57Z pstef $ */
-void
-t(void)
-{
-       int             a = (double) 8;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/float.0
--- a/tests/usr.bin/indent/float.0      Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*     $NetBSD: float.0,v 1.1 2019/04/04 15:27:35 kamil Exp $  */
-/* $FreeBSD: head/usr.bin/indent/tests/float.0 337862 2018-08-15 18:19:45Z pstef $ */
-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;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/float.0.stdout
--- a/tests/usr.bin/indent/float.0.stdout       Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*     $NetBSD: float.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $   */
-/* $FreeBSD: head/usr.bin/indent/tests/float.0.stdout 337862 2018-08-15 18:19:45Z pstef $ */
-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;
-}
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/t_options.sh
--- a/tests/usr.bin/indent/t_options.sh Mon Oct 18 14:16:49 2021 +0000
+++ b/tests/usr.bin/indent/t_options.sh Mon Oct 18 18:10:19 2021 +0000
@@ -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 @@
 
 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}
 
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/token-ident.0
--- a/tests/usr.bin/indent/token-ident.0        Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-/* $NetBSD: token-ident.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tests for identifiers.
- */
-
-/* TODO: Add some code to be formatted. */
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/token-ident.0.pro
--- a/tests/usr.bin/indent/token-ident.0.pro    Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-/* $NetBSD: token-ident.0.pro,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * TODO: Explain the command line options of the test.
- */
-
-/* TODO: Add some command line options */
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/token-ident.0.stdout
--- a/tests/usr.bin/indent/token-ident.0.stdout Mon Oct 18 14:16:49 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-/* $NetBSD: token-ident.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tests for identifiers.
- */
-
-/* TODO: Add some code to be formatted. */
diff -r c1b46bd9ea6e -r 22fe99d8f42d tests/usr.bin/indent/token_ident.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/token_ident.c        Mon Oct 18 18:10:19 2021 +0000
@@ -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};



Home | Main Index | Thread Index | Old Index