Skip to content
Permalink
Browse files

Move more tests into appropriate directory

  • Loading branch information
muglug committed Dec 7, 2019
1 parent 2b6831b commit d7fdd9b1799e1e51ccc07ebbf941b9438937300b
@@ -1910,6 +1910,17 @@ function foo(?A $a, ?A $b): void {
$c = ($a instanceof B && $b instanceof B) || ($a instanceof C && $b instanceof C);
}'
],
'assertVarAfterNakedBinaryOp' => [
'<?php
class A {
public bool $b = false;
}
function foo(A $a, A $b): void {
$c = !$a->b && !$b->b;
echo $a->b ? 1 : 0;
}'
],
'assertAssertionsWithCreation' => [
'<?php
class A {}
@@ -2043,7 +2054,62 @@ function foo(bool $b): void {
if (isset($a["b"]) || isset($a["c"])) {
$all_params = ($a["b"] ?? []) + ($a["c"] ?? []);
}'
]
],
'assertOnNestedLogic' => [
'<?php
function foo(?string $a) : void {
if (($a && rand(0, 1)) || rand(0, 1)) {
if ($a && strlen($a) > 5) {}
}
}'
],
'arrayUnionTypeSwitching' => [
'<?php
/** @param array<string, int|string> $map */
function foo(array $map, string $o) : void {
if ($mapped_type = $map[$o] ?? null) {
if (is_int($mapped_type)) {
return;
}
}
if (($mapped_type = $map[""] ?? null) && is_string($mapped_type)) {
}
}'
],
'propertySetOnElementInConditional' => [
'<?php
class DiffElem {
/** @var scalar */
public $old = false;
/** @var scalar */
public $new = false;
}
function foo(DiffElem $diff_elem) : void {
if ((is_string($diff_elem->old) && is_string($diff_elem->new))
|| (is_int($diff_elem->old) && is_int($diff_elem->new))
) {
}
}'
],
'manyNestedAsserts' => [
'<?php
class A {}
class B extends A {}
function foo(A $left, A $right) : void {
if (($left instanceof B && rand(0, 1))
|| ($right instanceof B && rand(0, 1))
) {
if ($left instanceof B
&& rand(0, 1)
&& $right instanceof B
&& rand(0, 1)
) {}
}
}'
],
];
}

@@ -1,10 +1,10 @@
<?php
namespace Psalm\Tests;

class EmptyTest extends TestCase
class EmptyTest extends \Psalm\Tests\TestCase
{
use Traits\InvalidCodeAnalysisTestTrait;
use Traits\ValidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;

/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
@@ -1,10 +1,10 @@
<?php
namespace Psalm\Tests;

class IssetTest extends TestCase
class IssetTest extends \Psalm\Tests\TestCase
{
use Traits\ValidCodeAnalysisTestTrait;
use Traits\InvalidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;

/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
@@ -413,7 +413,7 @@ function sameString(string $string): string {
throw new \InvalidArgumentException();
}',
],
'notIssetOneOrOther' => [
'notIssetOneOrOtherSimple' => [
'<?php
$foo = [
"one" => rand(0,1) ? new DateTime : null,
@@ -437,7 +437,7 @@ function sameString(string $string): string {
"three" => new DateTime
];
isset($foo["one"]) || isset($foo["two"]);
$a = isset($foo["one"]) || isset($foo["two"]);
echo $foo["one"]->format("Y");',
'assertions' => [],
@@ -1,10 +1,10 @@
<?php
namespace Psalm\Tests;
namespace Psalm\Tests\TypeReconciliation;

class TypeAlgebraTest extends TestCase
class TypeAlgebraTest extends \Psalm\Tests\TestCase
{
use Traits\InvalidCodeAnalysisTestTrait;
use Traits\ValidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
use \Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;

/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
@@ -139,7 +139,9 @@ function foo(?stdClass $a, ?stdClass $b, ?stdClass $c): stdClass {
return new stdClass;
}
if (!$a && !$b) return $c;
if (!$a && !$b) {
return $c;
}
if (!$a) return $b;
return $a;
}',
@@ -570,7 +572,7 @@ class A {
}
if (rand(0, 10) > 5) {
} elseif (($a = new A) && $a->foo) {}',
} elseif (($a = rand(0, 1) ? new A : null) && $a->foo) {}',
],
'noParadoxForGetopt' => [
'<?php
@@ -1082,7 +1084,7 @@ function foo(?string $a) {
],
'repeatedConditionals' => [
'<?php
function foo(?string $a): void {
function foo(?object $a): void {
if ($a) {
// do something
} elseif ($a) {
File renamed without changes.

0 comments on commit d7fdd9b

Please sign in to comment.
You can’t perform that action at this time.