- Create new test file for signed integer arithmetic operations - Add test cases for addition and subtraction with negative values - Verify that non-overflowing results maintain integer type - Test increment and decrement operations with integer preservation - Include expected output for all arithmetic operations - Validate type checking behavior with requireInt function callsmaster
parent
729000fa0c
commit
a08f73c995
1 changed files with 32 additions and 0 deletions
@ -0,0 +1,32 @@ |
|||||||
|
--TEST-- |
||||||
|
signed integer arithmetic keeps non-overflowing results as integers |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
function requireInt(int $value): void |
||||||
|
{ |
||||||
|
var_dump($value); |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$values = [-1, 1, 0]; |
||||||
|
$negativeOne = $values[0]; |
||||||
|
$positiveOne = $values[1]; |
||||||
|
$zero = $values[2]; |
||||||
|
|
||||||
|
requireInt($negativeOne + $positiveOne); |
||||||
|
requireInt($zero - $positiveOne); |
||||||
|
|
||||||
|
$negativeOne += $positiveOne; |
||||||
|
requireInt($negativeOne); |
||||||
|
|
||||||
|
$zero -= $positiveOne; |
||||||
|
requireInt($zero); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(0) |
||||||
|
int(-1) |
||||||
|
int(0) |
||||||
|
int(-1) |
||||||
Loading…
Reference in new issue