function long_long_equal($a, $b, $message) { if (!($a === $b)) { if (!((double) $a === $b)) { return check::fail($message . ": '{$a}'!=='{$b}'"); } } return TRUE; }
<?php require "tests.php"; require "director_thread.php"; // No new functions check::functions(array(millisecondsleep, foo_stop, foo_run, foo_do_foo)); // No new classes check::classes(array(director_thread, Foo)); // now new vars check::globals(array(foo_val)); class Derived extends Foo { function do_foo() { $this->val = $this->val - 1; } } $d = new Derived(); $d->run(); if ($d->val >= 0) { check::fail($d->val); } $d->stop(); check::done();
<?php require "tests.php"; require "director_pass_by_value.php"; $passByVal = null; class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase { function virtualMethod($b) { global $passByVal; $passByVal = $b; } } # bug was the passByVal global object was destroyed after the call to virtualMethod had finished. $caller = new Caller(); $caller->call_virtualMethod(new director_pass_by_value_Derived()); $ret = $passByVal->getVal(); if ($ret != 0x12345678) { check::fail("Bad return value, got " . dechex($ret)); } check::done();
try { $bad->call_int(); check::fail("Exception wasn't propagated from Bad::return_int()"); } catch (Exception $e) { check::equal($e->getMessage(), "bad int", "propagated exception incorrect"); } try { $bad->call_double(); check::fail("Exception wasn't propagated from Bad::return_double()"); } catch (Exception $e) { check::equal($e->getMessage(), "bad double", "propagated exception incorrect"); } try { $bad->call_const_char_star(); check::fail("Exception wasn't propagated from Bad::return_const_char_star()"); } catch (Exception $e) { check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect"); } try { $bad->call_std_string(); check::fail("Exception wasn't propagated from Bad::return_std_string()"); } catch (Exception $e) { check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect"); } try { $bad->call_Bar(); check::fail("Exception wasn't propagated from Bad::return_Bar()"); } catch (Exception $e) { check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect"); } check::done();
function resource($a, $b, $message) { $resource = trim(check::var_dump($a)); if (!eregi("^resource\\([0-9]+\\) of type \\({$b}\\)", $resource)) { return check::fail($message); } return TRUE; }