Skip to content

Commit e657b50

Browse files
committed
Add some tests for functions in ext/standard
1 parent a0091b9 commit e657b50

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Test array_filter() function : value cannot be converted to bool
3+
--EXTENSIONS--
4+
gmp
5+
--FILE--
6+
<?php
7+
8+
$input = [0, 1, -1, 10, 100, 1000];
9+
10+
function dump($value, $key)
11+
{
12+
echo "$key = $value\n";
13+
}
14+
15+
try {
16+
var_dump( array_filter($input, 'gmp_init') );
17+
} catch (\TypeError $e) {
18+
echo $e->getMessage(), \PHP_EOL;
19+
}
20+
21+
$input = [gmp_init(5), gmp_init(25)];
22+
23+
try {
24+
var_dump( array_filter($input) );
25+
} catch (\TypeError $e) {
26+
echo $e->getMessage(), \PHP_EOL;
27+
}
28+
29+
echo "Done"
30+
?>
31+
--EXPECT--
32+
Object of class GMP could not be converted to bool
33+
Object of class GMP could not be converted to bool
34+
Done
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Testing boolval()
3+
--EXTENSIONS--
4+
gmp
5+
--FILE--
6+
<?php
7+
try {
8+
var_dump(boolval(gmp_init('5')));
9+
} catch (\TypeError $e) {
10+
echo $e->getMessage(), \PHP_EOL;
11+
}
12+
?>
13+
--EXPECT--
14+
Object of class GMP could not be converted to bool

ext/standard/type.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ PHP_FUNCTION(boolval)
220220
Z_PARAM_ZVAL(value)
221221
ZEND_PARSE_PARAMETERS_END();
222222

223-
/* Need to do explicit exception check? */
224223
RETURN_BOOL(zend_is_true(value));
225224
}
226225
/* }}} */

0 commit comments

Comments
 (0)