v4 / vlib / v3 / tests / unknown_fn_error_test.v
21 lines · 18 sloc · 862 bytes · 6c4d26f1f98c5464b012a375667ab345e462f7e0
Raw
1import os
2
3const vexe = @VEXE
4const tests_dir = os.dir(@FILE)
5const v3_dir = os.dir(tests_dir)
6const v3_src = os.join_path(v3_dir, 'v3.v')
7
8// test_unknown_function_stops_in_type_checker validates this v3 regression case.
9fn test_unknown_function_stops_in_type_checker() {
10 v3_bin := os.join_path(os.temp_dir(), 'v3_unknown_fn_error_test')
11 build := os.execute('${vexe} -o ${v3_bin} ${v3_src}')
12 assert build.exit_code == 0
13
14 bad_src := os.join_path(os.temp_dir(), 'v3_unknown_fn_error_input.v')
15 os.write_file(bad_src, 'fn main() {\n\tx := missing_fn()\n\tprintln(x)\n}\n')!
16 bad_bin := os.join_path(os.temp_dir(), 'v3_unknown_fn_error_input')
17 result := os.execute('${v3_bin} ${bad_src} -b c -o ${bad_bin}')
18 assert result.exit_code != 0
19 assert result.output.contains('unknown function `missing_fn`')
20 assert !result.output.contains('C compilation failed')
21}
22