aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/v/fmt/tests/empty_lines_keep.vv
blob: 7e22486423dd38f7d9fabf92030c7364e1c158d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Keep empty lines between types
type Expr = IfExpr | IntegerLiteral

type Node2 = Expr | string
type MyInt = int

// Keep empty lines in const blocks
const (
	_ = SomeStruct{
		val: 'Multiline field exprs should cause no problems'
	}
	_ = 1

	_ = 'Keep this empty line before'
	// Comment before a field
	_ = 2

	// The empty line above should stay too
	_ = 3

	// This comment doesn't really belong anywhere

	_ = 'A multiline string with a StringInterLiteral...
	$foo
	...and the ending brace on a newline had a wrong pos.last_line.
	'
	_ = 4
)

fn keep_single_empty_line() {
	println('a')
	println('b')

	println('c')

	d := 0

	if true {
		println('e')
	}

	f := 0
	arr << MyStruct{}

	arr2 := [1, 2]
}

fn prevent_empty_line_after_multi_line_statements() {
	// line1
	/*
	block1
	*/
	/*
	block2
	*/
	if test {
		println('a')
	}
	println('b')
	for test {
		println('c')
	}
	c := fn (s string) {
		println('s')
	}
}

fn between_orm_blocks() {
	sql db {
		insert upper_1 into Upper
	}

	upper_s := sql db {
		select from Upper where id == 1
	}
}

fn no_empty_lines() {
	_ := $embed_file('testy.v')
	mut files := map[string][]FileData{}
	code := 'foo
bar'
	params[0] = IfExpr{
		...params[0]
		typ: params[0].typ.set_nr_muls(1)
	}
	env_value = environ()[env_lit] or {
		return error('the environment variable "$env_lit" does not exist.')
	}
	assert '$mr_one_two()' == "(One{
    value: 'one'
}, Two{
    value: 'two'
})"
	r := m[key] ?
	compile_time_env := $env('ENV_VAR')
	func()
}