mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
improve test
This commit is contained in:
parent
55b45853de
commit
edff17134d
@ -2675,6 +2675,48 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
||||
'$_a===' => '"N"|"Y"',
|
||||
]
|
||||
],
|
||||
'nullErasureWithSmallerAndGreater' => [
|
||||
'<?php
|
||||
function getIntOrNull(): ?int{return null;}
|
||||
$a = getIntOrNull();
|
||||
|
||||
if ($a < 0) {
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if ($a <= 0) {
|
||||
/** @psalm-suppress PossiblyNullOperand */
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if ($a > 0) {
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if ($a >= 0) {
|
||||
/** @tmp-psalm-suppress PossiblyNullOperand this should be suppressed but assertions remove null for now */
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if (0 < $a) {
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if (0 <= $a) {
|
||||
/** @tmp-psalm-suppress PossiblyNullOperand this should be suppressed but assertions remove null for now */
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if (0 > $a) {
|
||||
echo $a + 3;
|
||||
}
|
||||
|
||||
if (0 >= $a) {
|
||||
/** @psalm-suppress PossiblyNullOperand */
|
||||
echo $a + 3;
|
||||
}
|
||||
',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -2734,15 +2776,6 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
'dontEraseNullAfterLessThanCheck' => [
|
||||
'<?php
|
||||
$a = mt_rand(0, 1) ? mt_rand(-10, 10): null;
|
||||
|
||||
if ($a < -1) {
|
||||
echo $a + 3;
|
||||
}',
|
||||
'error_message' => 'PossiblyNullOperand',
|
||||
],
|
||||
'nonRedundantConditionGivenDocblockType' => [
|
||||
'<?php
|
||||
/** @param array[] $arr */
|
||||
|
Loading…
x
Reference in New Issue
Block a user