Module Name: src Committed By: rillig Date: Sun Nov 28 16:20:13 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_question.c Removed Files: src/tests/usr.bin/indent: token_question.c Log Message: tests/indent: migrate token_question to lsym_question and extend it To generate a diff of this commit: cvs rdiff -u -r1.1172 -r1.1173 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_question.c cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/token_question.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.1172 src/distrib/sets/lists/tests/mi:1.1173 --- src/distrib/sets/lists/tests/mi:1.1172 Sun Nov 28 16:05:59 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1172 2021/11/28 16:05:59 rillig Exp $ +# $NetBSD: mi,v 1.1173 2021/11/28 16:20:13 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5268,7 +5268,7 @@ ./usr/tests/usr.bin/indent/token_period.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_postfix_op.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_preprocessing.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/token_question.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/token_question.c tests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_rbrace.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_rparen.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_semicolon.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.38 src/tests/usr.bin/indent/Makefile:1.39 --- src/tests/usr.bin/indent/Makefile:1.38 Sun Nov 28 16:05:59 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.38 2021/11/28 16:05:59 rillig Exp $ +# $NetBSD: Makefile,v 1.39 2021/11/28 16:20:13 rillig Exp $ .include <bsd.own.mk> @@ -133,7 +133,6 @@ FILES+= token_newline.c FILES+= token_period.c FILES+= token_postfix_op.c FILES+= token_preprocessing.c -FILES+= token_question.c FILES+= token_rbrace.c FILES+= token_rparen.c FILES+= token_semicolon.c Index: src/tests/usr.bin/indent/lsym_question.c diff -u src/tests/usr.bin/indent/lsym_question.c:1.1 src/tests/usr.bin/indent/lsym_question.c:1.2 --- src/tests/usr.bin/indent/lsym_question.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_question.c Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_question.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_question.c,v 1.2 2021/11/28 16:20:13 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -7,7 +7,62 @@ */ #indent input -// TODO: add input +const char *result = cond ? "then" : "else"; + +const char *multi = cond1 ? "cond1" : cond2 ? "cond2" : cond3 ? "cond3" : ""; +#indent end + +#indent run-equals-input -di0 + + +/* + * To make them easier to read, conditional expressions can be split into + * multiple lines. + */ +#indent input +const char *separate_lines = cond + ? "then" + : "else"; +#indent end + +#indent run -di0 +const char *separate_lines = cond +// $ XXX: Continuation lines in expressions should be indented, even in column 1. +? "then" +: "else"; +#indent end + + +/* + * In functions, conditional expressions are indented as intended. + */ +#indent input +void +function(void) +{ + return cond + ? "then" + : "else"; +} #indent end #indent run-equals-input + + +/* + * In functions, conditional expressions are indented as intended. + */ +#indent input +void +function(void) +{ + const char *branch = cond + // $ TODO: Indent these continuation lines as they are part of the + // $ TODO: initializer expression, not of the declarator part to the + // $ TODO: left of the '='. + ? "then" + : "else"; +} +#indent end + +#indent run-equals-input -di0