Skip to content

Commit 52f652f

Browse files
committed
Add test case
1 parent 14ffc87 commit 52f652f

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Zend/tests/gc_045.phpt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
--TEST--
2+
GC 045: Total count persisted when GC is rerun due to destructor call
3+
--INI--
4+
zend.enable_gc=1
5+
--FILE--
6+
<?php
7+
class GlobalData
8+
{
9+
public static Bar $bar;
10+
}
11+
12+
class Value
13+
{
14+
public function __destruct()
15+
{
16+
new Bar();
17+
}
18+
}
19+
20+
class Bar
21+
{
22+
public function __construct()
23+
{
24+
GlobalData::$bar = $this;
25+
}
26+
}
27+
28+
class Foo
29+
{
30+
public Foo $selfRef;
31+
public Value $val;
32+
33+
public function __construct(Value $val)
34+
{
35+
$this->val = $val;
36+
$this->selfRef = $this;
37+
}
38+
}
39+
40+
for ($j = 0; $j < 10; $j++) {
41+
for ($i = 0; $i < 3000; $i++) {
42+
new Foo(new Value());
43+
}
44+
}
45+
46+
var_dump(gc_status());
47+
echo 'ok';
48+
?>
49+
--EXPECT--
50+
array(4) {
51+
["runs"]=>
52+
int(10)
53+
["collected"]=>
54+
int(25000)
55+
["threshold"]=>
56+
int(10001)
57+
["roots"]=>
58+
int(10000)
59+
}
60+
ok

0 commit comments

Comments
 (0)