tests/indent: migrate a few token tests to psym tests
This commit is contained in:
parent
42e25676fd
commit
c91f4bf8dd
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1194 2022/04/20 07:41:04 blymn Exp $
|
||||
# $NetBSD: mi,v 1.1195 2022/04/23 09:01:03 rillig Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -5265,9 +5265,9 @@
|
|||
./usr/tests/usr.bin/indent/token_form_feed.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_funcname.c 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/token_if_expr.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_if_expr_stmt.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_if_expr_stmt_else.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_if_expr.c tests-obsolete obsolete,atf
|
||||
./usr/tests/usr.bin/indent/token_if_expr_stmt.c tests-obsolete obsolete,atf
|
||||
./usr/tests/usr.bin/indent/token_if_expr_stmt_else.c tests-obsolete obsolete,atf
|
||||
./usr/tests/usr.bin/indent/token_keyword_do.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_keyword_do_else.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/indent/token_keyword_else.c tests-usr.bin-tests compattestfile,atf
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.40 2022/04/22 21:21:20 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.41 2022/04/23 09:01:03 rillig Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -119,9 +119,6 @@ FILES+= token_for_exprs.c
|
|||
FILES+= token_form_feed.c
|
||||
FILES+= token_funcname.c
|
||||
FILES+= token_ident.c
|
||||
FILES+= token_if_expr.c
|
||||
FILES+= token_if_expr_stmt.c
|
||||
FILES+= token_if_expr_stmt_else.c
|
||||
FILES+= token_keyword_do.c
|
||||
FILES+= token_keyword_do_else.c
|
||||
FILES+= token_keyword_else.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: psym_if_expr.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
/* $NetBSD: psym_if_expr.c,v 1.3 2022/04/23 09:01:03 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for the parser symbol psym_if_expr, representing the parser state
|
||||
|
@ -7,7 +7,16 @@
|
|||
*/
|
||||
|
||||
#indent input
|
||||
// TODO: add input
|
||||
void function(void) {
|
||||
if(cond) stmt();
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run-equals-input
|
||||
#indent run
|
||||
void
|
||||
function(void)
|
||||
{
|
||||
if (cond)
|
||||
stmt();
|
||||
}
|
||||
#indent end
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
/* $NetBSD: psym_if_expr_stmt.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
/* $NetBSD: psym_if_expr_stmt.c,v 1.3 2022/04/23 09:01:03 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for the parser symbol psym_if_expr_stmt, which represents the state
|
||||
* after reading the keyword 'if', the controlling expression and the
|
||||
* statement for the 'then' branch. If the next token is 'else', another
|
||||
* statement will follow, otherwise the 'if' statement is finished already.
|
||||
* statement for the 'then' branch.
|
||||
*
|
||||
* At this point, the 'if' statement is not necessarily complete, it can be
|
||||
* completed with the keyword 'else' followed by a statement.
|
||||
*
|
||||
* Any token other than 'else' completes the 'if' statement.
|
||||
*/
|
||||
|
||||
#indent input
|
||||
// TODO: add input
|
||||
void
|
||||
function(void)
|
||||
{
|
||||
if (cond)
|
||||
stmt();
|
||||
if (cond)
|
||||
stmt();
|
||||
else /* belongs to the second 'if' */
|
||||
stmt();
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run-equals-input
|
||||
|
|
|
@ -1,15 +1,96 @@
|
|||
/* $NetBSD: psym_if_expr_stmt_else.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
/* $NetBSD: psym_if_expr_stmt_else.c,v 1.3 2022/04/23 09:01:03 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for the parser symbol psym_if_expr_stmt_else, which represents the
|
||||
* parser state after reading the keyword 'if', the controlling expression,
|
||||
* the statement of the 'then' branch and the keyword 'else'. If the next
|
||||
* token is an 'if', the formatting depends on the option '-ei' or '-nei'. In
|
||||
* all other situations, the next statement will finish the 'if' statement.
|
||||
* the statement of the 'then' branch and the keyword 'else'.
|
||||
*
|
||||
* If the next token is an 'if', the formatting depends on the option '-ei' or
|
||||
* '-nei'. Any other lookahead token completes the 'if' statement.
|
||||
*/
|
||||
|
||||
#indent input
|
||||
// TODO: add input
|
||||
void
|
||||
example(_Bool cond)
|
||||
{
|
||||
if (cond) {}
|
||||
else if (cond) {}
|
||||
else if (cond) i++;
|
||||
else {}
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run-equals-input
|
||||
#indent run
|
||||
void
|
||||
example(_Bool cond)
|
||||
{
|
||||
if (cond) {
|
||||
} else if (cond) {
|
||||
} else if (cond)
|
||||
i++;
|
||||
else {
|
||||
}
|
||||
}
|
||||
#indent end
|
||||
|
||||
/*
|
||||
* Combining the options '-bl' (place brace on the left margin) and '-ce'
|
||||
* (cuddle else) looks strange, but is technically correct.
|
||||
*/
|
||||
#indent run -bl
|
||||
void
|
||||
example(_Bool cond)
|
||||
{
|
||||
if (cond)
|
||||
{
|
||||
} else if (cond)
|
||||
{
|
||||
} else if (cond)
|
||||
i++;
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run -bl -nce
|
||||
void
|
||||
example(_Bool cond)
|
||||
{
|
||||
if (cond)
|
||||
{
|
||||
}
|
||||
else if (cond)
|
||||
{
|
||||
}
|
||||
else if (cond)
|
||||
i++;
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
#indent end
|
||||
|
||||
/*
|
||||
* Adding the option '-nei' (do not join 'else if') expands the code even
|
||||
* more.
|
||||
*/
|
||||
#indent run -bl -nce -nei
|
||||
void
|
||||
example(_Bool cond)
|
||||
{
|
||||
if (cond)
|
||||
{
|
||||
}
|
||||
else
|
||||
if (cond)
|
||||
{
|
||||
}
|
||||
else
|
||||
if (cond)
|
||||
i++;
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
#indent end
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/* $NetBSD: token_if_expr.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for 'if' followed by a parenthesized expression.
|
||||
*/
|
||||
|
||||
#indent input
|
||||
void function(void) {
|
||||
if(cond) stmt();
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run
|
||||
void
|
||||
function(void)
|
||||
{
|
||||
if (cond)
|
||||
stmt();
|
||||
}
|
||||
#indent end
|
|
@ -1,25 +0,0 @@
|
|||
/* $NetBSD: token_if_expr_stmt.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for 'if' followed by a parenthesized expression and a statement.
|
||||
*
|
||||
* At this point, the 'if' statement is not necessarily complete, it can be
|
||||
* completed with the keyword 'else' followed by a statement.
|
||||
*
|
||||
* Any token other than 'else' completes the 'if' statement.
|
||||
*/
|
||||
|
||||
#indent input
|
||||
void
|
||||
function(void)
|
||||
{
|
||||
if (cond)
|
||||
stmt();
|
||||
if (cond)
|
||||
stmt();
|
||||
else /* belongs to the second 'if' */
|
||||
stmt();
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run-equals-input
|
|
@ -1,21 +0,0 @@
|
|||
/* $NetBSD: token_if_expr_stmt_else.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for 'if' followed by a parenthesized expression, a statement and the
|
||||
* keyword 'else'.
|
||||
*
|
||||
* At this point, the statement needs to be completed with another statement.
|
||||
*/
|
||||
|
||||
#indent input
|
||||
void
|
||||
function(void)
|
||||
{
|
||||
if (cond)
|
||||
stmt();
|
||||
else
|
||||
stmt();
|
||||
}
|
||||
#indent end
|
||||
|
||||
#indent run-equals-input
|
Loading…
Reference in New Issue