1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
Files
v/vlib/v/fmt/tests/comments_keep.vv

102 lines
1.3 KiB
V

import semver // as sv
enum Abc {
a
b // after a value
c
// between values
d
}
struct User {
name string // name
// middle comment
age int
// last comment
// last comment2
}
fn main() {
u := User{
name: 'Peter'
}
n := sizeof(User)
// else
// else {
// }
_ := User{
name: 'Henry' // comment after name
// on the next line
age: 42
// after age line
// after line2
}
_ := User{
// Just a comment
}
//////
// /
// 123
match 0 {
0 {
0 // comment after an expression inside match
}
else {}
}
}
fn assign_comments() {
a := 123 // comment after assign
b := 'foo' // also comment after assign
c := true
// Between two assigns
d := false
// at the end
}
fn linebreaks_in_ascii_art_block_comments() {
/*
+++
*/
/*****
+++
*****/
/****
+++
*/
/*
+++
****/
}
fn map_comments() {
mymap := {
// pre
`:`: 1
`!`: 2 // after
// and between
`%`: 3
// between
// between second
`$`: 4
`&`: 5
// post
}
}
fn ifs_comments_and_empty_lines() {
if true {
}
// some comment direct after an if without else
if false {
} else {
}
// some comment direct after an else
if false {
}
// this is parsed as post_comment of the if but does not really belong there
// thereore keep the empty line
something_else()
}