v2 / vlib / v / fmt / tests / concat_expr_input.vv
22 lines · 20 sloc · 803 bytes · 75d85403a6b8d2143320da0824714a821a386879
Raw
1fn concatenation_of_strings() {
2_ := 'Simple' + 'Concat'
3 _ := 'Hello'
4 + ' ' +
5 'World' + '!'
6 _ := 'There' + ' ' + 'so' + ' ' + 'many' + ' ' + 'words' + ' ' + 'they' + ' ' + "don't" + ' ' + 'fit' + ' ' + 'in' + ' ' + 'one' + ' ' + 'line'
7}
8
9fn concat_inside_ternary() {
10 { // This block is needed to force line wrapping
11 cline := if iline == pos.line_nr {
12 sline[..start_column] + color(kind, sline[start_column..end_column]) + sline[end_column..]
13 } else {
14 sline
15 }
16 }
17}
18
19fn concat_two_or_more_ternaries() {
20 x := if some_condition { 'very long string part' } else { 'def' } + if y == 'asd' { 'qwe' } else {'something else'}
21 var := if other_condition { 'concat three long ternary ifs' } else { 'def' } + if true {'shorter'} else {'quite short'} + if true { 'small' } else {'tiny'}
22}
23