mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
expand test and fix assertions
This commit is contained in:
parent
d2e1388473
commit
ee75586fbf
@ -1582,9 +1582,8 @@ class AssertionFinder
|
||||
$value_right = $conditional->right->expr->value;
|
||||
}
|
||||
if ($right_assignment === true && $positive_right !== null && $value_right !== null) {
|
||||
$literal_value_comparison = ($value_right +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Greater ? 1 : 0)) *
|
||||
($positive_right ? 1 : -1);
|
||||
$literal_value_comparison = ($positive_right ? 1 : -1) * $value_right +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Greater ? 1 : 0);
|
||||
|
||||
return self::ASSIGNMENT_TO_RIGHT;
|
||||
}
|
||||
@ -1606,9 +1605,8 @@ class AssertionFinder
|
||||
$value_left = $conditional->left->expr->value;
|
||||
}
|
||||
if ($left_assignment === true && $positive_left !== null && $value_left !== null) {
|
||||
$literal_value_comparison = ($value_left +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Greater ? 1 : 0)) *
|
||||
($positive_left ? 1 : -1);
|
||||
$literal_value_comparison = ($positive_left ? 1 : -1) * $value_left +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Greater ? -1 : 0);
|
||||
|
||||
return self::ASSIGNMENT_TO_LEFT;
|
||||
}
|
||||
@ -1641,10 +1639,8 @@ class AssertionFinder
|
||||
$value_right = $conditional->right->expr->value;
|
||||
}
|
||||
if ($right_assignment === true && $positive_right !== null && $value_right !== null) {
|
||||
$literal_value_comparison = ($value_right +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Smaller ? -1 : 0)) *
|
||||
($positive_right ? 1 : -1);
|
||||
|
||||
$literal_value_comparison = ($positive_right ? 1 : -1) * $value_right +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Smaller ? -1 : 0);
|
||||
return self::ASSIGNMENT_TO_RIGHT;
|
||||
}
|
||||
|
||||
@ -1665,9 +1661,8 @@ class AssertionFinder
|
||||
$value_left = $conditional->left->expr->value;
|
||||
}
|
||||
if ($left_assignment === true && $positive_left !== null && $value_left !== null) {
|
||||
$literal_value_comparison = $value_left +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Smaller ? -1 : 0) *
|
||||
($positive_left ? 1 : -1);
|
||||
$literal_value_comparison = ($positive_left ? 1 : -1) * $value_left +
|
||||
($conditional instanceof PhpParser\Node\Expr\BinaryOp\Smaller ? 1 : 0);
|
||||
|
||||
return self::ASSIGNMENT_TO_LEFT;
|
||||
}
|
||||
|
@ -45,14 +45,17 @@ class IntRangeTest extends TestCase
|
||||
'intReduced' => [
|
||||
'<?php
|
||||
function getInt(): int{return 0;}
|
||||
$a = $b = getInt();
|
||||
$a = $b = $c = getInt();
|
||||
assert($a >= 500);
|
||||
assert($a < 5000);
|
||||
assert($b >= -5000);
|
||||
assert($b < -500);',
|
||||
assert($b < -501);
|
||||
assert(-60 > $c);
|
||||
assert(-500 < $c);',
|
||||
'assertions' => [
|
||||
'$a===' => 'int<500, 4999>',
|
||||
'$b===' => 'int<-5000, -499>',
|
||||
'$b===' => 'int<-5000, -502>',
|
||||
'$c===' => 'int<-499, -61>',
|
||||
]
|
||||
],
|
||||
'intOperations' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user