tests/indent: move test for ':' to lsym_token.c

This commit is contained in:
rillig 2021-11-28 14:49:28 +00:00
parent af3ccc52b1
commit f8e8fcdaab
4 changed files with 91 additions and 80 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1169 2021/11/28 14:29:03 rillig Exp $
# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -5244,7 +5244,7 @@
./usr/tests/usr.bin/indent/token-while_expr.0.stdout tests-obsolete obsolete,atf
./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-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_comment.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/token_decl.c tests-usr.bin-tests compattestfile,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.35 2021/11/28 14:29:03 rillig Exp $
# $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $
.include <bsd.own.mk>
@ -112,7 +112,6 @@ FILES+= psym_while_expr.c
FILES+= t_options.awk
FILES+= token_binary_op.c
FILES+= token_case_label.c
FILES+= token_colon.c
FILES+= token_comma.c
FILES+= token_comment.c
FILES+= token_decl.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: lsym_colon.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
/* $NetBSD: lsym_colon.c,v 1.2 2021/11/28 14:49:28 rillig Exp $ */
/* $FreeBSD$ */
/*
@ -11,10 +11,96 @@
* As part of the conditional operator '?:'.
*
* In the declaration of a struct member that is a bit-field.
*
* See also:
* label.c
* lsym_question.c
*/
/*
* The ':' marks a label that can be used in a 'goto' statement.
*/
#indent input
// TODO: add input
void endless(void)
{
label1:
goto label2;
if (true)if (true)if (true)if (true)label2 :goto label1;
}
#indent end
#indent run
void
endless(void)
{
label1:
goto label2;
if (true)
if (true)
if (true)
if (true)
label2: goto label1;
}
#indent end
/*
* The ':' is used in a 'switch' statement, after a 'case' label or a
* 'default' label.
*/
#indent input
void
example(void)
{
switch (expr) {
case 'x':
return;
default:
return;
}
}
#indent end
#indent run-equals-input
/*
* The ':' is used as part of the conditional operator '?:'.
*/
#indent input
int constant_expression = true?4:12345;
#indent end
#indent run
int constant_expression = true ? 4 : 12345;
#indent end
/*
* The ':' is used in the declaration of a struct member that is a bit-field.
*/
#indent input
struct bit_field {
bool flag:1;
int maybe_signed : 4;
signed int definitely_signed:3;
signed int : 0;/* padding */
unsigned int definitely_unsigned:3;
unsigned int:0;/* padding */
};
#indent end
#indent run
struct bit_field {
bool flag:1;
int maybe_signed:4;
signed int definitely_signed:3;
/* $ XXX: Placing the colon directly at the type looks inconsistent. */
signed int: 0; /* padding */
unsigned int definitely_unsigned:3;
/* $ XXX: Placing the colon directly at the type looks inconsistent. */
unsigned int: 0; /* padding */
};
#indent end

View File

@ -1,74 +0,0 @@
/* $NetBSD: token_colon.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
* Tests for formatting of the colon token, which is used in the following
* contexts:
*
* After a label that is the target of a goto statement.
*
* In a switch statement, after a case label or the default label.
*
* As part of the conditional expression operator '?:'.
*
* In the declaration of a struct member that is a bit-field.
*/
#indent input
void endless(void)
{
label1:
goto label2;
if (true)if (true)if (true)if (true)label2 :goto label1;
}
#indent end
#indent run
void
endless(void)
{
label1:
goto label2;
if (true)
if (true)
if (true)
if (true)
label2: goto label1;
}
#indent end
#indent input
int constant_expression = true?4:12345;
#indent end
#indent run
int constant_expression = true ? 4 : 12345;
#indent end
#indent input
struct bit_field {
bool flag:1;
int maybe_signed : 4;
signed int definitely_signed:3;
signed int : 0;/* finish the storage unit for the bit-field */
unsigned int definitely_unsigned:3;
unsigned int:0;/* finish the storage unit for the bit-field */
};
#indent end
#indent run
struct bit_field {
bool flag:1;
int maybe_signed:4;
signed int definitely_signed:3;
/* $ XXX: Placing the colon directly at the type looks inconsistent. */
signed int: 0; /* finish the storage unit for the bit-field */
unsigned int definitely_unsigned:3;
/* $ XXX: Placing the colon directly at the type looks inconsistent. */
unsigned int: 0; /* finish the storage unit for the bit-field */
};
#indent end