xref: /netbsd-src/tests/usr.bin/indent/lsym_while.c (revision e914aa7b64febc5304e99be7f921a14dbe6ae4db)
1 /* $NetBSD: lsym_while.c,v 1.7 2025/01/03 23:37:18 rillig Exp $ */
2 
3 /*
4  * Tests for the token 'lsym_while', which represents the keyword 'while' that
5  * starts a 'while' loop or finishes a 'do-while' loop.
6  */
7 
8 //indent input
9 void
10 function(void)
11 {
12 	while(cond)stmt();
13 	do stmt();while(cond);
14 }
15 //indent end
16 
17 //indent run
18 void
19 function(void)
20 {
21 	while (cond)
22 		stmt();
23 	do
24 		stmt();
25 	while (cond);
26 }
27 //indent end
28 
29 
30 /*
31  * The keyword 'while' must only be indented if it follows a psym_do_stmt,
32  * otherwise it starts a new statement and must start a new line.
33  */
34 //indent input
35 void
36 function(void)
37 {
38 	{} while (0);
39 }
40 //indent end
41 
42 //indent run
43 void
44 function(void)
45 {
46 	{
47 	}
48 	while (0)
49 		;
50 }
51 //indent end
52