Ticket #121: eval_xx.pir

File eval_xx.pir, 1.0 KB (added by rurban, 6 years ago)

This test fails differently: the 2nd load_bytecode fail silently

Line 
1.sub main :main
2  .local pmc f1, f2
3  .local pmc io, os
4  f1 = compi("foo_1", "hello from foo_1")
5  $S0 = f1
6  $S1 = "/tmp/xx.pbc"
7  io = open $S1, ">"
8  say "writing /tmp/xx.pbc"
9  print io, $S0
10  close io
11  say "loading /tmp/xx.pbc"
12  load_bytecode $S1
13
14  say "ls -al /tmp/xx.pbc"
15  $I0 = spawnw "ls -al /tmp/xx.pbc"
16
17  os = new 'OS'
18  say "rm /tmp/xx.pbc"
19  os.'rm'($S1)
20  #say "sleep 1"
21  #sleep 1
22  say "ls -al /tmp/xx.pbc"
23  $I0 = spawnw "ls -al /tmp/xx.pbc"
24 
25  $S2 = "/tmp/xx.pbc"
26  f2 = compi("foo_2", "hello from foo_2")
27  say "writing /tmp/xx.pbc"
28  io = open $S2, ">"
29  print io, f2
30  close io
31  say "loading /tmp/xx.pbc"
32  load_bytecode $S2
33.end
34
35.sub compi
36  .param string name
37  .param string printme
38  .local string code
39  .local pmc pir_compiler, retval
40  pir_compiler = compreg "PIR"
41  code = ".sub "
42  code .= name
43  code .= " :load\n"
44  code .= "print \"  "
45  code .= printme
46  code .= "\\n\"\n"
47  code .= ".end\n"
48
49  retval = pir_compiler(code)
50  .return (retval)
51.end