1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/bcmath/tests/number/clone.phpt
Saki Takamachi fad899e566 [RFC] Support object types in BCMath (#13741)
Added BcMath\Number class. It is an immutable object, has methods that are
equivalent to existing BCMath calculation functions, and can also be calculated
using operators.

The existing BCMath function returned a string for each calculation, but this
class returns an object.

RFC: https://wiki.php.net/rfc/support_object_type_in_bcmath,
https://wiki.php.net/rfc/fix_up_bcmath_number_class

---------

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-09-04 11:12:51 +09:00

39 lines
566 B
PHP

--TEST--
BcMath\Number clone
--EXTENSIONS--
bcmath
--FILE--
<?php
$values = [
'0',
'0.0',
'2',
'1234',
'12.0004',
'0.1230',
1,
12345,
'-0',
'-0.0',
'-2',
'-1234',
'-12.0004',
'-0.1230',
-1,
-12345,
];
foreach ($values as $value) {
$num = new BcMath\Number($value);
$clone = clone $num;
if ($num->value !== $clone->value || $num->scale !== $clone->scale || $num === $clone) {
echo "Result is incorrect.\n";
var_dump($num, $clone);
}
}
echo 'done!';
?>
--EXPECT--
done!