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.
This commit is contained in:
parent
f229892ff8
commit
19176aa25f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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. */
|
|
@ -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 */
|
|
@ -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. */
|
|
@ -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
|
Loading…
Reference in New Issue