php-src/Zend/tests/gc_017.phpt

43 lines
689 B
Plaintext
Raw Normal View History

2008-01-22 09:27:48 +00:00
--TEST--
GC 017: GC and destructors with unset
2010-03-03 17:53:15 +00:00
--INI--
zend.enable_gc=1
2008-01-22 09:27:48 +00:00
--FILE--
<?php
class Node {
public $name;
public $children;
public $parent;
function __construct($name) {
$this->name = $name;
$this->parent = null;
}
function insert($node) {
$node->parent = $this;
$this->children[] = $node;
}
function __destruct() {
var_dump($this->name);
unset($this->name);
unset($this->children);
unset($this->parent);
}
}
$a = new Node('A');
$b = new Node('B');
$c = new Node('C');
$a->insert($b);
$a->insert($c);
unset($a);
unset($b);
unset($c);
var_dump(gc_collect_cycles() >= 7);
2008-01-22 09:27:48 +00:00
echo "ok\n"
?>
--EXPECTF--
string(1) "%s"
string(1) "%s"
string(1) "%s"
bool(true)
2008-01-22 09:27:48 +00:00
ok