Skip to content
Permalink
Browse files

Move misplaced tests

  • Loading branch information...
muglug committed Jun 24, 2019
1 parent 69b05f5 commit fe5138f1a6969db89bf937bc954dd8c6f8a961b6
Showing with 73 additions and 73 deletions.
  1. +73 −0 tests/Template/TemplateExtendsTest.php
  2. +0 −73 tests/Template/TemplateTest.php
@@ -1961,6 +1961,79 @@ public function getIterator() : Traversable {
foreach ($bat as $num) {}',
],
'implictIteratorTemplating' => [
'<?php
/**
* @template-implements IteratorAggregate<int, int>
*/
class SomeIterator implements IteratorAggregate
{
function getIterator()
{
yield 1;
}
}
/** @param \IteratorAggregate<mixed, int> $i */
function takesIteratorOfInts(\IteratorAggregate $i) : void {
foreach ($i as $j) {
echo $j;
}
}
takesIteratorOfInts(new SomeIterator());',
],
'genericInterface' => [
'<?php
/**
* @template T as object
* @param class-string<T> $t
* @return T
*/
function generic(string $t) {
return f($t)->get();
}
/** @template T as object */
interface I {
/** @return T */
public function get() {}
}
/**
* @template T as object
* @template-implements I<T>
*/
class C implements I {
/**
* @var T
*/
public $t;
/**
* @param T $t
*/
public function __construct(object $t) {
$this->t = $t;
}
/**
* @return T
*/
public function get() {
return $this->t;
}
}
/**
* @template T as object
* @param class-string<T> $t
* @return I<T>
*/
function f(string $t) {
return new C(new $t);
}',
],
];
}
@@ -763,28 +763,6 @@ public function getIterator(): \Traversable {
foreach ($c->getIterator() as $k => $v) { atan($v); strlen($k); }',
],
'implictIteratorTemplating' => [
'<?php
/**
* @template-implements IteratorAggregate<int, int>
*/
class SomeIterator implements IteratorAggregate
{
function getIterator()
{
yield 1;
}
}
/** @param \IteratorAggregate<mixed, int> $i */
function takesIteratorOfInts(\IteratorAggregate $i) : void {
foreach ($i as $j) {
echo $j;
}
}
takesIteratorOfInts(new SomeIterator());',
],
'allowTemplatedIntersectionToExtend' => [
'<?php
interface Foo {}
@@ -1525,57 +1503,6 @@ function Foo(string $foo) : object {
echo Foo(DateTime::class)->format("c");',
],
'genericInterface' => [
'<?php
/**
* @template T as object
* @param class-string<T> $t
* @return T
*/
function generic(string $t) {
return f($t)->get();
}
/** @template T as object */
interface I {
/** @return T */
public function get() {}
}
/**
* @template T as object
* @template-implements I<T>
*/
class C implements I {
/**
* @var T
*/
public $t;
/**
* @param T $t
*/
public function __construct(object $t) {
$this->t = $t;
}
/**
* @return T
*/
public function get() {
return $this->t;
}
}
/**
* @template T as object
* @param class-string<T> $t
* @return I<T>
*/
function f(string $t) {
return new C(new $t);
}',
],
'templateIntersectionLeft' => [
'<?php
interface I1 {}

0 comments on commit fe5138f

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