Skip to content

Commit

Permalink
Move constant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 7, 2020
1 parent 4e36f6c commit cecc5ed
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 89 deletions.
89 changes: 89 additions & 0 deletions tests/ConstantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,59 @@ public static function will_succeed($code) : bool {
return (self::LOOKUP[strtoupper($code)] ?? null) === self::SUCCEED;
}
}'
],
'keyOf' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}
A::foo(1);
A::foo(2);
A::foo(3);',
],
'valueOf' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}
A::bar("a");
A::bar("b");
A::bar("c");',
],
'valueOfDefault' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @var value-of<self::C>
*/
public $foo = "a";
}',
],
];
}
Expand Down Expand Up @@ -701,6 +754,42 @@ class C {
}',
'error_message' => 'CircularReference'
],
'keyOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}
A::foo(4);',
'error_message' => 'InvalidArgument',
],
'valueOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}
A::bar("d");',
'error_message' => 'InvalidArgument',
],
];
}
}
89 changes: 0 additions & 89 deletions tests/TypeReconciliation/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,59 +593,6 @@ public function foo(string ...$things) : void {
}
',
],
'keyOf' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}
A::foo(1);
A::foo(2);
A::foo(3);',
],
'valueOf' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}
A::bar("a");
A::bar("b");
A::bar("c");',
],
'valueOfDefault' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @var value-of<self::C>
*/
public $foo = "a";
}',
],
'supportSingleLiteralType' => [
'<?php
class A {
Expand Down Expand Up @@ -874,42 +821,6 @@ function foo(string $s) : void {
}',
'error_message' => 'RedundantCondition',
],
'keyOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}
A::foo(4);',
'error_message' => 'InvalidArgument',
],
'valueOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}
A::bar("d");',
'error_message' => 'InvalidArgument',
],
'casedComparison' => [
'<?php
if ("C" === "c") {}',
Expand Down

0 comments on commit cecc5ed

Please sign in to comment.