Up to [cvs.NetBSD.org] / src / tests / usr.bin / indent
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
tests/indent: consolidate tests for comments These tests have been the motivation for t_options.sh, which allows to run indent with various command line options on the same input, without having to create 3 files per test case. A test file actually contains several tests, all separated by '#indent' directives. Isolating each of these tests is simpler than having to pick up the corresponding sections from 3 separate files. Running indent on each small test case isolates the test cases from each other, preventing them to influence later test cases. Exactly this had happened when support for C99 comments was added in March 2021, which later turned out to be done wrong.
indent: fix formatting of C99 comments The first attempt at formatting C99 comments was conceptually wrong. It accessed the next token in dump_line, even though that function should only ever look at the buffers for the label, the code and the current comment. (Understanding that part of the code was difficult at that time due to the sheer number of global variables.) The complicated and ever-growing condition for whether to output the token was a hack and in retrospect doesn't make sense at all, that's why it only came close to the intended effect. Some unintended side effects were that the C99 comments had an additional space in front of them, and that in some cases an empty line followed the comment, and that the comments were not aligned. Previously, the newline that terminates the C99 comment was included in the comment. Separating the newline from the comment fixed all these unintended side effects. The only downside is that the multi-line statement is not indented, but that should be easy to fix.
tests/indent: add more tests with ')(', found bug in '//'
indent: fix token duplication after C99 comment The code that keeps blank lines after C99 comments still looks wrong, but at least it's better than before.
tests/indent: demonstrate token repetition after line-end comment
tests/indent: demonstrate stray empty line at end-of-file
indent: fix handling of '//' end-of-line comments
tests/indent: allow for comments in either the input or output files
tests/indent: extend test for '//' comments with more examples
indent: add test demonstrating that indent cannot handle C99 indent cannot handle line-end comments. The indent test suite requires each test file to have both a NetBSD and a FreeBSD RCS ID. If the FreeBSD RCS ID is missing, the test will silently pass since in that case, an empty file is compared with an empty file. See the /start/,/end/ operator in t_indent.sh.