Mon May 15 08:22:23 2023 UTC ()
tests/indent: demonstrate wrong spacing in for loops


(rillig)
diff -r1.4 -r1.5 src/tests/usr.bin/indent/psym_for_exprs.c

cvs diff -r1.4 -r1.5 src/tests/usr.bin/indent/psym_for_exprs.c (expand / switch to unified diff)

--- src/tests/usr.bin/indent/psym_for_exprs.c 2022/04/24 09:04:12 1.4
+++ src/tests/usr.bin/indent/psym_for_exprs.c 2023/05/15 08:22:23 1.5
@@ -1,29 +1,50 @@ @@ -1,29 +1,50 @@
1/* $NetBSD: psym_for_exprs.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */ 1/* $NetBSD: psym_for_exprs.c,v 1.5 2023/05/15 08:22:23 rillig Exp $ */
2 2
3/* 3/*
4 * Tests for the parser state psym_for_exprs, which represents the state after 4 * Tests for the parser state psym_for_exprs, which represents the state after
5 * reading the keyword 'for' and the 3 expressions, now waiting for the body 5 * reading the keyword 'for' and the 3 expressions, now waiting for the body
6 * of the loop. 6 * of the loop.
7 */ 7 */
8 8
9//indent input 9//indent input
10// TODO: add input 10void
 11for_loops(void)
 12{
 13 for (int i = 0; i < 10; i++)
 14 printf("%d * %d = %d\n", i, 7, i * 7);
 15
 16 for (int i = 0; i < 10; i++) {
 17 printf("%d * %d = %d\n", i, 7, i * 7);
 18 }
 19}
11//indent end 20//indent end
12 21
13//indent run-equals-input 22//indent run
 23void
 24for_loops(void)
 25{
 26 for (int i = 0; i < 10; i++)
 27 printf("%d * %d = %d\n", i, 7, i * 7);
 28
 29 /* $ FIXME: Add space between ')' and '{'. */
 30 for (int i = 0; i < 10; i++){
 31 printf("%d * %d = %d\n", i, 7, i * 7);
 32 }
 33}
 34//indent end
14 35
15 36
16/* 37/*
17 * Since C99, the first expression of a 'for' loop may be a declaration, not 38 * Since C99, the first expression of a 'for' loop may be a declaration, not
18 * only an expression. 39 * only an expression.
19 */ 40 */
20//indent input 41//indent input
21void 42void
22function(void) 43small_scope(void)
23{ 44{
24 for (int i = 0; i < 3; i++) 45 for (int i = 0; i < 3; i++)
25 stmt(); 46 stmt();
26} 47}
27//indent end 48//indent end
28 49
29//indent run-equals-input 50//indent run-equals-input