v2 / vlib / v / tests / debugger_reserved_arg_name_test.v
29 lines · 28 sloc · 800 bytes · c10f5639b29f29b8cf3ec1c3d8bb1dc378c06f37
Raw
1import os
2
3fn test_dbg_compiles_with_reserved_function_argument_name() {
4 pid := os.getpid()
5 source_path := os.join_path(os.vtmp_dir(), 'v_issue_26746_debugger_reserved_arg_name_${pid}.v')
6 exe_path := os.join_path(os.vtmp_dir(), 'v_issue_26746_debugger_reserved_arg_name_${pid}.exe')
7 source := [
8 'pub fn bad_function(array []u8) u8 {',
9 r' $dbg',
10 ' return array[0]',
11 '}',
12 '',
13 'fn main() {',
14 ' _ = bad_function([u8(1)])',
15 '}',
16 ].join_lines()
17 os.write_file(source_path, source)!
18 defer {
19 os.rm(source_path) or {}
20 os.rm(exe_path) or {}
21 }
22 cmd := '${os.quoted_path(@VEXE)} -o ${os.quoted_path(exe_path)} ${os.quoted_path(source_path)}'
23 res := os.execute(cmd)
24 if res.exit_code != 0 {
25 eprintln('> failed command: ${cmd}')
26 eprintln(res.output)
27 }
28 assert res.exit_code == 0
29}
30