| 1 | import os |
| 2 | import rand |
| 3 | |
| 4 | const vexe = @VEXE |
| 5 | |
| 6 | fn test_cross_arch_ppc_closure_codegen() { |
| 7 | tmp_dir := os.join_path(os.vtmp_dir(), 'issue_20507_${rand.ulid()}') |
| 8 | os.mkdir_all(tmp_dir) or { panic(err) } |
| 9 | defer { |
| 10 | os.rmdir_all(tmp_dir) or {} |
| 11 | } |
| 12 | source := os.join_path(tmp_dir, 'main.v') |
| 13 | output := os.join_path(tmp_dir, 'main.c') |
| 14 | os.write_file(source, 'fn main() { |
| 15 | x := 123 |
| 16 | f := fn [x] () int { |
| 17 | return x |
| 18 | } |
| 19 | println(f()) |
| 20 | } |
| 21 | ') or { |
| 22 | panic(err) |
| 23 | } |
| 24 | res := |
| 25 | os.execute('${os.quoted_path(vexe)} -gc none -arch ppc -o ${os.quoted_path(output)} ${os.quoted_path(source)}') |
| 26 | assert res.exit_code == 0, res.output |
| 27 | csrc := os.read_file(output) or { panic(err) } |
| 28 | assert csrc.contains('__V_ppc') |
| 29 | assert csrc.contains('0x7c)), 0x08, 0x02, 0xa6') |
| 30 | assert csrc.contains('0x94)), 0x21, 0xff, 0xf0') |
| 31 | assert !csrc.contains('0xF3)), 0x44, 0x0F, 0x7E') |
| 32 | } |
| 33 | |