The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
67
SWIG/Examples/test-suite/php4/Makefile
Normal file
67
SWIG/Examples/test-suite/php4/Makefile
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#######################################################################
|
||||
# Makefile for php4 test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = php4
|
||||
SCRIPTSUFFIX = _runme.php4
|
||||
|
||||
include ../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SWIGOPT = -I$(TOP)/../Lib -I$(TOP)/$(TEST_SUITE)
|
||||
TARGETPREFIX = php_
|
||||
|
||||
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.php4 ] ; then make clean && make $${test}.cpptest; fi ; done'
|
||||
|
||||
runctests:
|
||||
@bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then make clean && make $${test}.cpptest; fi; done'
|
||||
|
||||
runtests: runcpptests runctests
|
||||
|
||||
# write out tests without a _runme.php4
|
||||
missingcpptests:
|
||||
@bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
|
||||
|
||||
missingctests:
|
||||
@bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || 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.php4 appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $*\_runme.php4 ]; then ( \
|
||||
env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH php -q -d extension_dir=. $*\_runme.php4;) \
|
||||
fi;
|
||||
|
||||
# Clean: remove the generated .php file
|
||||
%.clean:
|
||||
@rm -f $*.php;
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile php4_clean
|
||||
13
SWIG/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
Normal file
13
SWIG/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
require "abstract_inherit_ok.php";
|
||||
|
||||
check::classes(array(foo,spam));
|
||||
$spam=new Spam();
|
||||
|
||||
check::equal(0,$spam->blah(),"spam object method");
|
||||
check::equal(0,Spam::blah($spam),"spam class method");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
14
SWIG/Examples/test-suite/php4/abstract_inherit_runme.php4
Normal file
14
SWIG/Examples/test-suite/php4/abstract_inherit_runme.php4
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
require "abstract_inherit.php";
|
||||
|
||||
check::classes(array(foo,bar,spam));
|
||||
// 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();
|
||||
?>
|
||||
23
SWIG/Examples/test-suite/php4/add_link_runme.php4
Normal file
23
SWIG/Examples/test-suite/php4/add_link_runme.php4
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "add_link.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// No new classes
|
||||
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();
|
||||
?>
|
||||
13
SWIG/Examples/test-suite/php4/anonymous_arg_runme.php4
Normal file
13
SWIG/Examples/test-suite/php4/anonymous_arg_runme.php4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "anonymous_arg.php";
|
||||
|
||||
check::functions(array(foo));
|
||||
// these two should perform without error
|
||||
foo();
|
||||
foo(7);
|
||||
|
||||
check::done();
|
||||
?>
|
||||
37
SWIG/Examples/test-suite/php4/argout_runme.php4
Normal file
37
SWIG/Examples/test-suite/php4/argout_runme.php4
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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=2;
|
||||
check::equal(2,incp(&$p),"2==incp($p)");
|
||||
check::equal(3,$p,"3==$p");
|
||||
|
||||
$r=7;
|
||||
check::equal(7,incr(&$r),"7==incr($r)");
|
||||
check::equal(8,$r,"8==$r");
|
||||
|
||||
$tr=4;
|
||||
check::equal(4,inctr(&$tr),"4==incr($tr)");
|
||||
check::equal(5,$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();
|
||||
?>
|
||||
15
SWIG/Examples/test-suite/php4/arrayptr_runme.php4
Normal file
15
SWIG/Examples/test-suite/php4/arrayptr_runme.php4
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "arrayptr.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(foo));
|
||||
// No new classes
|
||||
check::classes(array());
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
check::done();
|
||||
?>
|
||||
16
SWIG/Examples/test-suite/php4/arrays_global_runme.php4
Normal file
16
SWIG/Examples/test-suite/php4/arrays_global_runme.php4
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "arrays_global.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// No new classes
|
||||
check::classes(array(simplestruct));
|
||||
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));
|
||||
check::set(array_c,"hac");
|
||||
check::equal("ha",check::get(array_c,"ha"),"set array_c");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "arrays_global_twodim.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(fn_taking_arrays,get_2d_array));
|
||||
// No new classes
|
||||
check::classes(array(simplestruct));
|
||||
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));
|
||||
$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();
|
||||
?>
|
||||
22
SWIG/Examples/test-suite/php4/arrays_runme.php4
Normal file
22
SWIG/Examples/test-suite/php4/arrays_runme.php4
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "arrays.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer));
|
||||
// No new classes
|
||||
check::classes(array(simplestruct,arraystruct));
|
||||
// now 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();
|
||||
?>
|
||||
17
SWIG/Examples/test-suite/php4/arrays_scope_runme.php4
Normal file
17
SWIG/Examples/test-suite/php4/arrays_scope_runme.php4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "arrays_scope.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// No new classes
|
||||
check::classes(array(bar));
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
$bar=new bar();
|
||||
|
||||
check::done();
|
||||
?>
|
||||
20
SWIG/Examples/test-suite/php4/bool_default_runme.php4
Normal file
20
SWIG/Examples/test-suite/php4/bool_default_runme.php4
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "bool_default.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(foo));
|
||||
// No new classes
|
||||
check::classes(array());
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
check::equal(false,foo(),"foo()==false");
|
||||
check::equal(false,foo(1),"foo(1)==false");
|
||||
check::equal(false,foo(true),"foo(true)==false");
|
||||
check::equal(true,foo(false),"foo(false)==true");
|
||||
check::equal(true,foo(0),"foo(0)==true");
|
||||
check::done();
|
||||
?>
|
||||
19
SWIG/Examples/test-suite/php4/casts_runme.php4
Normal file
19
SWIG/Examples/test-suite/php4/casts_runme.php4
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "casts.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// 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();
|
||||
?>
|
||||
19
SWIG/Examples/test-suite/php4/class_ignore_runme.php4
Normal file
19
SWIG/Examples/test-suite/php4/class_ignore_runme.php4
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "class_ignore.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(do_blah));
|
||||
// No new classes
|
||||
check::classes(array(bar));
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
$bar=new bar();
|
||||
do_blah($bar);
|
||||
check::classparent($bar,"");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
require "conversion_ns_template.php";
|
||||
|
||||
check::classes(array("foo_one","bar_one"));
|
||||
// this is too hard, I'm not sure what to test for,
|
||||
|
||||
check::done();
|
||||
?>
|
||||
14
SWIG/Examples/test-suite/php4/conversion_runme.php4
Normal file
14
SWIG/Examples/test-suite/php4/conversion_runme.php4
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "conversion.php";
|
||||
|
||||
check::classes(array("foo","bar"));
|
||||
$bar=new Bar;
|
||||
check::classname("bar",$bar);
|
||||
$foo=$bar->toFoo();
|
||||
check::classname("foo",$foo);
|
||||
|
||||
check::done();
|
||||
?>
|
||||
15
SWIG/Examples/test-suite/php4/cpp_static_runme.php4
Normal file
15
SWIG/Examples/test-suite/php4/cpp_static_runme.php4
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
17
SWIG/Examples/test-suite/php4/enum_scope_runme.php4
Normal file
17
SWIG/Examples/test-suite/php4/enum_scope_runme.php4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "enum_scope.php";
|
||||
|
||||
check::classes("tree");
|
||||
check::functions("chops");
|
||||
check::equal(0,Tree_Oak,"0==Tree_Oak");
|
||||
check::equal(1,Tree_Fir,"1==Tree_Fir");
|
||||
check::equal(2,Tree_Cedar,"2==Tree_Cedar");
|
||||
check::equal(Tree_Oak,chops(Tree_Oak),"Tree_Oak==chops(Tree_Oak)");
|
||||
check::equal(Tree_Fir,chops(Tree_Fir),"Tree_Fir==chops(Tree_Fir)");
|
||||
check::equal(Tree_Cedar,chops(Tree_Cedar),"Tree_Cedar==chops(Tree_Cedar)");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
17
SWIG/Examples/test-suite/php4/enum_scope_template_runme.php4
Normal file
17
SWIG/Examples/test-suite/php4/enum_scope_template_runme.php4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "enum_scope_template.php";
|
||||
|
||||
check::classes("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();
|
||||
?>
|
||||
19
SWIG/Examples/test-suite/php4/evil_diamond_ns_runme.php4
Normal file
19
SWIG/Examples/test-suite/php4/evil_diamond_ns_runme.php4
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "evil_diamond_ns.php";
|
||||
|
||||
check::classes(array("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();
|
||||
?>
|
||||
38
SWIG/Examples/test-suite/php4/evil_diamond_prop_runme.php4
Normal file
38
SWIG/Examples/test-suite/php4/evil_diamond_prop_runme.php4
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "evil_diamond_prop.php";
|
||||
|
||||
check::classes(array("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();
|
||||
?>
|
||||
17
SWIG/Examples/test-suite/php4/evil_diamond_runme.php4
Normal file
17
SWIG/Examples/test-suite/php4/evil_diamond_runme.php4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "evil_diamond.php";
|
||||
|
||||
check::classes(array("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();
|
||||
?>
|
||||
13
SWIG/Examples/test-suite/php4/extend_template_ns_runme.php4
Normal file
13
SWIG/Examples/test-suite/php4/extend_template_ns_runme.php4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "extend_template_ns.php";
|
||||
|
||||
check::classes(array("foo_one"));
|
||||
$foo=new Foo_One();
|
||||
check::equal(2,$foo->test1(2),"test1");
|
||||
check::equal(3,$foo->test2(3),"test2");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
13
SWIG/Examples/test-suite/php4/extend_template_runme.php4
Normal file
13
SWIG/Examples/test-suite/php4/extend_template_runme.php4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
24
SWIG/Examples/test-suite/php4/grouping_runme.php4
Normal file
24
SWIG/Examples/test-suite/php4/grouping_runme.php4
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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::functionref(NEGATE,"_p_UnaryOp","NEGATE=_p_UnaryOp");
|
||||
check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
39
SWIG/Examples/test-suite/php4/ignore_parameter_runme.php4
Normal file
39
SWIG/Examples/test-suite/php4/ignore_parameter_runme.php4
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
15
SWIG/Examples/test-suite/php4/lib_carrays_runme.php4
Normal file
15
SWIG/Examples/test-suite/php4/lib_carrays_runme.php4
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "lib_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();
|
||||
?>
|
||||
17
SWIG/Examples/test-suite/php4/rename_scope_runme.php4
Normal file
17
SWIG/Examples/test-suite/php4/rename_scope_runme.php4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "rename_scope.php";
|
||||
|
||||
check::classes(array("interface_up","interface_bp","natural_up","natural_bp"));
|
||||
|
||||
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();
|
||||
?>
|
||||
15
SWIG/Examples/test-suite/php4/skel.php4
Normal file
15
SWIG/Examples/test-suite/php4/skel.php4
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "____.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// No new classes
|
||||
check::classes(array());
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
23
SWIG/Examples/test-suite/php4/sym_runme.php4
Normal file
23
SWIG/Examples/test-suite/php4/sym_runme.php4
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
11
SWIG/Examples/test-suite/php4/template_construct_runme.php4
Normal file
11
SWIG/Examples/test-suite/php4/template_construct_runme.php4
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
217
SWIG/Examples/test-suite/php4/tests.php4
Normal file
217
SWIG/Examples/test-suite/php4/tests.php4
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
<?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 ($string!=($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 ($extra) $message[]="does have these extra methods:\n ".join(",",$extra);
|
||||
if ($message) {
|
||||
return check::fail("Class %s %s\nFull class list:\n %s\n",$classname,join("\nbut ",$message),join("\n ",get_class_methods($classname)));
|
||||
}
|
||||
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 ($extra) $message[]=sprintf("These extra classes are defined: %s",join(",",array_keys($extra)));
|
||||
if ($message) return check::fail(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 ($extra) $message[]=sprintf("These extra methods are defined: %s",join(",",array_keys($extra)));
|
||||
if ($message) return check::fail(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 ($extra) $message[]=sprintf("These extra globals are defined: %s",join(",",array_keys($extra)));
|
||||
if ($message) return check::fail(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);
|
||||
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 done() {
|
||||
print $_SERVER[argv][0]." ok\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
13
SWIG/Examples/test-suite/php4/typedef_reference_runme.php4
Normal file
13
SWIG/Examples/test-suite/php4/typedef_reference_runme.php4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
9
SWIG/Examples/test-suite/php4/using1_runme.php4
Normal file
9
SWIG/Examples/test-suite/php4/using1_runme.php4
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
9
SWIG/Examples/test-suite/php4/using2_runme.php4
Normal file
9
SWIG/Examples/test-suite/php4/using2_runme.php4
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php4";
|
||||
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();
|
||||
?>
|
||||
14
SWIG/Examples/test-suite/php4/valuewrapper_base_runme.php4
Normal file
14
SWIG/Examples/test-suite/php4/valuewrapper_base_runme.php4
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php4";
|
||||
require "valuewrapper_base.php";
|
||||
|
||||
check::classes(array("base","interface_bp"));
|
||||
check::functions("make_interface_bp");
|
||||
|
||||
$ibp=make_interface_bp();
|
||||
check::classname("interface_bp",$ibp);
|
||||
|
||||
check::done();
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue