Permalink
Browse files

Merge pull request #4 from Jille/master

Add FAIL test expliciting a potential bug
  • Loading branch information...
2 parents 51fd496 + 1b1832f commit 4c3f4e2cf4070f9c5d1efa411a3fee4c32dfb8f5 @colder committed Apr 11, 2012
Showing with 47 additions and 1 deletion.
  1. +1 −1 tests/weakref_006.phpt
  2. +46 −0 tests/weakref_007.phpt
View
@@ -1,5 +1,5 @@
--TEST--
-Weakref: Destroying the weakred within the std dtor of the object
+Weakref: Destroying the weakref within the std dtor of the object
--FILE--
<?php
View
@@ -0,0 +1,46 @@
+--TEST--
+Weakref: Destroying the weakref and its object after a fatal error
+--SKIPIF--
+<?php if(!function_exists('pcntl_fork')) echo "skip can't test for returnvalue"; ?>
+--FILE--
+<?php
+ class A {
+ function __destruct() {
+ printf("Destroy A\n");
+ }
+ }
+ class B {
+ public $ref;
+
+ function __construct($a) {
+ $this->ref = array($a);
+ }
+
+ function __destruct() {
+ printf("Destroy B\n");
+ var_dump($this->ref->valid());
+ }
+ }
+ function doit() {
+ $a = new A();
+ $b = new B($a);
+ crash();
+ }
+ $pid = pcntl_fork();
+ if($pid == 0) {
+ doit();
+ exit(0);
+ }
+ pcntl_waitpid($pid, $status);
+ if(pcntl_wifsignaled($status)) {
+ echo "Killed: ". pcntl_wtermsig($status) ."\n";
+ } elseif(pcntl_wifexited($status)) {
+ echo "Exit: ". pcntl_wexitstatus($status) ."\n";
+ } else {
+ echo "Weird.\n";
+ }
+?>
+--EXPECTF--
+
+Fatal error: Call to undefined function crash() in %s on line %d
+Exit: 255

0 comments on commit 4c3f4e2

Please sign in to comment.