Ticket #948: gc.t.patch

File gc.t.patch, 3.0 KB (added by jrtayloriv, 12 years ago)
  • t/op/gc.t

     
    2323 
    2424=cut 
    2525 
    26 pasm_output_is( <<'CODE', '1', "sweep 1" ); 
    27       interpinfo I1, 2   # How many GC mark runs have we done already? 
     26pir_output_is( <<'CODE', '1', "sweep 1" ); 
     27.include 'interpinfo.pasm' 
     28.sub main :main 
     29      $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS  # How many GC mark runs have we done already? 
    2830      sweep 1 
    29       interpinfo I2, 2   # Should be one more now 
    30       sub I3, I2, I1 
    31       print I3 
    32       end 
     31      $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS  # Should be one more now 
     32      $I3 = $I2 - $I1 
     33      print $I3 
     34.end 
    3335CODE 
    3436 
    35 pasm_output_is( <<'CODE', '0', "sweep 0" ); 
    36       interpinfo I1, 2   # How many GC mark runs have we done already? 
     37pir_output_is( <<'CODE', '0', "sweep 0" ); 
     38.include 'interpinfo.pasm' 
     39.sub main :main 
     40      $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS   # How many GC mark runs have we done already? 
    3741      sweep 0 
    38       interpinfo I2, 2   # Should be same 
    39       sub I3, I2, I1 
    40       print I3 
    41       end 
     42      $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS  # Should be one more now 
     43      $I3 = $I2 - $I1 
     44      print $I3 
     45.end 
    4246CODE 
    4347 
    4448pasm_output_is( <<'CODE', '1', "sweep 0, with object that need destroy" ); 
     
    6872      end 
    6973CODE 
    7074 
    71 pasm_output_is( <<'CODE', '1', "collect" ); 
    72       interpinfo I1, 3   # How many garbage collections have we done already? 
     75pir_output_is( <<'CODE', '1', "collect" ); 
     76.include 'interpinfo.pasm' 
     77.sub main :main 
     78      $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS   # How many garbage collections have we done already? 
    7379      collect 
    74       interpinfo I2, 3   # Should be one more now 
    75       sub I3, I2, I1 
    76       print I3 
    77       end 
     80      $I2 = interpinfo .INTERPINFO_GC_COLLECT_RUNS  # Should be one more now 
     81      $I3 = $I2 - $I1 
     82      print $I3 
     83.end 
    7884CODE 
    7985 
    8086pasm_output_is( <<'CODE', <<'OUTPUT', "collectoff/on" ); 
     
    1231291 
    124130OUTPUT 
    125131 
    126 pasm_output_is( <<'CODE', <<OUTPUT, "vanishing singleton PMC" ); 
    127 _main: 
    128     .const 'Sub' P0 = "_rand" 
    129     new P16, 'Env' 
    130     set P16['Foo'], 'bar' 
    131     set I16, 100 
    132     set I17, 0 
    133 loop: 
    134     sweep 1 
    135     invokecc P0 
    136     inc I17 
    137     lt I17, I16, loop 
    138     print "ok\n" 
    139     end 
     132pir_output_is( <<'CODE', <<OUTPUT, "vanishing singleton PMC" ); 
     133.sub main :main 
     134    $P16 = new 'Env' 
     135    $P16['Foo'] = 'bar' 
     136    $I16 = 100 
     137    $I17 = 0 
    140138 
    141 .pcc_sub _rand: 
    142     new P16, 'Env' 
    143     set P5, P16['Foo'] 
    144     ne P5, 'bar', err 
    145     returncc 
    146 err: 
    147     print "singleton destroyed .Env = ." 
    148     new P16, 'Env' 
    149     typeof S16, P16 
    150     print S16 
    151     print "\n" 
    152     end 
     139    loop: 
     140                sweep 1 
     141        _rand() 
     142        $I17 += 1 
     143        if $I17 <= $I16 goto loop 
     144        say "ok" 
     145.end 
     146 
     147.sub _rand 
     148    $P16 = new 'Env' 
     149    $P5 = $P16['Foo'] 
     150    if $P5 != 'bar' goto err 
     151    .return() 
     152    err: 
     153        say "singleton destroyed .Env = ." 
     154        $P16 = new 'Env' 
     155        $S16 = typeof $P16 
     156        say $S16 
     157.end 
     158 
    153159CODE 
    154160ok 
    155161OUTPUT