"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Examples/test-suite/php/abstract_inherit_runme.php" (30 Nov 2022, 716 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "abstract_inherit_runme.php": 4.0.2_vs_4.1.0.

    1 <?php
    2 
    3 require "tests.php";
    4 
    5 check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i'));
    6 
    7 // We shouldn't be able to instantiate any of these classes since they are all
    8 // abstract (in each case there's a pure virtual function in the base class
    9 // which isn't implemented).
   10 foreach (array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i')as $class) {
   11     try {
   12     $obj = eval("new $class();");
   13     check::fail("Should not be able to instantiate abstract class $class");
   14     } catch (Error $e) {
   15     check::equal($e->getMessage(), "Cannot instantiate abstract class $class", "Unexpected exception: {$e->getMessage()}");
   16     }
   17 }
   18 
   19 check::done();