mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: array newlines test
This commit is contained in:
parent
85c5103ba3
commit
de9f302412
@ -482,11 +482,11 @@ fn (var f Fmt) expr(node ast.Expr) {
|
|||||||
f.wrap_long_line()
|
f.wrap_long_line()
|
||||||
}
|
}
|
||||||
f.expr(expr)
|
f.expr(expr)
|
||||||
if i < it.exprs.len - 1 {
|
|
||||||
f.write(', ')
|
|
||||||
}
|
|
||||||
if line_nr < pos.line_nr {
|
if line_nr < pos.line_nr {
|
||||||
|
// Previous element was on a different line, add a newline
|
||||||
f.writeln('')
|
f.writeln('')
|
||||||
|
} else if i < it.exprs.len - 1 {
|
||||||
|
f.write(', ')
|
||||||
}
|
}
|
||||||
line_nr = pos.line_nr
|
line_nr = pos.line_nr
|
||||||
}
|
}
|
||||||
|
12
vlib/v/fmt/tests/array_newlines_keep.vv
Normal file
12
vlib/v/fmt/tests/array_newlines_keep.vv
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fn make_flag(a, b, c string) string {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Set up flags
|
||||||
|
expected_flags := [
|
||||||
|
make_flag('solaris', '-L', '/opt/local/lib')
|
||||||
|
make_flag('darwin', '-framework', 'Cocoa')
|
||||||
|
make_flag('windows', '-l', 'gdi32')
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user