1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00
Files
archived-php-src/ext/standard/tests/math/base_convert_error.phpt
Nikita Popov a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00

47 lines
1.2 KiB
PHP

--TEST--
Test base_convert() function : error conditions - incorrect input
--FILE--
<?php
/* Prototype : string base_convert ( string $number , int $frombase , int $tobase )
* Description: Convert a number between arbitrary bases.
* Source code: ext/standard/math.c
*/
echo "*** Testing base_convert() : error conditions ***\n";
// get a class
class classA
{
}
echo "Incorrect number of arguments\n";
base_convert();
base_convert(35);
base_convert(35,2);
base_convert(1234, 1, 10);
base_convert(1234, 10, 37);
echo "Incorrect input\n";
try {
base_convert(new classA(), 8, 10);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
*** Testing base_convert() : error conditions ***
Incorrect number of arguments
Warning: base_convert() expects exactly 3 parameters, 0 given in %s on line %d
Warning: base_convert() expects exactly 3 parameters, 1 given in %s on line %d
Warning: base_convert() expects exactly 3 parameters, 2 given in %s on line %d
Warning: base_convert(): Invalid `from base' (1) in %s on line %d
Warning: base_convert(): Invalid `to base' (37) in %s on line %d
Incorrect input
Object of class classA could not be converted to string