2015-01-08 06:13:09 +08:00
|
|
|
--TEST--
|
|
|
|
Error cases of compound shift assignment on strings
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$n = "65";
|
|
|
|
$n <<= $n;
|
|
|
|
var_dump($n);
|
|
|
|
|
|
|
|
$n = "-1";
|
2015-04-06 19:30:05 +08:00
|
|
|
try {
|
|
|
|
$n <<= $n;
|
|
|
|
var_dump($n);
|
2015-07-03 11:18:53 +08:00
|
|
|
} catch (ArithmeticError $e) {
|
2015-04-06 19:30:05 +08:00
|
|
|
echo "\nException: " . $e->getMessage() . "\n";
|
|
|
|
}
|
2015-01-08 06:13:09 +08:00
|
|
|
|
|
|
|
$n = "65";
|
|
|
|
$n >>= $n;
|
|
|
|
var_dump($n);
|
|
|
|
|
|
|
|
$n = "-1";
|
2015-04-06 19:30:05 +08:00
|
|
|
try {
|
|
|
|
$n >>= $n;
|
|
|
|
var_dump($n);
|
2015-07-03 11:18:53 +08:00
|
|
|
} catch (ArithmeticError $e) {
|
2015-04-06 19:30:05 +08:00
|
|
|
echo "\nException: " . $e->getMessage() . "\n";
|
|
|
|
}
|
2015-01-08 06:13:09 +08:00
|
|
|
|
2015-01-08 06:21:12 +08:00
|
|
|
$n = "0";
|
2015-04-06 19:30:05 +08:00
|
|
|
try{
|
|
|
|
$n %= $n;
|
|
|
|
var_dump($n);
|
2015-07-03 11:18:53 +08:00
|
|
|
} catch (DivisionByZeroError $e) {
|
2015-04-06 19:30:05 +08:00
|
|
|
echo "\nException: " . $e->getMessage() . "\n";
|
|
|
|
}
|
2015-01-08 06:21:12 +08:00
|
|
|
|
|
|
|
$n = "-1";
|
|
|
|
$n %= $n;
|
|
|
|
var_dump($n);
|
2018-02-19 16:59:41 +08:00
|
|
|
--EXPECT--
|
2015-01-08 06:13:09 +08:00
|
|
|
int(0)
|
|
|
|
|
2015-04-06 19:30:05 +08:00
|
|
|
Exception: Bit shift by negative number
|
2015-01-08 06:13:09 +08:00
|
|
|
int(0)
|
|
|
|
|
2015-04-06 19:30:05 +08:00
|
|
|
Exception: Bit shift by negative number
|
2015-01-08 06:21:12 +08:00
|
|
|
|
2015-07-02 07:54:08 +08:00
|
|
|
Exception: Modulo by zero
|
2015-01-08 06:21:12 +08:00
|
|
|
int(0)
|