mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Promote conditional tests to always-running
This commit is contained in:
parent
20567ff720
commit
cf962eebc2
@ -330,7 +330,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-mirrorCallableParams' => [
|
||||
'mirrorCallableParams' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -357,7 +357,7 @@ class ClosureTest extends TestCase
|
||||
[1, 2, 3]
|
||||
);',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableNamedClass' => [
|
||||
'closureFromCallableInvokableNamedClass' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -373,7 +373,7 @@ class ClosureTest extends TestCase
|
||||
|
||||
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableAnonymousClass' => [
|
||||
'closureFromCallableInvokableAnonymousClass' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -389,7 +389,7 @@ class ClosureTest extends TestCase
|
||||
|
||||
acceptsIntToBool(Closure::fromCallable($anonInvokable));',
|
||||
],
|
||||
'PHP71-publicCallableFromInside' => [
|
||||
'publicCallableFromInside' => [
|
||||
'<?php
|
||||
class Base {
|
||||
public function publicMethod() : void {}
|
||||
@ -401,7 +401,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-protectedCallableFromInside' => [
|
||||
'protectedCallableFromInside' => [
|
||||
'<?php
|
||||
class Base {
|
||||
protected function protectedMethod() : void {}
|
||||
@ -413,7 +413,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-closureFromCallableNamedFunction' => [
|
||||
'closureFromCallableNamedFunction' => [
|
||||
'<?php
|
||||
$closure = Closure::fromCallable("strlen");
|
||||
',
|
||||
@ -965,7 +965,7 @@ class ClosureTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||
'closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -999,7 +999,7 @@ class ClosureTest extends TestCase
|
||||
};',
|
||||
'error_message' => 'DuplicateParam',
|
||||
],
|
||||
'PHP71-privateCallable' => [
|
||||
'privateCallable' => [
|
||||
'<?php
|
||||
class Base {
|
||||
private function privateMethod() : void {}
|
||||
|
@ -1032,7 +1032,7 @@ class FunctionCallTest extends TestCase
|
||||
'$c' => 'int',
|
||||
],
|
||||
],
|
||||
'PHP73-hrtime' => [
|
||||
'hrtime' => [
|
||||
'<?php
|
||||
$a = hrtime(true);
|
||||
$b = hrtime();
|
||||
@ -1046,7 +1046,7 @@ class FunctionCallTest extends TestCase
|
||||
'$d' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'PHP73-hrtimeCanBeFloat' => [
|
||||
'hrtimeCanBeFloat' => [
|
||||
'<?php
|
||||
$a = hrtime(true);
|
||||
|
||||
@ -1239,7 +1239,7 @@ class FunctionCallTest extends TestCase
|
||||
/** @psalm-suppress TooFewArguments */
|
||||
min(0);',
|
||||
],
|
||||
'PHP73-allowIsCountableToInformType' => [
|
||||
'allowIsCountableToInformType' => [
|
||||
'<?php
|
||||
function getObject() : iterable{
|
||||
return [];
|
||||
@ -1345,7 +1345,7 @@ class FunctionCallTest extends TestCase
|
||||
'$matches===' => 'array<array-key, array{string, int}>',
|
||||
],
|
||||
],
|
||||
'PHP72-pregMatchWithFlagUnmatchedAsNull' => [
|
||||
'pregMatchWithFlagUnmatchedAsNull' => [
|
||||
'<?php
|
||||
$r = preg_match("{foo}", "foo", $matches, PREG_UNMATCHED_AS_NULL);',
|
||||
'assertions' => [
|
||||
@ -1353,7 +1353,7 @@ class FunctionCallTest extends TestCase
|
||||
'$matches===' => 'array<array-key, null|string>',
|
||||
],
|
||||
],
|
||||
'PHP72-pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
||||
'pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
||||
'<?php
|
||||
$r = preg_match("{foo}", "foo", $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);',
|
||||
'assertions' => [
|
||||
@ -1399,7 +1399,7 @@ class FunctionCallTest extends TestCase
|
||||
return compact("a", "b", "c");
|
||||
}',
|
||||
],
|
||||
'PHP73-setCookiePhp73' => [
|
||||
'setCookiePhp73' => [
|
||||
'<?php
|
||||
setcookie(
|
||||
"name",
|
||||
|
@ -42,11 +42,7 @@ trait InvalidCodeAnalysisTestTrait
|
||||
string $php_version = '7.3'
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP71-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||
}
|
||||
|
@ -39,19 +39,7 @@ trait ValidCodeAnalysisTestTrait
|
||||
string $php_version = '7.3'
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP71-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP72-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.2.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.2.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP73-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.3.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ class ConditionalTest extends TestCase
|
||||
atan($a);
|
||||
atan($b);',
|
||||
],
|
||||
'PHP71-removeNonCallable' => [
|
||||
'removeNonCallable' => [
|
||||
'<?php
|
||||
$f = rand(0, 1) ? "strlen" : 1.1;
|
||||
if (is_callable($f)) {
|
||||
|
Loading…
Reference in New Issue
Block a user