| 1 | import os |
| 2 | |
| 3 | const vexe = @VEXE |
| 4 | |
| 5 | fn test_match_expr_array_literal_compiles_with_g() { |
| 6 | test_dir := os.join_path(os.vtmp_dir(), 'match_expr_array_g_test_${os.getpid()}') |
| 7 | os.mkdir_all(test_dir)! |
| 8 | defer { |
| 9 | os.rmdir_all(test_dir) or {} |
| 10 | } |
| 11 | source := os.join_path(test_dir, 'test.v') |
| 12 | out_c := os.join_path(test_dir, 'test.c') |
| 13 | os.write_file(source, "import os |
| 14 | |
| 15 | fn pick() []string { |
| 16 | home := os.home_dir() |
| 17 | return match os.user_os() { |
| 18 | 'windows' { |
| 19 | [os.join_path(os.getenv('LOCALAPPDATA'), 'a'), os.join_path(home, 'b')] |
| 20 | } |
| 21 | else { |
| 22 | []string{} |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | fn main() { |
| 28 | println(pick()) |
| 29 | } |
| 30 | ")! |
| 31 | res := |
| 32 | os.execute('${os.quoted_path(vexe)} -g -o ${os.quoted_path(out_c)} -b c ${os.quoted_path(source)}') |
| 33 | assert res.exit_code == 0, res.output |
| 34 | generated := os.read_file(out_c)! |
| 35 | // Ensure no #line directive is glued to the following expression (missing newline). |
| 36 | assert !generated.contains('"builtin__new_array'), 'found #line directive glued to expression' |
| 37 | } |
| 38 | |