From: Marcus Boerger Date: Mon, 3 Mar 2003 11:10:30 +0000 (+0000) Subject: Adding tests for final methods X-Git-Tag: RELEASE_0_5~646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=326b793fafda3850a9123f65601bb4aab0919018;p=php Adding tests for final methods --- diff --git a/tests/classes/abstract_final.phpt b/tests/classes/abstract_final.phpt new file mode 100644 index 0000000000..7aac02615d --- /dev/null +++ b/tests/classes/abstract_final.phpt @@ -0,0 +1,16 @@ +--TEST-- +A final method cannot be abstract +--SKIPIF-- + +--FILE-- + +--EXPECTF-- + +Fatal error: Cannot use the final modifier on an abstract class member in %s on line %d diff --git a/tests/classes/final.phpt b/tests/classes/final.phpt new file mode 100644 index 0000000000..733adf2e84 --- /dev/null +++ b/tests/classes/final.phpt @@ -0,0 +1,31 @@ +--TEST-- +A method may be redeclared final +--SKIPIF-- + +--FILE-- +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 \ No newline at end of file diff --git a/tests/classes/final_abstract.phpt b/tests/classes/final_abstract.phpt new file mode 100644 index 0000000000..37aa0bee8f --- /dev/null +++ b/tests/classes/final_abstract.phpt @@ -0,0 +1,16 @@ +--TEST-- +A final method cannot be abstract +--SKIPIF-- + +--FILE-- + +--EXPECTF-- + +Fatal error: Cannot use the final modifier on an abstract class member in %s diff --git a/tests/classes/final_redeclare.phpt b/tests/classes/final_redeclare.phpt new file mode 100644 index 0000000000..bdf34a149a --- /dev/null +++ b/tests/classes/final_redeclare.phpt @@ -0,0 +1,28 @@ +--TEST-- +A final method may not be overwritten +--SKIPIF-- + +--FILE-- +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