Merged with recent changes from trunk.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11187 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2009-04-11 16:46:47 +00:00
commit 8c74fa0f46
703 changed files with 21126 additions and 9266 deletions

View file

@ -0,0 +1,72 @@
#######################################################################
# Makefile for php test-suite
#######################################################################
LANGUAGE = php
SCRIPTSUFFIX = _runme.php
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
#CPP_TEST_CASES += \
# php_namewarn_rename \
include $(srcdir)/../common.mk
# Overridden variables here
TARGETPREFIX =# Should be php_ for Windows, empty otherwise
makecpptests:
@bash -ec 'for test in $(CPP_TEST_CASES) ; do $(MAKE) clean && $(MAKE) $${test}.cpptest; done'
maketests: makecpptests makectests
makectests:
@bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done'
runcpptests:
@bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
runctests:
@bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
runtests: runcpptests runctests
# write out tests without a _runme.php
missingcpptests:
@bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
missingctests:
@bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
missingtests: missingcpptests missingctests
# Rules for the different types of tests
%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
+$(run_testcase)
%.ctest:
$(setup)
+$(swig_and_compile_c)
+$(run_testcase)
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
+$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.php appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \
fi;
# Clean: remove the generated .php file
%.clean:
@rm -f $*.php;
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean

View file

@ -0,0 +1,12 @@
<?php
require "tests.php";
require "abstract_inherit_ok.php";
check::classes(array(Foo,Spam));
$spam=new Spam();
check::equal(0,$spam->blah(),"spam object method");
check::done();
?>

View file

@ -0,0 +1,14 @@
<?php
require "tests.php";
require "abstract_inherit.php";
check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
// This constructor attempt should fail as there isn't one
//$spam=new Spam();
//check::equal(0,$spam->blah(),"spam object method");
//check::equal(0,Spam::blah($spam),"spam class method");
check::done();
?>

View file

@ -0,0 +1,23 @@
<?php
// Sample test file
require "tests.php";
require "add_link.php";
// No new functions, except the flat functions
check::functions(array(new_foo,foo_blah));
check::classes(array(Foo));
$foo=new foo();
check::is_a($foo,foo);
$foo_blah=$foo->blah();
check::is_a($foo_blah,foo);
//fails, can't be called as a class method, should allow and make it nil?
//$class_foo_blah=foo::blah();
//check::is_a($class_foo_blah,foo);
check::done();
?>

View file

@ -0,0 +1,37 @@
<?php
require "tests.php";
require "argout.php";
check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
$ip=copy_intp(42);
check::equal(42,incp($ip),"42==incp($ip)");
check::equal(43,intp_value($ip),"43=$ip");
$p=copy_intp(2);
check::equal(2,incp($p),"2==incp($p)");
check::equal(3,intp_value($p),"3==$p");
$r=copy_intp(7);
check::equal(7,incr($r),"7==incr($r)");
check::equal(8,intp_value($r),"8==$r");
$tr=copy_intp(4);
check::equal(4,inctr($tr),"4==incr($tr)");
check::equal(5,intp_value($tr),"5==$tr");
# Check the voidhandle call, first with null
unset($handle);
voidhandle(&$handle);
check::resource($handle,"_p_void",'$handle is not _p_void');
$handledata=handle($handle);
check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
unset($handle);
// without reference, should fatal error so can't test here
//voidhandle($handle);
//check::isnull($handle,'$handle not null');
check::done();
?>

View file

@ -0,0 +1,15 @@
<?php
// Sample test file
require "tests.php";
require "arrayptr.php";
// No new functions
check::functions(array(foo));
// No new classes
check::classes(array());
// now new vars
check::globals(array());
check::done();
?>

View file

@ -0,0 +1,20 @@
<?php
// Sample test file
require "tests.php";
require "arrays_global.php";
check::functions(array(test_a,test_b,new_simplestruct,new_material));
check::classes(array(arrays_global,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat));
// The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it.
check::set(array_c,"Z");
check::equal("Z",check::get(array_c),"set array_c");
check::set(array_c,"xy");
check::equal("x",check::get(array_c),"set array_c");
check::set(array_c,"h");
check::equal("h",check::get(array_c),"set array_c");
check::done();
?>

View file

@ -0,0 +1,23 @@
<?php
// Sample test file
require "tests.php";
require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
check::classes(array(arrays_global_twodim,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat));
$a1=array(10,11,12,13);
$a2=array(14,15,16,17);
$a=array($a1,$a2);
$_a=check::get(array_const_i);
for($x=0;$x<count($a1);$x++) {
for($y=0;$y<2;$y++) {
check::equal($a[$y][$x],get_2d_array($_a,$y,$x),"check array $x,$y");
}
}
check::done();
?>

View file

@ -0,0 +1,19 @@
<?php
// Sample test file
require "tests.php";
require "arrays.php";
check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t));
// No new vars
check::globals(array());
$ss=new simplestruct();
check::classname(simplestruct,$ss);
$as=new arraystruct();
$as->array_c="abc";
check::equal($as->array_c,"ab",'$as->array_c=="ab"');
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
// Sample test file
require "tests.php";
require "arrays_scope.php";
// No new functions
check::functions(array(new_bar,bar_blah));
// No new classes
check::classes(array(arrays_scope,Bar));
// now new vars
check::globals(array());
$bar=new bar();
check::done();
?>

View file

@ -0,0 +1,19 @@
<?php
// Sample test file
require "tests.php";
require "casts.php";
// No new functions
check::functions(array(new_a,a_hello,new_b));
// No new classes
check::classes(array(A,B));
// now new vars
check::globals(array());
# Make sure $b inherites hello() from class A
$b=new B();
$b->hello();
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
// Sample test file
require "tests.php";
require "class_ignore.php";
check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
check::classes(array(class_ignore,Bar,Boo,Far,Hoo));
// No new vars
check::globals(array());
$bar=new bar();
do_blah($bar);
check::classparent($bar,"");
check::done();
?>

View file

@ -0,0 +1,14 @@
<?php
// Sample test file
require "tests.php";
require "conversion_namespace.php";
check::classes(array("Foo","Bar"));
$bar=new Bar;
check::classname("bar",$bar);
$foo=$bar->toFoo();
check::classname("foo",$foo);
check::done();
?>

View file

@ -0,0 +1,10 @@
<?php
require "tests.php";
require "conversion_ns_template.php";
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

@ -0,0 +1,14 @@
<?php
// Sample test file
require "tests.php";
require "conversion.php";
check::classes(array("Foo","Bar"));
$bar=new Bar;
check::classname("bar",$bar);
$foo=$bar->toFoo();
check::classname("foo",$foo);
check::done();
?>

View file

@ -0,0 +1,15 @@
<?php
// Sample test file
require "tests.php";
require "cpp_static.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(StaticMemberTest,StaticFunctionTest));
// now new vars
check::globals(array());
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
// Sample test file
require "tests.php";
require "enum_scope_template.php";
check::classes(array("enum_scope_template", "TreeInt"));
check::functions("chops");
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
check::equal(1,TreeInt_Fir,"0==TreeInt_Fir");
check::equal(2,TreeInt_Cedar,"0==TreeInt_Cedar");
check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
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

@ -0,0 +1,19 @@
<?php
// Sample test file
require "tests.php";
require "evil_diamond_ns.php";
check::classes(array("evil_diamond_ns","foo","bar","baz","spam"));
check::functions("test");
check::is_a("bar","foo");
check::is_a("baz","foo");
check::is_a("spam","foo");
check::is_a("spam","bar");
//No multiple inheritance
//check::is_a("spam","baz");
$spam=new spam();
$_spam=test($spam);
check::done();
?>

View file

@ -0,0 +1,38 @@
<?php
// Sample test file
require "tests.php";
require "evil_diamond_prop.php";
check::classes(array("evil_diamond_prop","foo","bar","baz","spam"));
check::functions("test");
check::is_a("bar","foo");
check::is_a("baz","foo");
check::is_a("spam","foo");
check::is_a("spam","bar");
//No multiple inheritance introspection yet
//check::is_a("spam","baz");
$foo=new foo();
check::is_a($foo,"foo");
check::equal(1,$foo->_foo,"1==foo->_foo");
$bar=new bar();
check::is_a($bar,"bar");
check::equal(1,$bar->_foo,"1==bar->_foo");
check::equal(2,$bar->_bar,"2==bar->_bar");
$baz=new baz();
check::is_a($baz,"baz");
check::equal(1,$baz->_foo,"1==baz->_foo");
check::equal(3,$baz->_baz,"3==baz->_baz");
$spam=new spam();
check::is_a($spam,"spam");
check::equal(1,$spam->_foo,"1==spam->_foo");
check::equal(2,$spam->_bar,"2==spam->_bar");
check::equal(3,$spam->_baz,"3==spam->_baz");
check::equal(4,$spam->_spam,"4==spam->_spam");
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
// Sample test file
require "tests.php";
require "evil_diamond.php";
check::classes(array("evil_diamond","foo","bar","baz","spam"));
check::functions("test");
check::is_a("bar","foo");
check::is_a("baz","foo");
check::is_a("spam","foo");
check::is_a("spam","bar");
//No multiple inheritance
//check::is_a("spam","baz");
check::done();
?>

View file

@ -0,0 +1,13 @@
<?php
// Sample test file
require "tests.php";
require "extend_template_ns.php";
check::classes(array("extend_template_ns","Foo_One"));
$foo=new Foo_One();
check::equal(2,$foo->test1(2),"test1");
check::equal(3,$foo->test2(3),"test2");
check::done();
?>

View file

@ -0,0 +1,13 @@
<?php
// Sample test file
require "tests.php";
require "extend_template.php";
check::classes(array("Foo_0"));
$foo=new Foo_0();
check::equal(2,$foo->test1(2),"test1");
check::equal(3,$foo->test2(3),"test2");
check::done();
?>

View file

@ -0,0 +1,23 @@
<?php
// Sample test file
require "tests.php";
require "grouping.php";
check::functions(array("test1","test2","do_unary","negate"));
check::equal(5,test1(5),"5==test1(5)");
check::resource(test2(7),"_p_int","_p_int==test2(7)");
check::globals(array(test3));
//check::equal(37,test3_get(),'37==test3_get()');
check::equal(37,check::get("test3"),'37==get(test3)');
//test3_set(38);
check::set(test3,38);
//check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
check::equal(38,check::get(test3),'38==get(test3) after set(test)');
check::equal(-5,negate(5),"-5==negate(5)");
check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
check::done();
?>

View file

@ -0,0 +1,39 @@
<?php
// Sample test file
require "tests.php";
require "ignore_parameter.php";
// No new functions
check::functions(array(jaguar,lotus,tvr,ferrari));
// No new classes
check::classes(array(sportscars,minicooper,morrisminor,fordanglia,austinallegro));
// now 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');
check::equal(tvr("eek",2),8.8,'tvr("eek",2)==8.8');
check::equal(ferrari(),101,'ferrari(2)==101');
$sc=new sportscars();
check::classname("sportscars",$sc);
check::equal($sc->daimler(2,3.4),"hello",'$sc->daimler(2,3.4)=="hello"');
check::equal($sc->astonmartin("eek",3.4),101,'$sc->mastonmartin("eek",3.4)==101');
check::equal($sc->bugatti("eek",2),8.8,'$sc->bugatti("eek",2)==8.8');
check::equal($sc->lamborghini(),101,'$sc->lamborghini(2)==101');
$mc=new minicooper(2,3.4);
check::classname("minicooper",$mc);
$mm=new morrisminor("eek",3.4);
check::classname("morrisminor",$mm);
$fa=new fordanglia("eek",2);
check::classname("fordanglia",$fa);
$aa=new austinallegro();
check::classname("austinallegro",$aa);
check::done();
?>

View file

@ -0,0 +1,15 @@
<?php
// Sample test file
require "tests.php";
require "li_carrays.php";
// No new functions
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem));
// No new classes
check::classes(array(doubleArray));
// now new vars
check::globals(array());
check::done();
?>

View file

@ -0,0 +1,32 @@
<?php
// Sample test file
require "tests.php";
require "li_std_string.php";
// Global variables
//$s="initial string";
//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
// Global variables
$s = "initial string";
check::equal(GlobalString2_get(), "global string 2", "GlobalString2 test 1");
GlobalString2_set($s);
check::equal(GlobalString2_get(), $s, "GlobalString2 test 2");
check::equal(ConstGlobalString_get(), "const global string", "ConstGlobalString test");
// Member variables
$myStructure = new Structure();
check::equal($myStructure->MemberString2, "member string 2", "MemberString2 test 1");
$myStructure->MemberString2 = $s;
check::equal($myStructure->MemberString2, $s, "MemberString2 test 2");
check::equal($myStructure->ConstMemberString, "const member string", "ConstMemberString test");
check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1");
Structure::StaticMemberString2($s);
check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2");
// below broken ?
//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
check::done();
?>

View file

@ -0,0 +1,17 @@
<?php
// Sample test file
require "tests.php";
require "rename_scope.php";
check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
check::classmethods("Interface_UP",array("interface_up"));
check::classmethods("Interface_BP",array("interface_bp"));
check::classmethods("Natural_UP",array("interface_up","natural_up","rtest"));
check::classmethods("Natural_BP",array("interface_bp","natural_bp","rtest"));
check::classparent("Natural_UP","interface_up");
check::classparent("Natural_BP","interface_bp");
check::done();
?>

View file

@ -0,0 +1,15 @@
<?php
// Sample test file
require "tests.php";
require "____.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array());
// now new vars
check::globals(array());
check::done();
?>

View file

@ -0,0 +1,28 @@
<?php
// Sample test file
require "tests.php";
require "smart_pointer_rename.php";
check::classes(array("Foo","Bar"));
check::classmethods("foo",array("foo","ftest1","ftest2"));
check::classmethods("bar",array("__deref__","bar","test","ftest1","ftest2"));
$foo=new foo();
check::classname("foo",$foo);
$bar=new bar($foo);
check::classname("bar",$bar);
# check foo's ftest1, ftest2
check::equal(1,$foo->ftest1(1),"foo->ftest1");
check::equal(2,$foo->ftest2(1,2),"foo->ftest2");
# check bar's ftest1, ftest2, ftest
check::equal(1,$bar->ftest1(1),"bar->ftest1");
check::equal(2,$bar->ftest2(1,2),"bar->ftest2");
check::equal(3,$bar->test(),"bar->test");
# check deref returns foo
check::classname("foo",$bar->__deref__());
check::done();
?>

View file

@ -0,0 +1,23 @@
<?php
// Sample test file
require "tests.php";
require "sym.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(flim,flam));
// now new vars
check::globals(array());
$flim=new flim();
$flam=new flam();
check::equal($flim->hulahoops(),"flim-jam","flim()->hulahoops==flim-jam");
check::equal($flim->jar(),"flim-jar","flim()->jar==flim-jar");
check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam");
check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar");
check::done();
?>

View file

@ -0,0 +1,19 @@
<?php
// Sample test file
require "tests.php";
require "template_arg_typename.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(UnaryFunction_bool_bool,BoolUnaryFunction_bool));
$ufbb=new unaryfunction_bool_bool();
check::is_a($ufbb,"unaryfunction_bool_bool");
unset($whatisthis);
$bufb=new boolunaryfunction_bool(&$whatisthis);
check::is_a($bufb,"boolunaryfunction_bool");
check::done();
?>

View file

@ -0,0 +1,11 @@
<?php
require "tests.php";
require "template_construct.php";
check::classes(array(Foo_int));
$foo_int=new foo_int(3);
check::is_a($foo_int,"foo_int","Made a foo_int");
check::done();
?>

View file

@ -0,0 +1,227 @@
<?php
// do we have true global vars or just GETSET functions?
// Used to filter out get/set global functions to fake vars...
define(GETSET,1);
$_original_functions=get_defined_functions();
$_original_globals=1;
$_original_classes=get_declared_classes();
$_original_globals=array_keys($GLOBALS);
class check {
function get_extra_classes($ref=FALSE) {
static $extra;
global $_original_classes;
if ($ref===FALSE) $f=$_original_classes;
if (! is_array($extra)) {
$df=array_flip(get_declared_classes());
foreach($_original_classes as $class) unset($df[$class]);
$extra=array_keys($df);
}
return $extra;
}
function get_extra_functions($ref=FALSE,$gs=false) {
static $extra;
static $extrags; // for get/setters
global $_original_functions;
if ($ref===FALSE) $f=$_original_functions;
if (! is_array($extra) || $gs) {
$extra=array();
$extrags=array();
$df=get_defined_functions();
$df=array_flip($df[internal]);
foreach($_original_functions[internal] as $func) unset($df[$func]);
// Now chop out any get/set accessors
foreach(array_keys($df) as $func) if (GETSET && ereg('_[gs]et$',$func)) $extrags[]=$func;
else $extra[]=$func;
// $extra=array_keys($df);
}
if ($gs) return $extrags;
return $extra;
}
function get_extra_globals($ref=FALSE) {
static $extra;
global $_original_globals;
if (! is_array($extra)) {
if (GETSET) {
$_extra=array();
foreach(check::get_extra_functions(false,1) as $global) {
if (ereg('^(.*)_[sg]et$',$global,$match)) $_extra[$match[1]]=1;
}
$extra=array_keys($_extra);
} else {
if ($ref===FALSE) $ref=$_original_globals;
if (! is_array($extra)) {
$df=array_flip(array_keys($GLOBALS));
foreach($_original_globals as $func) unset($df[$func]);
// MASK xxxx_LOADED__ variables
foreach(array_keys($df) as $func) if (ereg('_LOADED__$',$func)) unset($df[$func]);
$extra=array_keys($df);
}
}
}
return $extra;
}
function classname($string,$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) {
if (is_object($classname)) $classname=get_class($classname);
$classmethods=array_flip(get_class_methods($classname));
$missing=array();
$extra=array();
foreach($methods as $method) {
if (! isset($classmethods[$method])) $missing[]=$method;
else unset($classmethods[$method]);
}
$extra=array_keys($classmethods);
if ($missing) $message[]="does not have these methods:\n ".join(",",$missing);
if ($message) {
return check::fail("Class %s %s\nFull class list:\n %s\n",$classname,join("\nbut ",$message),join("\n ",get_class_methods($classname)));
}
if ($extra) $message[]="Class ".$classname." has these extra methods:\n ".join(",",$extra);
if ($message) return check::warn(join("\n ",$message));
return TRUE;
}
function set($var,$value) {
$func=$var."_set";
if (GETSET) $func($value);
else $_GLOBALS[$var]=$value;
}
function &get($var) {
$func=$var."_get";
if (GETSET) return $func();
else return $_GLOBALS[$var];
}
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();
$c=$a;
while($c!=$b && $c) {
$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));
return TRUE;
}
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);
if ($parent!=$b) return check::fail("Class $a parent not actually $b but $parent");
return TRUE;
}
function classes($classes) {
if (! is_array($classes)) $classes=array($classes);
$message=array();
$missing=array();
$extra=array_flip(check::get_extra_classes());
foreach($classes as $class) {
if (! class_exists($class)) $missing[]=$class;
else unset($extra[$class]);
}
if ($missing) $message[]=sprintf("Classes missing: %s",join(",",$missing));
if ($message) return check::fail(join("\n ",$message));
if ($extra) $message[]=sprintf("These extra classes are defined: %s",join(",",array_keys($extra)));
if ($message) return check::warn(join("\n ",$message));
return TRUE;
}
function functions($functions) {
if (! is_array($functions)) $functions=array($functions);
$message=array();
$missing=array();
$extra=array_flip(check::get_extra_functions());
foreach ($functions as $func) {
if (! function_exists($func)) $missing[]=$func;
else unset($extra[$func]);
}
if ($missing) $message[]=sprintf("Functions missing: %s",join(",",$missing));
if ($message) return check::fail(join("\n ",$message));
if ($extra) $message[]=sprintf("These extra functions are defined: %s",join(",",array_keys($extra)));
if ($message) return check::warn(join("\n ",$message));
return TRUE;
}
function globals($globals) {
if (! is_array($globals)) $globals=array($globals);
$message=array();
$missing=array();
$extra=array_flip(check::get_extra_globals());
foreach ($globals as $glob) {
if (GETSET) {
if (! isset($extra[$glob])) $missing[]=$glob;
else unset($extra[$glob]);
} else {
if (! isset($GLOBALS[$glob])) $missing[]=$glob;
else unset($extra[$glob]);
}
}
if ($missing) $message[]=sprintf("Globals missing: %s",join(",",$missing));
if ($message) return check::fail(join("\n ",$message));
if ($extra) $message[]=sprintf("These extra globals are defined: %s",join(",",array_keys($extra)));
if ($message) return check::warn(join("\n ",$message));
return TRUE;
}
function functionref($a,$type,$message) {
if (! eregi("^_[a-f0-9]+$type$",$a)) return check::fail($message);
return TRUE;
}
function equal($a,$b,$message) {
if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
return TRUE;
}
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;
}
function isnull($a,$message) {
$value=trim(check::var_dump($a));
return check::equal($value,"NULL",$message);
}
function var_dump($arg) {
ob_start();
var_dump($arg);
$result=ob_get_contents();
ob_end_clean();
return $result;
}
function fail($pattern) {
$args=func_get_args();
print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
exit(1);
}
function warn($pattern) {
$args=func_get_args();
print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
return FALSE;
}
function done() {
# print $_SERVER[argv][0]." ok\n";
}
}
?>

View file

@ -0,0 +1,13 @@
<?php
require "tests.php";
require "typedef_reference.php";
check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
$int2=copy_intp(2);
check::equal(2,somefunc($int2)," test passing intp to somefunc");
$int3=copy_intp(3);
check::equal(3,otherfunc($int3)," test passing intp to otherfunc");
check::done();
?>

View file

@ -0,0 +1,9 @@
<?php
require "tests.php";
require "typemap_ns_using.php";
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

@ -0,0 +1,9 @@
<?php
require "tests.php";
require "using1.php";
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

@ -0,0 +1,9 @@
<?php
require "tests.php";
require "using2.php";
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

@ -0,0 +1,14 @@
<?php
// Sample test file
require "tests.php";
require "valuewrapper_base.php";
check::classes(array("valuewrapper_base","Base","Interface_BP"));
check::functions("make_interface_bp");
$ibp=make_interface_bp();
check::classname("interface_bp",$ibp);
check::done();
?>