com php-src: Fix assert() implementation to match docs: ext/standard/assert.c ext/standard/tests/assert/assert_custom _exception.phpt
| From: | Aaron Piotrowski | Date: | Sat, 17 Oct 2015 19:30:41 +0000 |
| Subject: | com php-src: Fix assert() implementation to match docs: ext/standard/assert.c ext/standard/tests/assert/assert_custom _exception.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89421@lists.php.net to get a copy of this message | ||
Commit: 51953423ee391c8e002d0ef7ac21c5243a097135
Author: Aaron Piotrowski <aaron@trowski.com> Sat, 17 Oct 2015 14:30:41 -0500
Parents: e2d6090043aed271d18a4d157cbb64138481c9ed
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=51953423ee391c8e002d0ef7ac21c5243a097135
Log:
Fix assert() implementation to match docs
Changed paths:
M ext/standard/assert.c
A ext/standard/tests/assert/assert_custom_exception.phpt
Diff:
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index 545c099..22f4759 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -245,7 +245,7 @@ PHP_FUNCTION(assert)
if (!description) {
zend_throw_exception(assertion_error_ce, NULL, E_ERROR);
} else if (Z_TYPE_P(description) == IS_OBJECT &&
- instanceof_function(Z_OBJCE_P(description), assertion_error_ce)) {
+ instanceof_function(Z_OBJCE_P(description), zend_ce_throwable)) {
Z_ADDREF_P(description);
zend_throw_exception_object(description);
} else {
diff --git a/ext/standard/tests/assert/assert_custom_exception.phpt
b/ext/standard/tests/assert/assert_custom_exception.phpt
new file mode 100644
index 0000000..caec222
--- /dev/null
+++ b/ext/standard/tests/assert/assert_custom_exception.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Throwing custom exception object from assert() throws given object
+--INI--
+zend.assertions = 1
+assert.exception = 1
+--FILE--
+<?php
+class CustomException extends Exception {}
+assert(false, new CustomException('Exception message'));
+?>
+--EXPECTF--
+Fatal error: Uncaught CustomException: Exception message in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d