diff options
author | Olly Betts <olly@survex.com> | 2021-12-18 14:38:49 +1300 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2021-12-18 14:38:49 +1300 |
commit | cc5395a669588f7c9b6347dfc65ed69e0f5221d0 (patch) | |
tree | a55a0d7b9990f9527feab664b17da1022692d5e2 | |
parent | f04d741d1c752f3af87c90820ee1d386e56a924d (diff) | |
download | swig-cc5395a669588f7c9b6347dfc65ed69e0f5221d0.tar.gz |
[php] Add more checks to some PHP testcases
-rw-r--r-- | Examples/test-suite/php/abstract_inherit_ok_runme.php | 17 | ||||
-rw-r--r-- | Examples/test-suite/php/arrays_scope_runme.php | 4 | ||||
-rw-r--r-- | Examples/test-suite/php/php_pragma_runme.php | 7 |
3 files changed, 27 insertions, 1 deletions
diff --git a/Examples/test-suite/php/abstract_inherit_ok_runme.php b/Examples/test-suite/php/abstract_inherit_ok_runme.php index 6cfea2341..add4191c2 100644 --- a/Examples/test-suite/php/abstract_inherit_ok_runme.php +++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php @@ -2,9 +2,24 @@ require "tests.php"; +// No new functions +check::functions(array()); + check::classes(array('Foo','Spam')); -$spam=new Spam(); +// No new vars +check::globals(array()); + +// We shouldn't be able to instantiate abstract class Foo. +$class = 'Foo'; +try { + $obj = eval("new $class();"); + check::fail("Should not be able to instantiate abstract class $class"); +} catch (Error $e) { + check::equal($e->getMessage(), "Cannot instantiate abstract class $class", "Unexpected exception: {$e->getMessage()}"); +} + +$spam=new Spam(); check::equal(0,$spam->blah(),"spam object method"); check::done(); diff --git a/Examples/test-suite/php/arrays_scope_runme.php b/Examples/test-suite/php/arrays_scope_runme.php index f18037ca7..8455b837c 100644 --- a/Examples/test-suite/php/arrays_scope_runme.php +++ b/Examples/test-suite/php/arrays_scope_runme.php @@ -10,5 +10,9 @@ check::classes(array('arrays_scope','Bar')); check::globals(array()); $bar=new bar(); +$bar->blah($bar->adata, $bar->bdata, $bar->cdata); +// Like C/C++, SWIG treats `int asize[ASIZE]` as `int*` so there's no checking +// of the passed array size. +$bar->blah($bar->bdata, $bar->cdata, $bar->adata); check::done(); diff --git a/Examples/test-suite/php/php_pragma_runme.php b/Examples/test-suite/php/php_pragma_runme.php index e70f2ceda..cf297701d 100644 --- a/Examples/test-suite/php/php_pragma_runme.php +++ b/Examples/test-suite/php/php_pragma_runme.php @@ -2,6 +2,13 @@ require "tests.php"; +// No new functions +check::functions(array()); +// No new classes +check::classes(array()); +// No new vars +check::globals(array()); + check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)"); check::done(); |