v2 / vlib / v / fmt / tests / concat_expr_expected.vv
24 lines · 22 sloc · 812 bytes · 75d85403a6b8d2143320da0824714a821a386879
Raw
1fn concatenation_of_strings() {
2 _ := 'Simple' + 'Concat'
3 _ := 'Hello' + ' ' + 'World' + '!'
4 _ := 'There' + ' ' + 'so' + ' ' + 'many' + ' ' + 'words' + ' ' + 'they' + ' ' + "don't" + ' ' +
5 'fit' + ' ' + 'in' + ' ' + 'one' + ' ' + 'line'
6}
7
8fn concat_inside_ternary() {
9 { // This block is needed to force line wrapping
10 cline := if iline == pos.line_nr {
11 sline[..start_column] + color(kind, sline[start_column..end_column]) +
12 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' } +
21 if y == 'asd' { 'qwe' } else { 'something else' }
22 var := if other_condition { 'concat three long ternary ifs' } else { 'def' } +
23 if true { 'shorter' } else { 'quite short' } + if true { 'small' } else { 'tiny' }
24}
25