summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2015-10-18 01:42:15 -0500
committerAaron Piotrowski <aaron@trowski.com>2015-10-18 01:42:15 -0500
commit49d6336faea161dc2412797392aa568c17c1cd9b (patch)
tree7e464af42fe2aaa75f7f9c56543a8601796fc341 /ext
parent51953423ee391c8e002d0ef7ac21c5243a097135 (diff)
downloadphp-git-49d6336faea161dc2412797392aa568c17c1cd9b.tar.gz
Always return boolean from assert
Matches docs prototype
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/assert.c2
-rw-r--r--ext/standard/tests/assert/assert_basic.phpt4
-rw-r--r--ext/standard/tests/assert/assert_basic5.phpt2
-rw-r--r--ext/standard/tests/assert/assert_return_value.phpt15
-rw-r--r--ext/standard/tests/assert/assert_variation.phpt12
5 files changed, 26 insertions, 9 deletions
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index 22f4759af4..22eade66c3 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -274,6 +274,8 @@ PHP_FUNCTION(assert)
if (ASSERTG(bail)) {
zend_bailout();
}
+
+ RETURN_FALSE;
}
/* }}} */
diff --git a/ext/standard/tests/assert/assert_basic.phpt b/ext/standard/tests/assert/assert_basic.phpt
index ea58e9f7f3..48b5fb6c6a 100644
--- a/ext/standard/tests/assert/assert_basic.phpt
+++ b/ext/standard/tests/assert/assert_basic.phpt
@@ -23,8 +23,8 @@ var_dump($r2=assert(0));
var_dump($r2=assert(1));
--EXPECTF--
f1 called
-NULL
+bool(false)
bool(true)
f1 called
-NULL
+bool(false)
bool(true)
diff --git a/ext/standard/tests/assert/assert_basic5.phpt b/ext/standard/tests/assert/assert_basic5.phpt
index d67d879262..745f3e7e29 100644
--- a/ext/standard/tests/assert/assert_basic5.phpt
+++ b/ext/standard/tests/assert/assert_basic5.phpt
@@ -27,6 +27,6 @@ int(0)
f1 called
Warning: assert(): assert($sa): "0 != 0" failed in %s on line 10
-NULL
+bool(false)
bool(true)
int(1)
diff --git a/ext/standard/tests/assert/assert_return_value.phpt b/ext/standard/tests/assert/assert_return_value.phpt
new file mode 100644
index 0000000000..834f9df1ff
--- /dev/null
+++ b/ext/standard/tests/assert/assert_return_value.phpt
@@ -0,0 +1,15 @@
+--TEST--
+assert() returns boolean on success or failure
+--INI--
+zend.assertions = 1
+assert.exception = 0
+--FILE--
+<?php
+var_dump(assert(true));
+var_dump(assert(false));
+?>
+--EXPECTF--
+bool(true)
+
+Warning: assert(): assert(false) failed in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/assert/assert_variation.phpt b/ext/standard/tests/assert/assert_variation.phpt
index af8c967f8e..8ae84344c6 100644
--- a/ext/standard/tests/assert/assert_variation.phpt
+++ b/ext/standard/tests/assert/assert_variation.phpt
@@ -74,27 +74,27 @@ echo"\n";
Initial values: assert_options(ASSERT_CALLBACK) => [f1]
Initial values: ini.get("assert.callback") => [f1]
f1 called
-NULL
+bool(false)
Change callback function using ini.set and test return value
string(2) "f1"
assert_options(ASSERT_CALLBACK) => [f2]
ini.get("assert.callback") => [f2]
f2 called
-NULL
+bool(false)
Change callback function using assert_options and test return value
string(2) "f2"
assert_options(ASSERT_CALLBACK) => [f3]
ini.get("assert.callback") => [f2]
f3 called
-NULL
+bool(false)
Reset the name of the callback routine to a class method and check that it works
string(2) "f3"
assert_options(ASSERT_CALLBACK) => [c1]
ini.get("assert.callback") => [f2]
-NULL
+bool(false)
Reset callback options to use a class method
string(2) "c1"
@@ -109,7 +109,7 @@ ini.get("assert.callback") => [f2]
Deprecated: Non-static method c1::assert() should not be called statically in %s on line 53
Class assertion failed 53, "0 != 0"
-NULL
+bool(false)
Reset callback options to use an object method
array(2) {
@@ -128,4 +128,4 @@ array(2) {
ini.get("assert.callback") => [f2]
Class assertion failed 61, "0 != 0"
-NULL
+bool(false)