TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
666 B
28 lines
666 B
--TEST--
|
|
Decimal keeps 50 digits and translates native arithmetic errors
|
|
--FILE--
|
|
<?php
|
|
declare(strict_types=1);
|
|
use native_types;
|
|
|
|
function main(): void {
|
|
$large = std::decimal("1234567890123456789012345678901234567890123456789");
|
|
echo ($large + 1)->toString(), "\n";
|
|
|
|
try {
|
|
$unused = std::decimal("1") / 0;
|
|
} catch (DivisionByZeroError $e) {
|
|
echo "division by zero caught\n";
|
|
}
|
|
|
|
try {
|
|
$unused = std::decimal("not-a-decimal");
|
|
} catch (ValueError $e) {
|
|
echo "invalid decimal caught\n";
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
1234567890123456789012345678901234567890123456790
|
|
division by zero caught
|
|
invalid decimal caught
|
|
|