1 /* $NetBSD: lsym_question.c,v 1.5 2023/05/15 10:13:40 rillig Exp $ */ 2 3 /* 4 * Tests for the token lsym_question, which represents the '?' in a '?:' 5 * conditional expression. 6 */ 7 8 //indent input 9 const char *result = cond ? "then" : "else"; 10 11 const char *multi = cond1 ? "cond1" : cond2 ? "cond2" : cond3 ? "cond3" : ""; 12 //indent end 13 14 //indent run-equals-input -di0 15 16 17 /* 18 * To make them easier to read, conditional expressions can be split into 19 * multiple lines. 20 */ 21 //indent input 22 const char *separate_lines = cond 23 ? "then" 24 : "else"; 25 //indent end 26 27 //indent run -di0 28 const char *separate_lines = cond 29 // $ XXX: Continuation lines in expressions should be indented, even in column 1. 30 ? "then" 31 : "else"; 32 //indent end 33 34 35 /* 36 * In functions, conditional expressions are indented as intended. 37 */ 38 //indent input 39 void 40 function(void) 41 { 42 return cond 43 ? "then" 44 : "else"; 45 } 46 //indent end 47 48 //indent run-equals-input 49 50 51 /* 52 * In functions, conditional expressions are indented as intended. 53 */ 54 //indent input 55 void 56 function(void) 57 { 58 const char *branch = cond 59 ? "then" 60 : "else"; 61 62 const char *multiple_branches = cond1 63 ? "then 1" 64 : cond2 65 ? "then 2" 66 : "else"; 67 68 const char *condensed = cond1 ? "condensed 1" 69 : cond2 ? "condensed 2" 70 : "condensed else"; 71 } 72 //indent end 73 74 //indent run-equals-input -di0 75