summaryrefslogtreecommitdiff
path: root/ext/standard/tests/math/base_convert_error.phpt
blob: b2cf396ae304774a59d9df83aca53dad9eae60b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--TEST--
Test base_convert() function :  error conditions - incorrect input
--FILE--
<?php
echo "*** Testing base_convert() : error conditions ***\n";

// get a class
class classA
{
}

try {
    base_convert(1234, 1, 10);
} catch (ValueError $e) {
    echo $e->getMessage(), "\n";
}
try {
    base_convert(1234, 10, 37);
} catch (ValueError $e) {
    echo $e->getMessage(), "\n";
}

try {
    base_convert(new classA(), 8, 10);
} catch (Error $e) {
    echo $e->getMessage(), "\n";
}

?>
--EXPECT--
*** Testing base_convert() : error conditions ***
base_convert(): Argument #2 ($frombase) must be between 2 and 36 (inclusive)
base_convert(): Argument #3 ($tobase) must be between 2 and 36 (inclusive)
base_convert(): Argument #1 ($number) must be of type string, classA given