[php] Actually implement abstract_inherit_runme.php

The previous version didn't really test anything useful.  Now we
check that trying to instantiate any of the abstract classes fails
with the expected error.
This commit is contained in:
Olly Betts 2021-12-18 14:06:36 +13:00
commit f04d741d1c
2 changed files with 11 additions and 8 deletions

View file

@ -3,10 +3,17 @@
require "tests.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");
// We shouldn't be able to instantiate any of these classes since they are all
// abstract (in each case there's a pure virtual function in the base class
// which isn't implemented).
foreach (array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i')as $class) {
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()}");
}
}
check::done();

4
TODO
View file

@ -204,10 +204,6 @@ PHP
mapping to the same object in case it gets twice destroyed. And check
if ref count destroying is even working, see smart_pointer_rename
* Work out how classes without even inherited constructors should
interact with the php "new <class>" notation.
See: abstract_inherit_wrap.cpptest
** Look at pass by point and passby ref,
Make sometype** to be auto allocated
Make sometype& and sometype* to be autoallocated IF THEY ARE NOT