Remove support for PHP5

PHP5 is no longer actively supported by the PHP developers and security
support for it ends completely at the end of 2018, so it doesn't make
sense to include support for it in the upcoming SWIG 4.0.0 release.

See #701.
This commit is contained in:
Olly Betts 2018-06-07 18:04:45 +12:00
commit d6d5db122b
201 changed files with 94 additions and 11358 deletions

View file

@ -1,81 +0,0 @@
#######################################################################
# Makefile for php5 test-suite
#######################################################################
LANGUAGE = php5
SCRIPTSUFFIX = _runme.php
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
callback \
li_factory \
php_iterator \
php_namewarn_rename \
php_pragma \
include $(srcdir)/../common.mk
# Overridden variables here
TARGETPREFIX =# Should be php_ for Windows, empty otherwise
# Custom tests - tests with additional commandline options
prefix.cpptest: SWIGOPT += -prefix Project
# write out tests without a _runme.php
missingcpptests:
for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
missingctests:
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)
# Smart target
%.test:
@echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.ctest
@echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.cpptest
@echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.multicpptest
# Runs the testcase. Tries to run testcase_runme.php, and if that's not
# found, runs testcase.php, except for multicpptests.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php5_run; \
elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php5_run; \
fi
# Clean: remove the generated .php file
%.clean:
@rm -f $*.php php_$*.h
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' php5_clean
rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h
rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h
rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h
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

View file

@ -1,12 +0,0 @@
<?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

@ -1,14 +0,0 @@
<?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

@ -1,22 +0,0 @@
<?php
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

@ -1,38 +0,0 @@
<?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);
# FIXME: Call-time pass-by-reference has been deprecated for ages, and was
# removed in PHP 5.4. We need to rework
#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);
voidhandle($handle);
check::isnull($handle,'$handle not null');
check::done();
?>

View file

@ -1,14 +0,0 @@
<?php
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

@ -1,19 +0,0 @@
<?php
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,simplestruct_double_field));
// 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

@ -1,22 +0,0 @@
<?php
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,simplestruct_double_field));
$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

@ -1,18 +0,0 @@
<?php
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));
check::globals(array(simplestruct_double_field,arraystruct_array_c,arraystruct_array_sc,arraystruct_array_uc,arraystruct_array_s,arraystruct_array_us,arraystruct_array_i,arraystruct_array_ui,arraystruct_array_l,arraystruct_array_ul,arraystruct_array_ll,arraystruct_array_f,arraystruct_array_d,arraystruct_array_struct,arraystruct_array_structpointers,arraystruct_array_ipointers,arraystruct_array_enum,arraystruct_array_enumpointers,arraystruct_array_const_i,cartposedata_t_p));
$ss=new simplestruct();
check::classname(simplestruct,$ss);
$as=new arraystruct();
$as->array_c="abc";
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

@ -1,16 +0,0 @@
<?php
require "tests.php";
require "arrays_scope.php";
// New functions
check::functions(array(new_bar,bar_blah));
// New classes
check::classes(array(arrays_scope,Bar));
// New vars
check::globals(array(bar_adata,bar_bdata,bar_cdata));
$bar=new bar();
check::done();
?>

View file

@ -1,9 +0,0 @@
<?php
require "tests.php";
require "callback.php";
// In 2.0.6 and earlier, the constant was misnamed.
if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::FOO_I_Cb_Ptr not a resource\n");
check::done();
?>

View file

@ -1,18 +0,0 @@
<?php
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

@ -1,43 +0,0 @@
<?php
require "tests.php";
require "char_strings.php";
$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
$OTHERLAND_MSG_10 = "Little message from the safe world.10";
check::equal(GetCharHeapString(), $CPLUSPLUS_MSG, "failed GetCharHeapString");
check::equal(GetConstCharProgramCodeString(), $CPLUSPLUS_MSG, "failed GetConstCharProgramCodeString");
check::equal(GetCharStaticString(), $CPLUSPLUS_MSG, "failed GetCharStaticString");
check::equal(GetCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetCharStaticStringFixed");
check::equal(GetConstCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetConstCharStaticStringFixed");
check::equal(SetCharHeapString($OTHERLAND_MSG_10, 10), true, "failed GetConstCharStaticStringFixed");
check::equal(SetCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharStaticString");
check::equal(SetCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharArrayStaticString");
check::equal(SetConstCharHeapString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharHeapString");
check::equal(SetConstCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharStaticString");
check::equal(SetConstCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharArrayStaticString");
check::equal(CharPingPong($OTHERLAND_MSG_10), $OTHERLAND_MSG_10, "failed CharPingPong");
Global_char_set($OTHERLAND_MSG_10);
check::equal(Global_char_get(), $OTHERLAND_MSG_10, "failed Global_char_get");
Global_char_array1_set($OTHERLAND_MSG_10);
check::equal(Global_char_array1_get(), $OTHERLAND_MSG_10, "failed Global_char_array1_get");
Global_char_array2_set($OTHERLAND_MSG_10);
check::equal(Global_char_array2_get(), $OTHERLAND_MSG_10, "failed Global_char_array2_get");
check::equal(Global_const_char_get(), $CPLUSPLUS_MSG, "failed Global_const_char");
check::equal(Global_const_char_array1_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array1");
check::equal(Global_const_char_array2_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array2");
check::equal(GetCharPointerRef(), $CPLUSPLUS_MSG, "failed GetCharPointerRef");
check::equal(SetCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCharPointerRef");
check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPointerRef");
check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
check::done();
?>

View file

@ -1,16 +0,0 @@
<?php
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

@ -1,13 +0,0 @@
<?php
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

@ -1,10 +0,0 @@
<?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

@ -1,13 +0,0 @@
<?php
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

@ -1,169 +0,0 @@
<?php
require "tests.php";
require "cpp11_strongly_typed_enumerations.php";
function enumCheck($actual, $expected) {
check::equal($actual, $expected, "Enum value mismatch");
return $expected + 1;
}
$val = 0;
$val = enumCheck(Enum1_Val1, $val);
$val = enumCheck(Enum1_Val2, $val);
$val = enumCheck(Enum1_Val3, 13);
$val = enumCheck(Enum1_Val4, $val);
$val = enumCheck(Enum1_Val5a, 13);
$val = enumCheck(Enum1_Val6a, $val);
$val = 0;
$val = enumCheck(Enum2_Val1, $val);
$val = enumCheck(Enum2_Val2, $val);
$val = enumCheck(Enum2_Val3, 23);
$val = enumCheck(Enum2_Val4, $val);
$val = enumCheck(Enum2_Val5b, 23);
$val = enumCheck(Enum2_Val6b, $val);
$val = 0;
$val = enumCheck(Val1, $val);
$val = enumCheck(Val2, $val);
$val = enumCheck(Val3, 43);
$val = enumCheck(Val4, $val);
$val = 0;
$val = enumCheck(Enum5_Val1, $val);
$val = enumCheck(Enum5_Val2, $val);
$val = enumCheck(Enum5_Val3, 53);
$val = enumCheck(Enum5_Val4, $val);
$val = 0;
$val = enumCheck(Enum6_Val1, $val);
$val = enumCheck(Enum6_Val2, $val);
$val = enumCheck(Enum6_Val3, 63);
$val = enumCheck(Enum6_Val4, $val);
$val = 0;
$val = enumCheck(Enum7td_Val1, $val);
$val = enumCheck(Enum7td_Val2, $val);
$val = enumCheck(Enum7td_Val3, 73);
$val = enumCheck(Enum7td_Val4, $val);
$val = 0;
$val = enumCheck(Enum8_Val1, $val);
$val = enumCheck(Enum8_Val2, $val);
$val = enumCheck(Enum8_Val3, 83);
$val = enumCheck(Enum8_Val4, $val);
$val = 0;
$val = enumCheck(Enum10_Val1, $val);
$val = enumCheck(Enum10_Val2, $val);
$val = enumCheck(Enum10_Val3, 103);
$val = enumCheck(Enum10_Val4, $val);
$val = 0;
$val = enumCheck(Class1::Enum12_Val1, 1121);
$val = enumCheck(Class1::Enum12_Val2, 1122);
$val = enumCheck(Class1::Enum12_Val3, $val);
$val = enumCheck(Class1::Enum12_Val4, $val);
$val = enumCheck(Class1::Enum12_Val5c, 1121);
$val = enumCheck(Class1::Enum12_Val6c, $val);
$val = 0;
$val = enumCheck(Class1::Val1, 1131);
$val = enumCheck(Class1::Val2, 1132);
$val = enumCheck(Class1::Val3, $val);
$val = enumCheck(Class1::Val4, $val);
$val = enumCheck(Class1::Val5d, 1131);
$val = enumCheck(Class1::Val6d, $val);
$val = 0;
$val = enumCheck(Class1::Enum14_Val1, 1141);
$val = enumCheck(Class1::Enum14_Val2, 1142);
$val = enumCheck(Class1::Enum14_Val3, $val);
$val = enumCheck(Class1::Enum14_Val4, $val);
$val = enumCheck(Class1::Enum14_Val5e, 1141);
$val = enumCheck(Class1::Enum14_Val6e, $val);
# Requires nested class support to work
#$val = 0;
#$val = enumCheck(Class1::Struct1.Enum12_Val1, 3121);
#$val = enumCheck(Class1::Struct1.Enum12_Val2, 3122);
#$val = enumCheck(Class1::Struct1.Enum12_Val3, $val);
#$val = enumCheck(Class1::Struct1.Enum12_Val4, $val);
#$val = enumCheck(Class1::Struct1.Enum12_Val5f, 3121);
#$val = enumCheck(Class1::Struct1.Enum12_Val6f, $val);
#
#$val = 0;
#$val = enumCheck(Class1::Struct1.$val1, 3131);
#$val = enumCheck(Class1::Struct1.$val2, 3132);
#$val = enumCheck(Class1::Struct1.$val3, $val);
#$val = enumCheck(Class1::Struct1.$val4, $val);
#
#$val = 0;
#$val = enumCheck(Class1::Struct1.Enum14_Val1, 3141);
#$val = enumCheck(Class1::Struct1.Enum14_Val2, 3142);
#$val = enumCheck(Class1::Struct1.Enum14_Val3, $val);
#$val = enumCheck(Class1::Struct1.Enum14_Val4, $val);
#$val = enumCheck(Class1::Struct1.Enum14_Val5g, 3141);
#$val = enumCheck(Class1::Struct1.Enum14_Val6g, $val);
$val = 0;
$val = enumCheck(Class2::Enum12_Val1, 2121);
$val = enumCheck(Class2::Enum12_Val2, 2122);
$val = enumCheck(Class2::Enum12_Val3, $val);
$val = enumCheck(Class2::Enum12_Val4, $val);
$val = enumCheck(Class2::Enum12_Val5h, 2121);
$val = enumCheck(Class2::Enum12_Val6h, $val);
$val = 0;
$val = enumCheck(Class2::Val1, 2131);
$val = enumCheck(Class2::Val2, 2132);
$val = enumCheck(Class2::Val3, $val);
$val = enumCheck(Class2::Val4, $val);
$val = enumCheck(Class2::Val5i, 2131);
$val = enumCheck(Class2::Val6i, $val);
$val = 0;
$val = enumCheck(Class2::Enum14_Val1, 2141);
$val = enumCheck(Class2::Enum14_Val2, 2142);
$val = enumCheck(Class2::Enum14_Val3, $val);
$val = enumCheck(Class2::Enum14_Val4, $val);
$val = enumCheck(Class2::Enum14_Val5j, 2141);
$val = enumCheck(Class2::Enum14_Val6j, $val);
# Requires nested class support to work
#$val = 0;
#$val = enumCheck(Class2::Struct1.Enum12_Val1, 4121);
#$val = enumCheck(Class2::Struct1.Enum12_Val2, 4122);
#$val = enumCheck(Class2::Struct1.Enum12_Val3, $val);
#$val = enumCheck(Class2::Struct1.Enum12_Val4, $val);
#$val = enumCheck(Class2::Struct1.Enum12_Val5k, 4121);
#$val = enumCheck(Class2::Struct1.Enum12_Val6k, $val);
#
#$val = 0;
#$val = enumCheck(Class2::Struct1.$val1, 4131);
#$val = enumCheck(Class2::Struct1.$val2, 4132);
#$val = enumCheck(Class2::Struct1.$val3, $val);
#$val = enumCheck(Class2::Struct1.$val4, $val);
#$val = enumCheck(Class2::Struct1.$val5l, 4131);
#$val = enumCheck(Class2::Struct1.$val6l, $val);
#
#$val = 0;
#$val = enumCheck(Class2::Struct1.Enum14_Val1, 4141);
#$val = enumCheck(Class2::Struct1.Enum14_Val2, 4142);
#$val = enumCheck(Class2::Struct1.Enum14_Val3, $val);
#$val = enumCheck(Class2::Struct1.Enum14_Val4, $val);
#$val = enumCheck(Class2::Struct1.Enum14_Val5m, 4141);
#$val = enumCheck(Class2::Struct1.Enum14_Val6m, $val);
$class1 = new Class1();
enumCheck($class1->class1Test1(Enum1_Val5a), 13);
enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121);
#enumCheck($class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121);
enumCheck(globalTest1(Enum1_Val5a), 13);
enumCheck(globalTest2(Class1::Enum12_Val5c), 1121);
#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121);
?>

View file

@ -1,20 +0,0 @@
<?php
require "tests.php";
require "cpp_basic.php";
// New functions
check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
// New classes
check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
// New vars
check::globals(array(foo_num,foo_func_ptr,bar_fptr,bar_fref,bar_fval,bar_cint,bar_global_fptr,bar_global_fref,bar_global_fval));
$f = new Foo(3);
$f->func_ptr = get_func1_ptr();
check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
$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

@ -1,14 +0,0 @@
<?php
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));
// New classes
check::classes(array(StaticMemberTest,StaticFunctionTest,cpp_static,StaticBase,StaticDerived));
// New vars
check::globals(array(staticmembertest_static_int,staticbase_statty,staticderived_statty));
check::done();
?>

View file

@ -1,62 +0,0 @@
<?php
require "tests.php";
require "director_abstract.php";
// No new functions
check::functions(array(foo_ping,foo_pong,example0_getxsize,example0_color,example0_get_color,example1_getxsize,example1_color,example1_get_color,example2_getxsize,example2_color,example2_get_color,example4_getxsize,example4_color,example4_get_color,example3_i_color,example3_i_get_color,g,a_f));
// No new classes
check::classes(array(director_abstract,Foo,Example0,Example1,Example2,Example4,Example3_i,A));
// now new vars
check::globals(array());
class MyFoo extends Foo {
function ping() {
return "MyFoo::ping()";
}
}
$a = new MyFoo();
check::equal($a->ping(), "MyFoo::ping()", "MyFoo::ping failed");
check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed");
class MyExample1 extends Example1 {
function Color($r, $g, $b) {
return $r;
}
}
class MyExample2 extends Example1 {
function Color($r, $g, $b) {
return $g;
}
}
class MyExample3 extends Example1 {
function Color($r, $g, $b) {
return $b;
}
}
$me1 = new MyExample1();
check::equal($me1->Color(1, 2, 3), 1, "Example1_get_color failed");
$me2 = new MyExample2(1, 2);
check::equal($me2->Color(1, 2, 3), 2, "Example2_get_color failed");
$me3 = new MyExample3();
check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed");
$class = new ReflectionClass('Example1');
check::equal($class->isAbstract(), true, "Example1 abstractness failed");
$class = new ReflectionClass('Example2');
check::equal($class->isAbstract(), true, "Example2 abstractness failed");
$class = new ReflectionClass('Example3_i');
check::equal($class->isAbstract(), true, "Example3_i abstractness failed");
check::done();
?>

View file

@ -1,58 +0,0 @@
<?php
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));
// now new vars
check::globals(array(bar_x));
class PhpFoo extends Foo {
function ping() {
return "PhpFoo::ping()";
}
}
$a = new PhpFoo();
check::equal($a->ping(), "PhpFoo::ping()", "ping failed");
check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed");
$b = new Foo();
check::equal($b->ping(), "Foo::ping()", "ping failed");
check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed");
$a = new A1(1);
check::equal($a->rg(2), 2, "rg failed");
class PhpClass extends MyClass {
function vmethod($b) {
$b->x = $b->x + 31;
return $b;
}
}
$b = new Bar(3);
$d = new MyClass();
$c = new PhpClass();
$cc = MyClass::get_self($c);
$dd = MyClass::get_self($d);
$bc = $cc->cmethod($b);
$bd = $dd->cmethod($b);
$cc->method($b);
check::equal($bc->x, 34, "bc failed");
check::equal($bd->x, 16, "bd failed");
check::done();
?>

View file

@ -1,150 +0,0 @@
<?php
require "tests.php";
require "director_classic.php";
// No new functions
check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
// No new classes
check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
// now new vars
check::globals(array());
class TargetLangPerson extends Person {
function id() {
$identifier = "TargetLangPerson";
return $identifier;
}
}
class TargetLangChild extends Child {
function id() {
$identifier = "TargetLangChild";
return $identifier;
}
}
class TargetLangGrandChild extends GrandChild {
function id() {
$identifier = "TargetLangGrandChild";
return $identifier;
}
}
# Semis - don't override id() in target language
class TargetLangSemiPerson extends Person {
# No id() override
}
class TargetLangSemiChild extends Child {
# No id() override
}
class TargetLangSemiGrandChild extends GrandChild {
# No id() override
}
# Orphans - don't override id() in C++
class TargetLangOrphanPerson extends OrphanPerson {
function id() {
$identifier = "TargetLangOrphanPerson";
return $identifier;
}
}
class TargetLangOrphanChild extends OrphanChild {
function id() {
$identifier = "TargetLangOrphanChild";
return $identifier;
}
}
function mycheck($person, $expected) {
$debug = 0;
# Normal target language polymorphic call
$ret = $person->id();
if ($debug)
print $ret . "\n";
check::equal($ret, $expected, "#1 failed");
# Polymorphic call from C++
$caller = new Caller();
$caller->setCallback($person);
$ret = $caller->call();
if ($debug)
print $ret . "\n";
check::equal($ret, $expected, "#2 failed");
# Polymorphic call of object created in target language and passed to
# C++ and back again
$baseclass = $caller->baseClass();
$ret = $baseclass->id();
if ($debug)
print $ret . "\n";
# TODO: Currently we do not track the dynamic type of returned
# objects, so in case it's possible that the dynamic type is not equal
# to the static type, we skip this check.
if (get_parent_class($person) === false)
check::equal($ret, $expected, "#3 failed");
$caller->resetCallback();
if ($debug)
print "----------------------------------------\n";
}
$person = new Person();
mycheck($person, "Person");
unset($person);
$person = new Child();
mycheck($person, "Child");
unset($person);
$person = new GrandChild();
mycheck($person, "GrandChild");
unset($person);
$person = new TargetLangPerson();
mycheck($person, "TargetLangPerson");
unset($person);
$person = new TargetLangChild();
mycheck($person, "TargetLangChild");
unset($person);
$person = new TargetLangGrandChild();
mycheck($person, "TargetLangGrandChild");
unset($person);
# Semis - don't override id() in target language
$person = new TargetLangSemiPerson();
mycheck($person, "Person");
unset($person);
$person = new TargetLangSemiChild();
mycheck($person, "Child");
unset($person);
$person = new TargetLangSemiGrandChild();
mycheck($person, "GrandChild");
unset($person);
# Orphans - don't override id() in C++
$person = new OrphanPerson();
mycheck($person, "Person");
unset($person);
$person = new OrphanChild();
mycheck($person, "Child");
unset($person);
$person = new TargetLangOrphanPerson();
mycheck($person, "TargetLangOrphanPerson");
unset($person);
$person = new TargetLangOrphanChild();
mycheck($person, "TargetLangOrphanChild");
unset($person);
check::done();
?>

View file

@ -1,20 +0,0 @@
<?php
require "tests.php";
require "director_default.php";
// No new functions
check::functions(array(foo_msg,foo_getmsg,bar_msg,bar_getmsg,defaultsbase_defaultargs,defaultsderived_defaultargs));
// No new classes
check::classes(array(Foo,Bar,DefaultsBase,DefaultsDerived));
// now new vars
check::globals(array());
$f = new Foo();
$f = new Foo(1);
$f = new Bar();
$f = new Bar(1);
check::done();
?>

View file

@ -1,55 +0,0 @@
<?php
require "tests.php";
require "director_detect.php";
// No new functions
check::functions(array(foo_cloner,foo_get_value,foo_get_class,foo_just_do_it,bar_baseclass,bar_cloner,bar_get_value,bar_get_class,bar_just_do_it));
// No new classes
check::classes(array(A,Foo,Bar));
// now new vars
check::globals(array());
class MyBar extends Bar {
function __construct($val = 2) {
parent::__construct();
$this->val = $val;
}
function get_value() {
$this->val = $this->val + 1;
return $this->val;
}
function get_class() {
$this->val = $this->val + 1;
return new A();
}
function just_do_it() {
$this->val = $this->val + 1;
}
/* clone is a reserved keyword */
function clone_() {
return new MyBar($this->val);
}
}
$b = new MyBar();
$f = $b->baseclass();
$v = $f->get_value();
$a = $f->get_class();
$f->just_do_it();
$c = $b->clone_();
$vc = $c->get_value();
check::equal($v, 3, "f: Bad virtual detection");
check::equal($b->val, 5, "b: Bad virtual detection");
check::equal($vc, 6, "c: Bad virtual detection");
check::done();
?>

View file

@ -1,25 +0,0 @@
<?php
require "tests.php";
require "director_enum.php";
// No new functions
check::functions(array(foo_say_hello,foo_say_hi,foo_say_bye,foo_say_hi_ref,foo_ping,foo_ping_ref,foo_ping_member_enum,a_f,a2_f));
// No new classes
check::classes(array(director_enum,Foo,A,B,A2,B2));
// now new vars
check::globals(array());
class MyFoo extends Foo {
function say_hi($val) {
return $val;
}
}
$b = new Foo();
$a = new MyFoo();
check::equal($a->say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed");
check::done();
?>

View file

@ -1,127 +0,0 @@
<?php
require "tests.php";
require "director_exception.php";
// No new functions
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));
// now new vars
check::globals(array());
class MyException extends Exception {
function __construct($a, $b) {
$this->msg = $a . $b;
}
}
class MyFoo extends Foo {
function ping() {
throw new Exception("MyFoo::ping() EXCEPTION");
}
}
class MyFoo2 extends Foo {
function ping() {
return true;
}
}
class MyFoo3 extends Foo {
function ping() {
throw new MyException("foo", "bar");
}
}
# Check that the Exception raised by MyFoo.ping() is returned by
# MyFoo.pong().
$ok = 0;
$a = new MyFoo();
# TODO: Currently we do not track the dynamic type of returned
# objects, so we skip the launder() call.
#$b = director_exception::launder($a);
$b = $a;
try {
$b->pong();
} catch (Exception $e) {
$ok = 1;
check::equal($e->getMessage(), "MyFoo::ping() EXCEPTION", "Unexpected error message #1");
}
check::equal($ok, 1, "Got no exception while expected one #1");
# Check that the director can return an exception which requires two
# arguments to the constructor, without mangling it.
$ok = 0;
$a = new MyFoo3();
#$b = director_exception::launder($a);
$b = $a;
try {
$b->pong();
} catch (Exception $e) {
$ok = 1;
check::equal($e->msg, "foobar", "Unexpected error message #2");
}
check::equal($ok, 1, "Got no exception while expected one #2");
try {
throw new Exception2();
} catch (Exception2 $e2) {
}
try {
throw new Exception1();
} catch (Exception1 $e1) {
}
// Check that we can throw exceptions from director methods (this didn't used
// to work in all cases, as the exception gets "set" in PHP and the method
// then returns PHP NULL, which the directorout template may fail to convert.
class Bad extends ReturnAllTypes {
function return_int() { throw new Exception("bad int"); }
function return_double() { throw new Exception("bad double"); }
function return_const_char_star() { throw new Exception("bad const_char_star"); }
function return_std_string() { throw new Exception("bad std_string"); }
function return_Bar() { throw new Exception("bad Bar"); }
}
$bad = new Bad();
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();
?>

View file

@ -1,24 +0,0 @@
<?php
require "tests.php";
require "director_extend.php";
// No new functions
check::functions(array(spobject_getfoobar,spobject_dummy,spobject_exceptionmethod));
// No new classes
check::classes(array(SpObject));
// now new vars
check::globals(array());
class MyObject extends SpObject{
function getFoo() {
return 123;
}
}
$m = new MyObject();
check::equal($m->dummy(), 666, "1st call");
check::equal($m->dummy(), 666, "2st call"); // Locked system
check::done();
?>

View file

@ -1,61 +0,0 @@
<?php
require "tests.php";
require "director_finalizer.php";
// No new functions
check::functions(array(foo_orstatus,deletefoo,getstatus,launder,resetstatus));
// No new classes
check::classes(array(director_finalizer,Foo));
// now new vars
check::globals(array());
class MyFoo extends Foo {
function __destruct() {
$this->orStatus(2);
if (method_exists(parent, "__destruct")) {
parent::__destruct();
}
}
}
resetStatus();
$a = new MyFoo();
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #1");
resetStatus();
$a = new MyFoo();
launder($a);
check::equal(getStatus(), 0, "getStatus() failed #2");
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #3");
resetStatus();
$a = new MyFoo();
$a->thisown = 0;
deleteFoo($a);
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #4");
resetStatus();
$a = new MyFoo();
$a->thisown = 0;
deleteFoo(launder($a));
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #5");
resetStatus();
check::done();
?>

View file

@ -1,19 +0,0 @@
<?php
require "tests.php";
require "director_frob.php";
// No new functions
check::functions(array(alpha_abs_method,bravo_abs_method,charlie_abs_method,ops_opint,ops_opintstarstarconst,ops_opintamp,ops_opintstar,ops_opconstintintstar,prims_ull,prims_callull,corecallbacks_on3dengineredrawn,corecallbacks_on3dengineredrawn2));
// No new classes
check::classes(array(Alpha,Bravo,Charlie,Delta,Ops,Prims,corePoint3d,coreCallbacks_On3dEngineRedrawnData,coreCallbacksOn3dEngineRedrawnData,coreCallbacks));
// now new vars
check::globals(array(corecallbacks_on3dengineredrawndata__eye,corecallbacks_on3dengineredrawndata__at,corecallbackson3dengineredrawndata__eye,corecallbackson3dengineredrawndata__at));
$foo = new Bravo();
$s = $foo->abs_method();
check::equal($s, "Bravo::abs_method()", "s failed");
check::done();
?>

View file

@ -1,74 +0,0 @@
<?php
require "tests.php";
require "director_nested.php";
// No new functions
check::functions(array(foo_int_advance,foo_int_do_advance,bar_step,bar_do_advance,bar_do_step,foobar_int_get_value,foobar_int_get_name,foobar_int_name,foobar_int_get_self,foobar_int_do_advance,foobar_int_do_step));
// No new classes
check::classes(array(Foo_int,Bar,FooBar_int));
// now new vars
check::globals(array());
class A extends FooBar_int {
function do_step() {
return "A::do_step;";
}
function get_value() {
return "A::get_value";
}
}
$a = new A();
check::equal($a->step(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", "Bad A virtual resolution");
class B extends FooBar_int {
function do_advance() {
return "B::do_advance;" . $this->do_step();
}
function do_step() {
return "B::do_step;";
}
function get_value() {
return 1;
}
}
$b = new B();
check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution");
class C extends FooBar_int {
function do_advance() {
return "C::do_advance;" . parent::do_advance();
}
function do_step() {
return "C::do_step;";
}
function get_value() {
return 2;
}
function get_name() {
return parent::get_name() . " hello";
}
}
$cc = new C();
# TODO: Currently we do not track the dynamic type of returned
# objects, so we skip the get_self() call.
#$c = Foobar_int::get_self($cc);
$c = $cc;
$c->advance();
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

@ -1,24 +0,0 @@
<?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();
?>

View file

@ -1,53 +0,0 @@
<?php
require "tests.php";
require "director_profile.php";
// No new functions
check::functions(array(b_fn,b_vfi,b_fi,b_fj,b_fk,b_fl,b_get_self,b_vfs,b_fs));
// No new classes
check::classes(array(A,B));
// now new vars
check::globals(array());
class MyB extends B {
function vfi($a) {
return $a+3;
}
}
$a = new A();
$myb = new MyB();
$b = B::get_self($myb);
$i = 50000;
$a = 1;
while ($i) {
$a = $b->fi($a); #1
$a = $b->fi($a); #2
$a = $b->fi($a); #3
$a = $b->fi($a); #4
$a = $b->fi($a); #5
$a = $b->fi($a); #6
$a = $b->fi($a); #7
$a = $b->fi($a); #8
$a = $b->fi($a); #9
$a = $b->fi($a); #10
$a = $b->fi($a); #1
$a = $b->fi($a); #2
$a = $b->fi($a); #3
$a = $b->fi($a); #4
$a = $b->fi($a); #5
$a = $b->fi($a); #6
$a = $b->fi($a); #7
$a = $b->fi($a); #8
$a = $b->fi($a); #9
$a = $b->fi($a); #20
$i -= 1;
}
print $a . "\n";
check::done();
?>

View file

@ -1,70 +0,0 @@
<?php
require "tests.php";
require "director_protected.php";
check::functions(array(foo_pong,foo_s,foo_q,foo_ping,foo_pang,foo_used,foo_cheer,bar_create,bar_callping,bar_callcheer,bar_cheer,bar_pong,bar_used,bar_ping,bar_pang,a_draw,b_draw));
check::classes(array(Foo,Bar,PrivateFoo,A,B,AA,BB));
check::globals(array(bar_a));
class FooBar extends Bar {
protected function ping() {
return "FooBar::ping();";
}
}
class FooBar2 extends Bar {
function ping() {
return "FooBar2::ping();";
}
function pang() {
return "FooBar2::pang();";
}
}
class FooBar3 extends Bar {
function cheer() {
return "FooBar3::cheer();";
}
}
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
$method = new ReflectionMethod('Bar', 'cheer');
check::equal($method->isProtected(), true, "Bar::cheer should be protected");
$method = new ReflectionMethod('Foo', 'cheer');
check::equal($method->isProtected(), true, "Foo::cheer should be protected");
check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
check::done();
?>

View file

@ -1,60 +0,0 @@
<?php
require "tests.php";
require "director_stl.php";
// No new functions
check::functions(array(foo_bar,foo_ping,foo_pong,foo_tping,foo_tpong,foo_pident,foo_vident,foo_vsecond,foo_tpident,foo_tvident,foo_tvsecond,foo_vidents,foo_tvidents));
// No new classes
check::classes(array(Foo));
// now new vars
check::globals(array());
class MyFoo extends Foo {
function ping($s) {
return "MyFoo::ping():" . $s;
}
function pident($arg) {
return $arg;
}
function vident($v) {
return $v;
}
function vidents($v) {
return $v;
}
function vsecond($v1, $v2) {
return $v2;
}
}
$a = new MyFoo();
$a->tping("hello");
$a->tpong("hello");
# TODO: automatic conversion between PHP arrays and std::pair or
# std::vector is not yet implemented.
/*$p = array(1, 2);
$a->pident($p);
$v = array(3, 4);
$a->vident($v);
$a->tpident($p);
$a->tvident($v);
$v1 = array(3, 4);
$v2 = array(5, 6);
$a->tvsecond($v1, $v2);
$vs = array("hi", "hello");
$vs;
$a->tvidents($vs);*/
check::done();
?>

View file

@ -1,34 +0,0 @@
<?php
require "tests.php";
require "director_string.php";
// No new functions
check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
// No new classes
check::classes(array(A,StringVector));
// now new vars
check::globals(array(a,a_call,a_m_strings,stringvector));
class B extends A {
function get_first() {
return parent::get_first() . " world!";
}
function process_text($string) {
parent::process_text($string);
$this->smem = "hello";
}
}
$b = new B("hello");
$b->get(0);
check::equal($b->get_first(),"hello world!", "get_first failed");
$b->call_process_func();
check::equal($b->smem, "hello", "smem failed");
check::done();
?>

View file

@ -1,32 +0,0 @@
<?php
require "tests.php";
require "director_thread.php";
# Fails in a ZTS-build of PHP - see: https://github.com/swig/swig/pull/155
exit(0);
// 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();
?>

View file

@ -1,29 +0,0 @@
<?php
require "tests.php";
require "director_unroll.php";
// No new functions
check::functions(array(foo_ping,foo_pong));
// No new classes
check::classes(array(Foo,Bar));
// now new vars
check::globals(array(bar));
class MyFoo extends Foo {
function ping() {
return "MyFoo::ping()";
}
}
$a = new MyFoo();
$b = new Bar();
$b->set($a);
$c = $b->get();
check::equal($a->this, $c->this, "this failed");
check::done();
?>

View file

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

@ -1,18 +0,0 @@
<?php
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

@ -1,38 +0,0 @@
<?php
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");
// multiple inheritance not supported in PHP
check::equal(null,$spam->_baz,"null==spam->_baz");
check::equal(4,$spam->_spam,"4==spam->_spam");
check::done();
?>

View file

@ -1,16 +0,0 @@
<?php
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

@ -1,39 +0,0 @@
<?
require "tests.php";
require "exception_order.php";
check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
$a = new A();
try {
$a->foo();
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
}
try {
$a->bar();
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ E2 exception thrown', '');
}
try {
$a->foobar();
} catch (Exception $e) {
check::equal($e->getMessage(), 'postcatch unknown', '');
}
try {
$a->barfoo(1);
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
}
try {
$a->barfoo(2);
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ E2 * exception thrown', '');
}
?>

View file

@ -1,12 +0,0 @@
<?php
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

@ -1,12 +0,0 @@
<?php
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

@ -1,22 +0,0 @@
<?php
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

@ -1,38 +0,0 @@
<?php
require "tests.php";
require "ignore_parameter.php";
// New functions
check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
// 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');
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

@ -1,20 +0,0 @@
<?php
require "tests.php";
require "import_nomodule.php";
// No new functions
check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
// No new classes
check::classes(array(import_nomodule,Bar));
// now new vars
check::globals(array());
$f = import_nomodule::create_Foo();
import_nomodule::test1($f,42);
import_nomodule::delete_Foo($f);
$b = new Bar();
import_nomodule::test1($b,37);
check::done();
?>

View file

@ -1,22 +0,0 @@
<?php
require "tests.php";
require "li_carrays_cpp.php";
// Check functions.
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
// Check classes.
// NB An "li_carrays_cpp" class is created as a mock namespace.
check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray));
// Check global variables.
check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
$d = new doubleArray(10);
$d->setitem(0, 7);
$d->setitem(5, $d->getitem(0) + 3);
check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
check::done();
?>

View file

@ -1,22 +0,0 @@
<?php
require "tests.php";
require "li_carrays.php";
// Check functions.
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
// Check classes.
// NB An "li_carrays" class is created as a mock namespace.
check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray));
// Check global variables.
check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
$d = new doubleArray(10);
$d->setitem(0, 7);
$d->setitem(5, $d->getitem(0) + 3);
check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
check::done();
?>

View file

@ -1,22 +0,0 @@
<?php
require "tests.php";
require "li_factory.php";
// No new functions
check::functions(array(geometry_draw,geometry_create,geometry_clone_,point_draw,point_width,point_clone_,circle_draw,circle_radius,circle_clone_));
// No new classes
check::classes(array(Geometry,Point,Circle));
// now new vars
check::globals(array());
$circle = Geometry::create(Geometry::CIRCLE);
$r = $circle->radius();
check::equal($r, 1.5, "r failed");
$point = Geometry::create(Geometry::POINT);
$w = $point->width();
check::equal($w, 1.0, "w failed");
check::done();
?>

View file

@ -1,31 +0,0 @@
<?php
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

@ -1,30 +0,0 @@
<?php
require "tests.php";
require "li_std_vector_member_var.php";
$t = new Test();
check::equal($t->x, 0, "Test::x != 0");
check::equal($t->v->size(), 0, "Test::v.size() != 0");
$t->f(1);
check::equal($t->x, 1, "Test::x != 1");
check::equal($t->v->size(), 1, "Test::v.size() != 1");
$t->f(2);
check::equal($t->x, 3, "Test::x != 3");
check::equal($t->v->size(), 2, "Test::v.size() != 2");
$t->f(3);
check::equal($t->x, 6, "Test::x != 6");
check::equal($t->v->size(), 3, "Test::v.size() != 3");
$T = new T();
$T->start_t = new S();
$T->length = 7;
check::equal($T->start_t->x, 4, "S::x != 4");
check::equal($T->length, 7, "T::length != 7");
check::done();
?>

View file

@ -1,19 +0,0 @@
<?php
require "tests.php";
require "newobject1.php";
// No new functions
check::functions(array(foo_makefoo,foo_makemore,foo_foocount));
// No new classes
check::classes(array(Foo));
// now new vars
check::globals(array());
$foo = Foo::makeFoo();
check::equal(get_class($foo), "Foo", "static failed");
$bar = $foo->makeMore();
check::equal(get_class($bar), "Foo", "regular failed");
check::done();
?>

View file

@ -1,18 +0,0 @@
<?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

@ -1,19 +0,0 @@
<?php
require "tests.php";
require "overload_rename.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(Foo));
// now new vars
check::globals(array());
$f = new Foo(1.0);
$f = new Foo(1.0,1.0);
$f = Foo::Foo_int(1.0,1);
$f = Foo::Foo_int(1.0,1,1.0);
check::done();
?>

View file

@ -1,13 +0,0 @@
<?php
require "tests.php";
require "overload_return_type.php";
$b = new B;
check::equal($b->foo(1), 0, "");
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

@ -1,24 +0,0 @@
<?php
require "tests.php";
require "php_iterator.php";
check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
check::classes(array(MyIterator));
// No new global variables.
check::globals(array());
$s = '';
foreach (new MyIterator(1, 6) as $i) {
$s .= $i;
}
check::equal($s, '12345', 'Simple iteration failed');
$s = '';
foreach (new MyIterator(2, 5) as $k => $v) {
$s .= "($k=>$v)";
}
check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
check::done();
?>

View file

@ -1,11 +0,0 @@
<?php
require "tests.php";
require "php_pragma.php";
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
check::done();
?>

View file

@ -1,18 +0,0 @@
<?php
require "tests.php";
require "pointer_reference.php";
$s = pointer_reference::get();
check::equal($s->value, 10, "pointer_reference::get() failed");
$ss = new Struct(20);
pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
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

@ -1,18 +0,0 @@
<?php
require "tests.php";
require "prefix.php";
// No new functions
check::functions(array(foo_get_self));
// No new classes
check::classes(array(ProjectFoo));
// now new vars
check::globals(array());
$f = new ProjectFoo();
// This resulted in "Fatal error: Class 'Foo' not found"
$f->get_self();
check::done();
?>

View file

@ -1,69 +0,0 @@
<?php
require "tests.php";
require "preproc_constants_c.php";
// Same as preproc_constants.i testcase, but bool types are always wrapped as int.
check::equal(gettype(preproc_constants_c::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_UINT1), "integer", "preproc_constants.CONST_UINT1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_UINT2), "integer", "preproc_constants.CONST_UINT2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_UINT3), "integer", "preproc_constants.CONST_UINT3 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_UINT4), "integer", "preproc_constants.CONST_UINT4 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_LONG1), "integer", "preproc_constants.CONST_LONG1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_LONG2), "integer", "preproc_constants.CONST_LONG2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_LONG3), "integer", "preproc_constants.CONST_LONG3 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_LONG4), "integer", "preproc_constants.CONST_LONG4 has unexpected type");
# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
#check::equal(gettype(preproc_constants_c::CONST_LLONG1), "integer", "preproc_constants.CONST_LLONG1 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_LLONG2), "integer", "preproc_constants.CONST_LLONG2 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_LLONG3), "integer", "preproc_constants.CONST_LLONG3 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_LLONG4), "integer", "preproc_constants.CONST_LLONG4 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_ULLONG1), "integer", "preproc_constants.CONST_ULLONG1 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_ULLONG2), "integer", "preproc_constants.CONST_ULLONG2 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_ULLONG3), "integer", "preproc_constants.CONST_ULLONG3 has unexpected type");
#check::equal(gettype(preproc_constants_c::CONST_ULLONG4), "integer", "preproc_constants.CONST_ULLONG4 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE1), "double", "preproc_constants.CONST_DOUBLE1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_BOOL1), "integer", "preproc_constants.CONST_BOOL1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_BOOL2), "integer", "preproc_constants.CONST_BOOL2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_STRING1), "string", "preproc_constants.CONST_STRING1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_STRING2), "string", "preproc_constants.CONST_STRING2 has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_BOOL), "integer", "preproc_constants.INT_AND_BOOL has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_CHAR), "integer", "preproc_constants.INT_AND_CHAR has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_INT), "integer", "preproc_constants.INT_AND_INT has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_UINT), "integer", "preproc_constants.INT_AND_UINT has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_LONG), "integer", "preproc_constants.INT_AND_LONG has unexpected type");
check::equal(gettype(preproc_constants_c::INT_AND_ULONG), "integer", "preproc_constants.INT_AND_ULONG has unexpected type");
# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
#check::equal(gettype(preproc_constants_c::INT_AND_LLONG), "integer", "preproc_constants.INT_AND_LLONG has unexpected type");
#check::equal(gettype(preproc_constants_c::INT_AND_ULLONG), "integer", "preproc_constants.INT_AND_ULLONG has unexpected type");
check::equal(gettype(preproc_constants_c::BOOL_AND_BOOL), "integer", "preproc_constants.BOOL_AND_BOOL has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_MULTIPLY), "integer", "preproc_constants.EXPR_MULTIPLY has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_DIVIDE), "integer", "preproc_constants.EXPR_DIVIDE has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_PLUS), "integer", "preproc_constants.EXPR_PLUS has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_MINUS), "integer", "preproc_constants.EXPR_MINUS has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_LSHIFT), "integer", "preproc_constants.EXPR_LSHIFT has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_RSHIFT), "integer", "preproc_constants.EXPR_RSHIFT has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_LTE), "integer", "preproc_constants.EXPR_LTE has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_GTE), "integer", "preproc_constants.EXPR_GTE has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_INEQUALITY), "integer", "preproc_constants.EXPR_INEQUALITY has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_EQUALITY), "integer", "preproc_constants.EXPR_EQUALITY has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_AND), "integer", "preproc_constants.EXPR_AND has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_XOR), "integer", "preproc_constants.EXPR_XOR has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_OR), "integer", "preproc_constants.EXPR_OR has unexpected type");
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

@ -1,77 +0,0 @@
<?php
require "tests.php";
require "preproc_constants.php";
check::equal(gettype(preproc_constants::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_UINT1), "integer", "preproc_constants.CONST_UINT1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_UINT2), "integer", "preproc_constants.CONST_UINT2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_UINT3), "integer", "preproc_constants.CONST_UINT3 has unexpected type");
check::equal(gettype(preproc_constants::CONST_UINT4), "integer", "preproc_constants.CONST_UINT4 has unexpected type");
check::equal(gettype(preproc_constants::CONST_LONG1), "integer", "preproc_constants.CONST_LONG1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_LONG2), "integer", "preproc_constants.CONST_LONG2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_LONG3), "integer", "preproc_constants.CONST_LONG3 has unexpected type");
check::equal(gettype(preproc_constants::CONST_LONG4), "integer", "preproc_constants.CONST_LONG4 has unexpected type");
# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
#check::equal(gettype(preproc_constants::CONST_LLONG1), "integer", "preproc_constants.CONST_LLONG1 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_LLONG2), "integer", "preproc_constants.CONST_LLONG2 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_LLONG3), "integer", "preproc_constants.CONST_LLONG3 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_LLONG4), "integer", "preproc_constants.CONST_LLONG4 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_ULLONG1), "integer", "preproc_constants.CONST_ULLONG1 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_ULLONG2), "integer", "preproc_constants.CONST_ULLONG2 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_ULLONG3), "integer", "preproc_constants.CONST_ULLONG3 has unexpected type");
#check::equal(gettype(preproc_constants::CONST_ULLONG4), "integer", "preproc_constants.CONST_ULLONG4 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE1), "double", "preproc_constants.CONST_DOUBLE1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
// SWIG wraps bool constants as integers for PHP5:
check::equal(gettype(preproc_constants::CONST_BOOL1), "integer", "preproc_constants.CONST_BOOL1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_BOOL2), "integer", "preproc_constants.CONST_BOOL2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
check::equal(gettype(preproc_constants::CONST_STRING1), "string", "preproc_constants.CONST_STRING1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_STRING2), "string", "preproc_constants.CONST_STRING2 has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_BOOL), "integer", "preproc_constants.INT_AND_BOOL has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_CHAR), "integer", "preproc_constants.INT_AND_CHAR has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_INT), "integer", "preproc_constants.INT_AND_INT has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_UINT), "integer", "preproc_constants.INT_AND_UINT has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_LONG), "integer", "preproc_constants.INT_AND_LONG has unexpected type");
check::equal(gettype(preproc_constants::INT_AND_ULONG), "integer", "preproc_constants.INT_AND_ULONG has unexpected type");
# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
#check::equal(gettype(preproc_constants::INT_AND_LLONG), "integer", "preproc_constants.INT_AND_LLONG has unexpected type");
#check::equal(gettype(preproc_constants::INT_AND_ULLONG), "integer", "preproc_constants.INT_AND_ULLONG has unexpected type");
check::equal(gettype(preproc_constants::BOOL_AND_BOOL), "integer", "preproc_constants.BOOL_AND_BOOL has unexpected type");
check::equal(gettype(preproc_constants::EXPR_MULTIPLY), "integer", "preproc_constants.EXPR_MULTIPLY has unexpected type");
check::equal(gettype(preproc_constants::EXPR_DIVIDE), "integer", "preproc_constants.EXPR_DIVIDE has unexpected type");
check::equal(gettype(preproc_constants::EXPR_PLUS), "integer", "preproc_constants.EXPR_PLUS has unexpected type");
check::equal(gettype(preproc_constants::EXPR_MINUS), "integer", "preproc_constants.EXPR_MINUS has unexpected type");
check::equal(gettype(preproc_constants::EXPR_LSHIFT), "integer", "preproc_constants.EXPR_LSHIFT has unexpected type");
check::equal(gettype(preproc_constants::EXPR_RSHIFT), "integer", "preproc_constants.EXPR_RSHIFT has unexpected type");
// SWIG wraps bool constants as integers for PHP5:
check::equal(gettype(preproc_constants::EXPR_LTE), "integer", "preproc_constants.EXPR_LTE has unexpected type");
check::equal(gettype(preproc_constants::EXPR_GTE), "integer", "preproc_constants.EXPR_GTE has unexpected type");
check::equal(gettype(preproc_constants::EXPR_INEQUALITY), "integer", "preproc_constants.EXPR_INEQUALITY has unexpected type");
check::equal(gettype(preproc_constants::EXPR_EQUALITY), "integer", "preproc_constants.EXPR_EQUALITY has unexpected type");
check::equal(gettype(preproc_constants::EXPR_AND), "integer", "preproc_constants.EXPR_AND has unexpected type");
check::equal(gettype(preproc_constants::EXPR_XOR), "integer", "preproc_constants.EXPR_XOR has unexpected type");
check::equal(gettype(preproc_constants::EXPR_OR), "integer", "preproc_constants.EXPR_OR has unexpected type");
// SWIG wraps bool constants as integers for PHP5:
check::equal(gettype(preproc_constants::EXPR_LAND), "integer", "preproc_constants.EXPR_LAND has unexpected type");
check::equal(gettype(preproc_constants::EXPR_LOR), "integer", "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

@ -1,34 +0,0 @@
<?php
require "tests.php";
require "primitive_ref.php";
# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
# The conversion to double can lose precision so this isn't an exact comparison.
function long_long_equal($a,$b,$message) {
if (! ($a===$b))
if (! ((double)$a===$b))
return check::fail($message . ": '$a'!=='$b'");
return TRUE;
}
check::equal(ref_over(3), 3, "ref_over failed");
check::equal(ref_int(3), 3, "ref_int failed");
check::equal(ref_uint(3), 3, "ref_uint failed");
check::equal(ref_short(3), 3, "ref_short failed");
check::equal(ref_ushort(3), 3, "ref_ushort failed");
check::equal(ref_long(3), 3, "ref_long failed");
check::equal(ref_ulong(3), 3, "ref_ulong failed");
check::equal(ref_schar(3), 3, "ref_schar failed");
check::equal(ref_uchar(3), 3, "ref_uchar failed");
check::equal(ref_bool(true), true, "ref_bool failed");
check::equal(ref_float(3.5), 3.5, "ref_float failed");
check::equal(ref_double(3.5), 3.5, "ref_double failed");
check::equal(ref_char('x'), 'x', "ref_char failed");
long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
check::done();
?>

View file

@ -1,16 +0,0 @@
<?php
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("__construct","__set","__isset","__get"));
check::classmethods("Interface_BP",array("__construct","__set","__isset","__get"));
check::classmethods("Natural_UP",array("__construct","__set","__isset","__get","rtest"));
check::classmethods("Natural_BP",array("__construct","__set","__isset","__get","rtest"));
check::classparent("Natural_UP","Interface_UP");
check::classparent("Natural_BP","Interface_BP");
check::done();
?>

View file

@ -1,15 +0,0 @@
<?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

@ -1,27 +0,0 @@
<?php
require "tests.php";
require "smart_pointer_rename.php";
check::classes(array("Foo","Bar"));
check::classmethods("foo",array("ftest1","ftest2","__set","__isset","__get","__construct"));
check::classmethods("bar",array("__deref__","test","ftest1","ftest2","__set","__isset","__get","__construct"));
$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

@ -1,33 +0,0 @@
<?php
require("swig_exception.php");
require("tests.php");
$c = new Circle(10);
$s = new Square(10);
if (Shape::nshapes() != 2) {
check::fail("Shape::nshapes() should be 2, actually ".Shape::nshapes());
}
# ----- Throw exception -----
try {
$c->throwException();
check::fail("Exception wasn't thrown");
} catch (Exception $e) {
if ($e->getMessage() != "OK") {
check::fail("Exception getMessage() should be \"OK\", actually \"".$e->getMessage()."\"");
}
}
# ----- Delete everything -----
$c = NULL;
$s = NULL;
$e = NULL;
if (Shape::nshapes() != 0) {
check::fail("Shape::nshapes() should be 0, actually ".Shape::nshapes());
}
?>

View file

@ -1,22 +0,0 @@
<?php
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

@ -1,18 +0,0 @@
<?php
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

@ -1,11 +0,0 @@
<?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

@ -1,237 +0,0 @@
<?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 && preg_match('/_[gs]et$/', $func)) ||
preg_match('/^new_/', $func) ||
preg_match('/_(alter|get)_newobject$/', $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 (preg_match('/^(.*)_[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 (preg_match('/_LOADED__$/', $func)) unset($df[$func]);
$extra=array_keys($df);
}
}
}
return $extra;
}
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) {
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\nHierarchy:\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 (! preg_match("/^_[a-f0-9]+$type$/i", $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 (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $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

@ -1,43 +0,0 @@
<?php
require "tests.php";
require "threads_exception.php";
// Check functions
check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
// Check classes.
check::classes(array(Exc,Test,threads_exception));
// Check globals.
check::globals(array(exc_code,exc_msg));
$t = new Test();
try {
$t->unknown();
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ A * exception thrown', '');
}
try {
$t->simple();
} catch (Exception $e) {
check::equal($e->getCode(), 37, '');
}
try {
$t->message();
} catch (Exception $e) {
check::equal($e->getMessage(), 'I died.', '');
}
try {
$t->hosed();
} catch (Exception $e) {
check::equal($e->getMessage(), 'C++ Exc exception thrown', '');
}
foreach (Array(1,2,3,4) as $i) {
try {
$t->multi($i);
} catch (Exception $e) {
}
}

View file

@ -1,13 +0,0 @@
<?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

@ -1,9 +0,0 @@
<?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

@ -1,9 +0,0 @@
<?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

@ -1,9 +0,0 @@
<?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

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

View file

@ -1,11 +0,0 @@
<?
require "tests.php";
require "virtual_vs_nonvirtual_base.php";
$fail = new SimpleClassFail();
$work = new SimpleClassWork();
check::equal($work->getInner()->get(), $fail->getInner()->get(), "should both be 10");
?>

View file

@ -1,12 +0,0 @@
<?php
require "tests.php";
require "wrapmacro.php";
check::functions(array('guint16_swap_le_be_constant', 'maximum'));
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();
?>

View file

@ -1,7 +1,8 @@
%module restrict_cplusplus
%{
// For PHP 5.3 / gcc-4.4
// Workaround PHP's headers which do:
// #define restrict __restrict__
#ifdef restrict
#undef restrict
#endif