xref: /netbsd-src/tests/usr.bin/indent/lsym_if.c (revision bae713c4124d10a9f23dab086fa85b51eac28369)
1 /* $NetBSD: lsym_if.c,v 1.6 2023/06/10 18:46:42 rillig Exp $ */
2 
3 /*
4  * Tests for the token lsym_if, which represents the keyword 'if' that starts
5  * an 'if' or 'if-else' statement.
6  */
7 
8 //indent input
9 void
function(void)10 function(void)
11 {
12 	if(cond)stmt();
13 }
14 //indent end
15 
16 //indent run
17 void
function(void)18 function(void)
19 {
20 	if (cond)
21 		stmt();
22 }
23 //indent end
24 
25 
26 /*
27  * After an 'if' statement without an 'else' branch, braces start a separate
28  * block.
29  */
30 //indent input
31 {
32 	if(0)if(1)if(2)stmt();{}
33 }
34 //indent end
35 
36 //indent run
37 {
38 	if (0)
39 		if (1)
40 			if (2)
41 				stmt();
42 	{
43 	}
44 }
45 //indent end
46