test(compiler): add signed integer arithmetic operator tests

- 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 calls
master
韩天峰 5 days ago
parent 729000fa0c
commit a08f73c995
  1. 32
      tests/compiler/operator/signed-integer-arithmetic.phpt

@ -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…
Cancel
Save