- 在BinaryOpTrait中添加Big*类型运算符支持检查逻辑 - 检测到BigFloat、Decimal或BigInt类型使用不支持的运算符时抛出错误 - 添加测试用例验证模运算符%对BigFloat类型的不支持 - 添加测试用例验证按位与运算符&对Decimal类型的不支持 - 添加测试用例验证左移运算符<<对BigFloat类型的不支持 - 添加测试用例验证按位或运算符|对Decimal类型的不支持pull/1/head
parent
051c4a45fd
commit
8aa1745e1d
6 changed files with 66 additions and 0 deletions
@ -0,0 +1,9 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
use native_types; |
||||
function main() |
||||
{ |
||||
$a = std::bigFloat("3.14"); |
||||
$b = std::bigFloat("2.71"); |
||||
$c = $a % $b; |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
use native_types; |
||||
function main() |
||||
{ |
||||
$a = std::bigFloat("10.0"); |
||||
$b = 2; |
||||
$c = $a << $b; |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
use native_types; |
||||
function main() |
||||
{ |
||||
$a = std::decimal("3.14"); |
||||
$b = std::decimal("2.71"); |
||||
$c = $a & $b; |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
<?php |
||||
declare(strict_types=1); |
||||
use native_types; |
||||
function main() |
||||
{ |
||||
$a = std::decimal("100"); |
||||
$b = std::decimal("200"); |
||||
$c = $a | $b; |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
class BigNumberUnsupportedOpTest extends \BaseTest |
||||
{ |
||||
public function testBigFloatMod() |
||||
{ |
||||
$this->exec("Operator '%' is not supported for Big* numeric types", 'bigfloat-unsupported-mod.php'); |
||||
} |
||||
|
||||
public function testDecimalBitAnd() |
||||
{ |
||||
$this->exec("Operator '&' is not supported for Big* numeric types", 'decimal-unsupported-bitand.php'); |
||||
} |
||||
|
||||
public function testBigFloatShiftLeft() |
||||
{ |
||||
$this->exec("Operator '<<' is not supported for Big* numeric types", 'bigfloat-unsupported-shift.php'); |
||||
} |
||||
|
||||
public function testDecimalBitOr() |
||||
{ |
||||
$this->exec("Operator '|' is not supported for Big* numeric types", 'decimal-unsupported-bitor.php'); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue