v2 / vlib / v / tests / last_stmt_semicolon_or_expr_test.v
21 lines · 18 sloc · 322 bytes · 949abb25bfd897a59d6d54f733f3f3be8d2b5f77
Raw
1fn foo() !int {
2 return 0
3}
4
5fn test_main() {
6 mut x := 1
7 // vfmt off
8 x = foo() or { panic("failed"); }
9 // vfmt on
10 println('x=${x}')
11}
12
13fn return_zero_with_trailing_semicolon() int {
14 // vfmt off
15 return 0;
16 // vfmt on
17}
18
19fn test_return_with_trailing_semicolon() {
20 assert return_zero_with_trailing_semicolon() == 0
21}
22