| 1 | // Keep empty lines between types |
| 2 | type Expr = IfExpr | IntegerLiteral |
| 3 | |
| 4 | type Node2 = Expr | string |
| 5 | type MyInt = int |
| 6 | |
| 7 | // Keep empty lines in const blocks |
| 8 | const _ = SomeStruct{ |
| 9 | val: 'Multiline field exprs should cause no problems' |
| 10 | } |
| 11 | const _ = 1 |
| 12 | |
| 13 | const _ = 'Keep this empty line before' |
| 14 | // Comment before a field |
| 15 | const _ = 2 |
| 16 | |
| 17 | // The empty line above should stay too |
| 18 | const _ = 3 |
| 19 | |
| 20 | // This comment doesn't really belong anywhere |
| 21 | |
| 22 | const _ = 'A multiline string with a StringInterLiteral... |
| 23 | ${foo} |
| 24 | ...and the ending brace on a newline had a wrong pos.last_line. |
| 25 | ' |
| 26 | const _ = 4 |
| 27 | |
| 28 | fn keep_single_empty_line() { |
| 29 | println('a') |
| 30 | println('b') |
| 31 | |
| 32 | println('c') |
| 33 | |
| 34 | dump('d') |
| 35 | |
| 36 | d := 0 |
| 37 | |
| 38 | if true { |
| 39 | println('e') |
| 40 | } |
| 41 | |
| 42 | dump('f') |
| 43 | f := 0 |
| 44 | arr << MyStruct{} |
| 45 | |
| 46 | arr2 := [1, 2] |
| 47 | } |
| 48 | |
| 49 | fn prevent_empty_line_after_multi_line_statements() { |
| 50 | // line1 |
| 51 | /* |
| 52 | block1 |
| 53 | */ |
| 54 | /* |
| 55 | block2 |
| 56 | */ |
| 57 | if test { |
| 58 | println('a') |
| 59 | } |
| 60 | println('b') |
| 61 | for test { |
| 62 | println('c') |
| 63 | } |
| 64 | c := fn (s string) { |
| 65 | println('s') |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | fn between_orm_blocks() { |
| 70 | sql db { |
| 71 | insert upper_1 into Upper |
| 72 | } |
| 73 | |
| 74 | upper_s := sql db { |
| 75 | select from Upper where id == 1 |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | fn no_empty_lines() { |
| 80 | _ := $embed_file('testy.v') |
| 81 | mut files := map[string][]FileData{} |
| 82 | code := 'foo |
| 83 | bar' |
| 84 | params[0] = IfExpr{ |
| 85 | ...params[0] |
| 86 | typ: params[0].typ.set_nr_muls(1) |
| 87 | } |
| 88 | env_value = environ()[env_lit] or { |
| 89 | return error('the environment variable "${env_lit}" does not exist.') |
| 90 | } |
| 91 | assert '${mr_one_two()}' == "(One{ |
| 92 | value: 'one' |
| 93 | }, Two{ |
| 94 | value: 'two' |
| 95 | })" |
| 96 | r := m[key]! |
| 97 | compile_time_env := $env('ENV_VAR') |
| 98 | func() |
| 99 | } |
| 100 | |