Merge branch 'master' into gsoc2017-php7-classes-via-c-api

This commit is contained in:
Olly Betts 2021-03-25 17:45:17 +13:00
commit 8ded9d8dae
1906 changed files with 50934 additions and 30001 deletions

View file

@ -79,3 +79,4 @@ clean:
rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
rm -f template_typedef_cplx2.php php_template_typedef_cplx2.h

View file

@ -9,4 +9,3 @@ $spam=new Spam();
check::equal(0,$spam->blah(),"spam object method");
check::done();
?>

View file

@ -11,4 +11,3 @@ check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterp
//check::equal(0,Spam::blah($spam),"spam class method");
check::done();
?>

View file

@ -19,4 +19,3 @@ check::is_a($foo_blah,'foo');
//check::is_a($class_foo_blah,foo);
check::done();
?>

View file

@ -30,9 +30,8 @@ unset($handle);
#$handledata=handle($handle);
#check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
unset($handle);
$handle=NULL;
voidhandle($handle);
check::isnull($handle,'$handle not null');
check::done();
?>

View file

@ -11,4 +11,3 @@ check::classes(array());
check::globals(array());
check::done();
?>

View file

@ -15,4 +15,3 @@ check::set("array_c","h");
check::equal("h",check::get("array_c"),"set array_c");
check::done();
?>

View file

@ -18,4 +18,3 @@ for($x=0;$x<count($a1);$x++) {
}
check::done();
?>

View file

@ -14,4 +14,3 @@ check::equal($as->array_c,"a",'$as->array_c=="a"');
check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)');
check::done();
?>

View file

@ -11,4 +11,3 @@ check::classes(array('arrays_scope','Bar'));
$bar=new bar();
check::done();
?>

View file

@ -6,4 +6,3 @@ require "callback.php";
if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::FOO_I_Cb_Ptr not a resource\n");
check::done();
?>

View file

@ -10,9 +10,8 @@ check::classes(array('A','B'));
// now new vars
check::globals(array());
# Make sure $b inherites hello() from class A
# Make sure $b inherits hello() from class A
$b=new B();
$b->hello();
check::done();
?>

View file

@ -40,4 +40,3 @@ check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPoint
check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
check::done();
?>

View file

@ -13,4 +13,3 @@ do_blah($bar);
check::classparent($bar,"");
check::done();
?>

View file

@ -10,4 +10,3 @@ $foo=$bar->toFoo();
check::classname("foo",$foo);
check::done();
?>

View file

@ -7,4 +7,3 @@ check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
// this is too hard, I'm not sure what to test for,
check::done();
?>

View file

@ -10,4 +10,3 @@ $foo=$bar->toFoo();
check::classname("foo",$foo);
check::done();
?>

View file

@ -165,5 +165,3 @@ enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121);
enumCheck(globalTest1(Enum1_Val5a), 13);
enumCheck(globalTest2(Class1::Enum12_Val5c), 1121);
#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121);
?>

View file

@ -15,4 +15,3 @@ $f->func_ptr = get_func2_ptr();
check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
check::done();
?>

View file

@ -4,9 +4,8 @@ require "tests.php";
require "cpp_static.php";
// New functions
check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin'));
check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin','staticmembertest_grab_int','staticbase_grab_statty_base','staticderived_grab_statty_derived'));
// New classes
check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived'));
check::done();
?>

View file

@ -50,4 +50,3 @@ $me3 = new MyExample3();
check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed");
check::done();
?>

View file

@ -3,10 +3,8 @@
require "tests.php";
require "director_basic.php";
// No new functions
check::functions(array('foo_ping','foo_pong','foo_get_self','a_f','a_rg','a1_ff','myclass_method','myclass_vmethod','myclass_pmethod','myclass_cmethod','myclass_get_self','myclass_call_pmethod','myclasst_i_method'));
// No new classes
check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i'));
check::functions(array('foo_ping','foo_pong','foo_get_self','a_f','a_rg','a1_ff','myclass_method','myclass_vmethod','myclass_pmethod','myclass_cmethod','myclass_get_self','myclass_call_pmethod','myclasst_i_method','myclass_nonvirtual','myclass_nonoverride','myclass_call_nonvirtual','myclass_call_nonoverride','myclass_connect','constptrclass_getconstptr'));
check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i','ConstPtrClass'));
class PhpFoo extends Foo {
function ping() {
@ -53,4 +51,3 @@ check::equal($bc->x, 34, "bc failed");
check::equal($bd->x, 16, "bd failed");
check::done();
?>

View file

@ -147,4 +147,3 @@ mycheck($person, "TargetLangOrphanChild");
unset($person);
check::done();
?>

View file

@ -17,4 +17,3 @@ $f = new Bar();
$f = new Bar(1);
check::done();
?>

View file

@ -52,4 +52,3 @@ check::equal($b->val, 5, "b: Bad virtual detection");
check::equal($vc, 6, "c: Bad virtual detection");
check::done();
?>

View file

@ -22,4 +22,3 @@ $a = new MyFoo();
check::equal($a->say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed");
check::done();
?>

View file

@ -3,8 +3,9 @@
require "tests.php";
require "director_exception.php";
// No new functions
check::functions(array('foo_ping','foo_pong','launder','bar_ping','bar_pong','bar_pang','returnalltypes_return_int','returnalltypes_return_double','returnalltypes_return_const_char_star','returnalltypes_return_std_string','returnalltypes_return_bar','returnalltypes_call_int','returnalltypes_call_double','returnalltypes_call_const_char_star','returnalltypes_call_std_string','returnalltypes_call_bar','is_python_builtin'));
check::functions(array('foo_ping','foo_pong','launder','bar_ping','bar_pong','returnalltypes_return_int','returnalltypes_return_double','returnalltypes_return_const_char_star','returnalltypes_return_std_string','returnalltypes_return_bar','returnalltypes_call_int','returnalltypes_call_double','returnalltypes_call_const_char_star','returnalltypes_call_std_string','returnalltypes_call_bar','is_python_builtin'));
// No new classes
check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes'));
class MyException extends Exception {
function __construct($a, $b) {
@ -120,4 +121,3 @@ try {
}
check::done();
?>

View file

@ -21,4 +21,3 @@ check::equal($m->dummy(), 666, "1st call");
check::equal($m->dummy(), 666, "2st call"); // Locked system
check::done();
?>

View file

@ -58,4 +58,3 @@ check::equal(getStatus(), 3, "getStatus() failed #5");
resetStatus();
check::done();
?>

View file

@ -14,4 +14,3 @@ $s = $foo->abs_method();
check::equal($s, "Bravo::abs_method()", "s failed");
check::done();
?>

View file

@ -71,4 +71,3 @@ check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");
check::equal($c->name(), "FooBar::get_name hello", "name failed");
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
require "tests.php";
require "director_overload.php";
check::functions(array('new_overloadedClass','new_overloadedPointers','new_overloadedGetSet','overloadedclass_method1','overloadedclass_method3','overloadedclass_method2','overloadedpointers_method','overloadedpointers_notover','overloadedgetset_rw'));
check::classes(array('OverloadedClass','OverloadedPointers','OverloadedGetSet'));
check::globals(array());
$o = new OverloadedGetSet;
check::equal($o->rw(), 42, "get_set() initial value not 42");
check::equal($o->rw(7), null, "get_set() failed to set");
check::equal($o->rw(), 7, "get_set() didn't return back set value");
check::done();

View file

@ -21,4 +21,3 @@ if ($ret != 0x12345678) {
}
check::done();
?>

View file

@ -50,4 +50,3 @@ while ($i) {
print $a . "\n";
check::done();
?>

View file

@ -66,4 +66,3 @@ check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
check::done();
?>

View file

@ -57,4 +57,3 @@ $vs;
$a->tvidents($vs);*/
check::done();
?>

View file

@ -29,4 +29,3 @@ $b->call_process_func();
check::equal($b->smem, "hello", "smem failed");
check::done();
?>

View file

@ -28,4 +28,3 @@ if ($d->val >= 0) {
$d->stop();
check::done();
?>

View file

@ -21,7 +21,9 @@ $b = new Bar();
$b->set($a);
$c = $b->get();
check::equal($a->this, $c->this, "this failed");
// FIXME: This doesn't work for checking that they wrap the same C++ object
// because the two objects have different PHP resources, and we can't easily
// look inside those resources to see which C++ objects they refer to.
//check::equal($a->_cPtr, $c->_cPtr, "_cPtr check failed");
check::done();
?>

View file

@ -12,4 +12,3 @@ check::equal(TreeInt::Fir,chops(TreeInt::Fir),"TreeInt_Fir==chops(TreeInt_Fir)")
check::equal(TreeInt::Cedar,chops(TreeInt::Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
check::done();
?>

View file

@ -15,4 +15,3 @@ $spam=new spam();
$_spam=test($spam);
check::done();
?>

View file

@ -31,8 +31,9 @@ check::is_a($spam,"spam");
check::equal(1,$spam->_foo,"1==spam->_foo");
check::equal(2,$spam->_bar,"2==spam->_bar");
// multiple inheritance not supported in PHP
set_error_handler(function () {return true;}, E_NOTICE|E_WARNING); // Don't complain that _baz is unknown.
check::equal(null,$spam->_baz,"null==spam->_baz");
restore_error_handler();
check::equal(4,$spam->_spam,"4==spam->_spam");
check::done();
?>

View file

@ -13,4 +13,3 @@ check::is_a("spam","bar");
//check::is_a("spam","baz");
check::done();
?>

View file

@ -35,4 +35,3 @@ try {
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ E2 * exception thrown', '');
}
?>

View file

@ -9,4 +9,3 @@ check::equal(2,$foo->test1(2),"test1");
check::equal(3,$foo->test2(3),"test2");
check::done();
?>

View file

@ -9,4 +9,3 @@ check::equal(2,$foo->test1(2),"test1");
check::equal(3,$foo->test2(3),"test2");
check::done();
?>

View file

@ -18,4 +18,3 @@ check::equal(-5,negate(5),"-5==negate(5)");
check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
check::done();
?>

View file

@ -4,11 +4,9 @@ require "tests.php";
require "ignore_parameter.php";
// New functions
check::functions(array('jaguar','lotus','tvr','ferrari','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini'));
check::functions(array('jaguar','lotus','tvr','ferrari','fiat','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini','sportscars_maseratti'));
// New classes
check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro'));
// No new vars
check::globals(array());
check::equal(jaguar(2,3.4),"hello",'jaguar(2,3.4)=="hello"');
check::equal(lotus("eek",3.4),101,'lotus("eek",3.4)==101');
@ -35,4 +33,3 @@ $aa=new austinallegro();
check::classname("austinallegro",$aa);
check::done();
?>

View file

@ -17,4 +17,3 @@ $b = new Bar();
import_nomodule::test1($b,37);
check::done();
?>

View file

@ -16,4 +16,3 @@ $d->setitem(5, $d->getitem(0) + 3);
check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
check::done();
?>

View file

@ -16,4 +16,3 @@ $d->setitem(5, $d->getitem(0) + 3);
check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
check::done();
?>

View file

@ -19,4 +19,3 @@ $w = $point->width();
check::equal($w, 1.0, "w failed");
check::done();
?>

View file

@ -27,5 +27,7 @@ check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2")
// below broken ?
//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
// This used to give "Undefined variable: r"
li_std_string::test_const_reference_returning_void("foo");
check::done();
?>

View file

@ -27,4 +27,3 @@ check::equal($T->start_t->x, 4, "S::x != 4");
check::equal($T->length, 7, "T::length != 7");
check::done();
?>

View file

@ -16,4 +16,3 @@ $bar = $foo->makeMore();
check::equal(get_class($bar), "Foo", "regular failed");
check::done();
?>

View file

@ -0,0 +1,16 @@
<?php
require "tests.php";
require "newobject3.php";
$factory = new factory();
check::classname("Product", $factory->create(7));
check::classname("Product", $factory->create(7, 6));
check::classname("Product", $factory->create("test"));
check::classname("Product", $factory->create("test", 2));
check::isnull($factory->create(0), "create(0) should be NULL");
check::isnull($factory->create(7, -1), "create(7, -1) should be NULL");
check::isnull($factory->create(0, -1), "create(0, -1) should be NULL");
check::isnull($factory->create("bad", -1), "create(\"bad\", -1) should be NULL");

View file

@ -0,0 +1,45 @@
<?php
require "tests.php";
require "overload_null.php";
$o = new Overload();
$x = new X();
check::equal(1, $o->byval1($x), "test 1");
check::equal(2, $o->byval1(null), "test 2");
check::equal(3, $o->byval2(null), "test 3");
check::equal(4, $o->byval2($x), "test 4");
check::equal(5, $o->byref1($x), "test 5");
check::equal(6, $o->byref1(null), "test 6");
check::equal(7, $o->byref2(null), "test 7");
check::equal(8, $o->byref2($x), "test 8");
check::equal(9, $o->byconstref1($x), "test 9");
check::equal(10, $o->byconstref1(null), "test 10");
check::equal(11, $o->byconstref2(null), "test 11");
check::equal(12, $o->byconstref2($x), "test 12");
# const pointer references
check::equal(13, $o->byval1cpr($x), "test 13");
check::equal(14, $o->byval1cpr(null), "test 14");
check::equal(15, $o->byval2cpr(null), "test 15");
check::equal(16, $o->byval2cpr($x), "test 16");
# forward class declaration
check::equal(17, $o->byval1forwardptr($x), "test 17");
check::equal(18, $o->byval1forwardptr(null), "test 18");
check::equal(19, $o->byval2forwardptr(null), "test 19");
check::equal(20, $o->byval2forwardptr($x), "test 20");
check::equal(21, $o->byval1forwardref($x), "test 21");
check::equal(22, $o->byval2forwardref($x), "test 22");
check::done();

View file

@ -0,0 +1,13 @@
<?php
require "tests.php";
require "overload_polymorphic.php";
$t = new Derived();
check::equal(overload_polymorphic::test($t), 0, "test(Derived)");
check::equal(overload_polymorphic::test(1), 1, "test(1)");
check::equal(overload_polymorphic::test2($t), 1, "test2(Derived)");
check::equal(overload_polymorphic::test3($t, null, $t), 1, "test3(Derived, null, Derived)");
check::done();

View file

@ -16,4 +16,3 @@ $f = Foo::Foo_int(1.0,1);
$f = Foo::Foo_int(1.0,1,1.0);
check::done();
?>

View file

@ -9,5 +9,3 @@ check::classname("A", $b->foo("test"));
check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
?>

View file

@ -21,4 +21,3 @@ foreach (new MyIterator(2, 5) as $k => $v) {
check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
check::done();
?>

View file

@ -7,6 +7,3 @@ require "php_pragma.php";
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
check::done();
?>

View file

@ -15,4 +15,3 @@ check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
check::done();
?>

View file

@ -15,4 +15,3 @@ $f = new ProjectFoo();
$f->get_self();
check::done();
?>

View file

@ -62,5 +62,6 @@ check::equal(gettype(preproc_constants_c::EXPR_OR), "integer", "preproc_constant
check::equal(gettype(preproc_constants_c::EXPR_LAND), "integer", "preproc_constants.EXPR_LAND has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_LOR), "integer", "preproc_constants.EXPR_LOR has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
?>
check::equal(gettype(preproc_constants_c::EXPR_MIXED1), "double", "preproc_constants.EXPR_MIXED1 has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_WCHAR_MAX), "integer", "preproc_constants.EXPR_WCHAR_MAX has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_WCHAR_MIN), "integer", "preproc_constants.EXPR_WCHAR_MIN has unexpected type");

View file

@ -61,5 +61,6 @@ check::equal(gettype(preproc_constants::EXPR_OR), "integer", "preproc_constants.
check::equal(gettype(preproc_constants::EXPR_LAND), "boolean", "preproc_constants.EXPR_LAND has unexpected type");
check::equal(gettype(preproc_constants::EXPR_LOR), "boolean", "preproc_constants.EXPR_LOR has unexpected type");
check::equal(gettype(preproc_constants::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
?>
check::equal(gettype(preproc_constants::EXPR_MIXED1), "double", "preproc_constants.EXPR_MIXED1 has unexpected type");
check::equal(gettype(preproc_constants::EXPR_WCHAR_MAX), "integer", "preproc_constants.EXPR_WCHAR_MAX has unexpected type");
check::equal(gettype(preproc_constants::EXPR_WCHAR_MIN), "integer", "preproc_constants.EXPR_WCHAR_MIN has unexpected type");

View file

@ -31,4 +31,3 @@ long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longl
long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
check::done();
?>

View file

@ -13,4 +13,3 @@ check::classparent("Natural_UP","Interface_UP");
check::classparent("Natural_BP","Interface_BP");
check::done();
?>

View file

@ -12,4 +12,3 @@ check::classes(array());
check::globals(array());
check::done();
?>

View file

@ -24,4 +24,3 @@ check::equal(3,$bar->test(),"bar->test");
check::classname("foo",$bar->__deref__());
check::done();
?>

View file

@ -29,5 +29,3 @@ $e = NULL;
if (Shape::nshapes() != 0) {
check::fail("Shape::nshapes() should be 0, actually ".Shape::nshapes());
}
?>

View file

@ -19,4 +19,3 @@ check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam");
check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar");
check::done();
?>

View file

@ -10,9 +10,8 @@ check::classes(array('UnaryFunction_bool_bool','BoolUnaryFunction_bool'));
$ufbb=new unaryfunction_bool_bool();
check::is_a($ufbb,"unaryfunction_bool_bool");
unset($whatisthis);
$whatisthis=NULL;
$bufb=new boolunaryfunction_bool($whatisthis);
check::is_a($bufb,"boolunaryfunction_bool");
check::done();
?>

View file

@ -8,4 +8,3 @@ $foo_int=new foo_int(3);
check::is_a($foo_int,"foo_int","Made a foo_int");
check::done();
?>

View file

@ -1,5 +1,16 @@
<?php
function die_on_error($errno, $errstr, $file, $line) {
if ($file !== Null) {
print $file;
if ($line !== Null) print ":$line";
print ": ";
}
print "$errstr\n";
exit(1);
}
set_error_handler("die_on_error", -1);
$_original_functions=get_defined_functions();
$_original_globals=1;
$_original_classes=get_declared_classes();
@ -10,7 +21,7 @@ class check {
// Used to filter out get/set global functions to fake vars...
const GETSET = 1;
function get_extra_classes($ref=FALSE) {
static function get_extra_classes($ref=FALSE) {
static $extra;
global $_original_classes;
if ($ref===FALSE) $f=$_original_classes;
@ -22,7 +33,7 @@ class check {
return $extra;
}
function get_extra_functions($ref=FALSE,$gs=false) {
static function get_extra_functions($ref=FALSE,$gs=false) {
static $extra;
static $extrags; // for get/setters
global $_original_functions;
@ -46,7 +57,7 @@ class check {
return $extra;
}
function get_extra_globals($ref=FALSE) {
static function get_extra_globals($ref=FALSE) {
static $extra;
global $_original_globals;
if (! is_array($extra)) {
@ -72,17 +83,18 @@ class check {
return $extra;
}
function classname($string,$object) {
static function classname($string,$object) {
if (!is_object($object))
return check::fail("The second argument is a " . gettype($object) . ", not an object.");
if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string);
return TRUE;
}
function classmethods($classname,$methods) {
static function classmethods($classname,$methods) {
return TRUE;
if (is_object($classname)) $classname=get_class($classname);
$classmethods=array_flip(get_class_methods($classname));
$message=NULL;
$missing=array();
$extra=array();
foreach($methods as $method) {
@ -99,19 +111,19 @@ class check {
return TRUE;
}
function set($var,$value) {
static function set($var,$value) {
$func=$var."_set";
if (self::GETSET) $func($value);
else $_GLOBALS[$var]=$value;
}
function &get($var) {
static function get($var) {
$func=$var."_get";
if (self::GETSET) return $func();
else return $_GLOBALS[$var];
}
function is_a($a,$b) {
static function is_a($a,$b) {
if (is_object($a)) $a=strtolower(get_class($a));
if (is_object($b)) $a=strtolower(get_class($b));
$parents=array();
@ -120,11 +132,11 @@ class check {
$parents[]=$c;
$c=strtolower(get_parent_class($c));
}
if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n %s\n",join("\n ",$parents));
if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierarchy:\n %s\n",join("\n ",$parents));
return TRUE;
}
function classparent($a,$b) {
static function classparent($a,$b) {
if (is_object($a)) $a=get_class($a);
if (is_object($b)) $a=get_class($b);
$parent=get_parent_class($a);
@ -133,7 +145,7 @@ class check {
return TRUE;
}
function classes($classes) {
static function classes($classes) {
return TRUE;
if (! is_array($classes)) $classes=array($classes);
$message=array();
@ -150,7 +162,7 @@ class check {
return TRUE;
}
function functions($functions) {
static function functions($functions) {
return TRUE;
if (! is_array($functions)) $functions=array($functions);
$message=array();
@ -168,7 +180,7 @@ class check {
return TRUE;
}
function globals($globals) {
static function globals($globals) {
if (! is_array($globals)) $globals=array($globals);
$message=array();
$missing=array();
@ -190,30 +202,30 @@ class check {
}
function functionref($a,$type,$message) {
static function functionref($a,$type,$message) {
if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
return check::fail($message);
return TRUE;
}
function equal($a,$b,$message) {
static function equal($a,$b,$message) {
if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
return TRUE;
}
function resource($a,$b,$message) {
static function resource($a,$b,$message) {
$resource=trim(check::var_dump($a));
if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
return check::fail($message);
return TRUE;
}
function isnull($a,$message) {
static function isnull($a,$message) {
$value=trim(check::var_dump($a));
return check::equal($value,"NULL",$message);
}
function var_dump($arg) {
static function var_dump($arg) {
ob_start();
var_dump($arg);
$result=ob_get_contents();
@ -221,20 +233,19 @@ class check {
return $result;
}
function fail($pattern) {
static function fail($pattern) {
$args=func_get_args();
print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
exit(1);
}
function warn($pattern) {
static function warn($pattern) {
$args=func_get_args();
print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
return FALSE;
}
function done() {
static function done() {
# print $_SERVER[argv][0]." ok\n";
}
}
?>

View file

@ -10,4 +10,3 @@ $int3=copy_intp(3);
check::equal(3,otherfunc($int3)," test passing intp to otherfunc");
check::done();
?>

View file

@ -6,4 +6,3 @@ if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
check::done();
?>

View file

@ -6,4 +6,3 @@ if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
check::done();
?>

View file

@ -6,4 +6,3 @@ if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
check::done();
?>

View file

@ -10,4 +10,3 @@ $ibp=valuewrapper_base::make_interface_bp();
check::classname("interface_bp",$ibp);
check::done();
?>

View file

@ -7,5 +7,3 @@ $fail = new SimpleClassFail();
$work = new SimpleClassWork();
check::equal($work->getInner()->get(), $fail->getInner()->get(), "should both be 10");
?>

View file

@ -9,4 +9,3 @@ check::equal(maximum(2.3, 2.4), 2.4, "maximum() doesn't work");
check::equal(guint16_swap_le_be_constant(0x1234), 0x3412, "GUINT16_SWAP_LE_BE_CONSTANT() doesn't work");
check::done();
?>