v2 / vlib / v / tests / fns / multiline_fn_signature_omitted_comma_test.v
13 lines · 12 sloc · 766 bytes · 80538516b34a0d2a254b56b1d306e6f3af9187c4
Raw
1import os
2
3fn test_multiline_fn_signature_can_omit_commas() {
4 source_path := os.join_path(os.vtmp_dir(),
5 'issue_22021_multiline_fn_signature_${os.getpid()}.v')
6 source := "fn multiline_greet(\n\tsalutation string\n\tname string\n) string {\n\treturn 'Hey, ' + salutation + ' ' + name + '!'\n}\n\nfn main() {\n\tassert multiline_greet(\n\t\t'Mr.'\n\t\t'Joe'\n\t) == 'Hey, Mr. Joe!'\n\tgreeter := fn (salutation string\n\t\tname string) string {\n\t\treturn 'Hello, ' + salutation + ' ' + name + '!'\n\t}\n\tassert greeter('Ms.', 'Jane') == 'Hello, Ms. Jane!'\n}\n"
7 os.write_file(source_path, source)!
8 defer {
9 os.rm(source_path) or {}
10 }
11 res := os.execute('${os.quoted_path(@VEXE)} run ${os.quoted_path(source_path)}')
12 assert res.exit_code == 0, res.output
13}
14