1 | #! parrot |
---|
2 | # Copyright (C) 2001-2009, Parrot Foundation. |
---|
3 | # $Id: string.t 40481 2009-08-11 06:09:35Z dukeleto $ |
---|
4 | |
---|
5 | =head1 NAME |
---|
6 | |
---|
7 | t/op/gc.t - Garbage collection |
---|
8 | |
---|
9 | =head1 SYNOPSIS |
---|
10 | |
---|
11 | % prove t/op/gc.t |
---|
12 | |
---|
13 | =head1 DESCRIPTION |
---|
14 | |
---|
15 | Tests garbage collection with the C<interpinfo> operation and various |
---|
16 | GC related bugs. |
---|
17 | |
---|
18 | =cut |
---|
19 | |
---|
20 | .include 'interpinfo.pasm' |
---|
21 | |
---|
22 | .sub main :main |
---|
23 | .include 'test_more.pir' |
---|
24 | plan(10) |
---|
25 | |
---|
26 | sweep_1() |
---|
27 | sweep_0() |
---|
28 | sweep_0_need_destroy_obj() |
---|
29 | sweep_0_need_destroy_destroy_obj() |
---|
30 | collect_count() |
---|
31 | collect_toggle() |
---|
32 | collect_toggle_nested() |
---|
33 | |
---|
34 | # END_OF_TESTS |
---|
35 | |
---|
36 | .end |
---|
37 | |
---|
38 | .sub sweep_1 |
---|
39 | $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS # How many GC mark runs have we done already? |
---|
40 | sweep 1 |
---|
41 | $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS # Should be one more now |
---|
42 | $I3 = $I2 - $I1 |
---|
43 | is($I3,1) |
---|
44 | .end |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | .sub sweep_0 |
---|
49 | $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS # How many GC mark runs have we done already? |
---|
50 | sweep 0 |
---|
51 | $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS # Should be same |
---|
52 | $I3 = $I2 - $I1 |
---|
53 | is($I3,0) |
---|
54 | .end |
---|
55 | |
---|
56 | |
---|
57 | # sweep 0, with object that needs destroy/destroy |
---|
58 | .sub sweep_0_need_destroy_obj |
---|
59 | $P0 = new 'Undef' |
---|
60 | $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS # How many GC mark runs have we done already? |
---|
61 | needs_destroy $P0 |
---|
62 | sweep 0 |
---|
63 | $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS # Should be one more now |
---|
64 | $I3 = $I2 - $I1 |
---|
65 | is($I3,1) |
---|
66 | .end |
---|
67 | |
---|
68 | # sweep 0, with object that needs destroy/destroy |
---|
69 | .sub sweep_0_need_destroy_destroy_obj |
---|
70 | $P0 = new 'Undef' |
---|
71 | needs_destroy $P0 |
---|
72 | $I1 = interpinfo .INTERPINFO_GC_MARK_RUNS # How many GC mark runs have we done already? |
---|
73 | $P0 = new 'Undef' #kill object |
---|
74 | sweep 0 |
---|
75 | $I2 = interpinfo .INTERPINFO_GC_MARK_RUNS # Should be one more now |
---|
76 | $I3 = $I2 - $I1 |
---|
77 | sweep 0 |
---|
78 | $I4 = interpinfo .INTERPINFO_GC_MARK_RUNS # Should be same as last |
---|
79 | $I5 = $I4 - $I2 |
---|
80 | is($I3,1) |
---|
81 | is($I5,0) |
---|
82 | .end |
---|
83 | |
---|
84 | .sub collect_count |
---|
85 | $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS # How many garbage collections have we done already? |
---|
86 | collect |
---|
87 | $I2 = interpinfo .INTERPINFO_GC_COLLECT_RUNS # Should be one more now |
---|
88 | $I3 = $I2 - $I1 |
---|
89 | is($I3,1) |
---|
90 | .end |
---|
91 | |
---|
92 | .sub collect_toggle |
---|
93 | $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS # How many garbage collections have we done already? |
---|
94 | collectoff |
---|
95 | collect |
---|
96 | $I2 = interpinfo .INTERPINFO_GC_COLLECT_RUNS |
---|
97 | $I3 = $I2 - $I1 |
---|
98 | is($I3,0) |
---|
99 | |
---|
100 | collecton |
---|
101 | collect |
---|
102 | $I4 = interpinfo .INTERPINFO_GC_COLLECT_RUNS |
---|
103 | $I6 = $I4 - $I2 |
---|
104 | is($I6,1) |
---|
105 | .end |
---|
106 | |
---|
107 | .sub collect_toggle_nested |
---|
108 | $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS # How many garbage collections have we done already? |
---|
109 | collectoff |
---|
110 | collectoff |
---|
111 | collecton |
---|
112 | collect # This shouldn't do anything... #' |
---|
113 | $I2 = interpinfo .INTERPINFO_GC_COLLECT_RUNS |
---|
114 | $I3 = $I2 - $I1 |
---|
115 | is($I3,0) |
---|
116 | |
---|
117 | collecton |
---|
118 | collect # ... but this should |
---|
119 | $I4 = interpinfo .INTERPINFO_GC_COLLECT_RUNS |
---|
120 | $I6 = $I4 - $I2 |
---|
121 | is($I6,1) |
---|
122 | |
---|
123 | .end |
---|
124 | |
---|
125 | |
---|
126 | # Local Variables: |
---|
127 | # mode: cperl |
---|
128 | # cperl-indent-level: 4 |
---|
129 | # fill-column: 100 |
---|
130 | # End: |
---|
131 | # vim: expandtab shiftwidth=4 filetype=pir: |
---|