helly Mon Mar 3 06:10:30 2003 EDT
Added files:
/php4/tests/classes abstract_final.phpt final.phpt
final_abstract.phpt final_redeclare.phpt
Log:
Adding tests for final methods
Index: php4/tests/classes/abstract_final.phpt
+++ php4/tests/classes/abstract_final.phpt
--TEST--
A final method cannot be abstract
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2
needed'); ?>
--FILE--
<?php
class fail {
abstract final function show();
}
echo "Done\n"; // Shouldn't be displayed
?>
--EXPECTF--
Fatal error: Cannot use the final modifier on an abstract class member in %s on line %d
Index: php4/tests/classes/final.phpt
+++ php4/tests/classes/final.phpt
--TEST--
A method may be redeclared final
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2
needed'); ?>
--FILE--
<?php
class first {
function show() {
echo "Call to function first::show()\n";
}
}
$t = new first();
$t->show();
class second extends first {
final function show() {
echo "Call to function second::show()\n";
}
}
$t2 = new second();
$t2->show();
echo "Done\n";
?>
--EXPECTF--
Call to function first::show()
Call to function second::show()
Done
Index: php4/tests/classes/final_abstract.phpt
+++ php4/tests/classes/final_abstract.phpt
--TEST--
A final method cannot be abstract
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2
needed'); ?>
--FILE--
<?php
class fail {
final abstract function show();
}
echo "Done\n"; // Shouldn't be displayed
?>
--EXPECTF--
Fatal error: Cannot use the final modifier on an abstract class member in %s
Index: php4/tests/classes/final_redeclare.phpt
+++ php4/tests/classes/final_redeclare.phpt
--TEST--
A final method may not be overwritten
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2
needed'); ?>
--FILE--
<?php
class pass {
final function show() {
echo "Call to function pass::show()\n";
}
}
$t = new pass();
$t->show();
class fail extends pass {
function show() {
echo "Call to function fail::show()\n";
}
}
echo "Done\n"; // Shouldn't be displayed
?>
--EXPECTF--
Call to function pass::show()
Fatal error: Cannot override final method pass::show() in %s on line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php