v/vlib/v/fmt/tests/comments_array_keep.vv

80 lines
1.2 KiB
V
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

fn main() {
_ := [
// pre comment
6,
// and after
]
_ := [
7,
// below expr
]
_ := [
8, /* I don't know why this still is a block comment */
9,
]
arr := [
// test 0
1,
// test 1
2,
// test 2
3, /* 3 */
4, /* 4-1 */ /* 4-2 */
]
}
fn only_comments_array() {
_ := [/* on a single line */ /* too */]
_ := [
// 1,
// 2,
// 3,
]
_ := [
/* whatever */ /* this is */ // 3,
// 4,
]
}
fn single_line_array_pre_comments() {
_ := [/* 2, */ 3]
_ := [/* 4, */ /* 5, */ 6]
_ := [/* cmt */ -4]
}
fn single_line_array_iembed_comments() {
_ := [1, /* betw single line */ 2]
// This caused a bug where the ´-´ was parsed as InfixExpr and not as part of an IntegerLiteral
_ := [1, /* cmt */ -4]
}
fn mixed_comments() {
_ := [
3 /* iembed */,
// keep line comment here
// and here
5,
]
}
fn keep_real_block_comment() {
_ := [
'foo',
/*
'bar',
'baz',
'spam',
*/
'eggs',
]
}
fn comment_at_line_start_with_expressions_after() {
arr := [123456789012345, 234567890123456, 678901234567890, 789012345678901, /* at the end */
345678901234567, /* in between */ 456789012345678,
/* line start */ 567890123456789, 890123456789012]
arr2 := [/* same line pre comment */ Foo{
a: 123
}]
}