1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Rename Iterator\collect to Iterator\toArray

This commit is contained in:
Niklas Keller 2018-11-25 16:58:42 +01:00
parent a60a8e1906
commit b73e03bfe2
2 changed files with 5 additions and 5 deletions

View File

@ -625,7 +625,7 @@ namespace Amp\Iterator
*
* @return Promise<array>
*/
function collect(Iterator $iterator): Promise
function toArray(Iterator $iterator): Promise
{
return call(function () use ($iterator) {
$array = [];

View File

@ -6,17 +6,17 @@ use Amp\Iterator;
use Amp\PHPUnit\TestCase;
use function Amp\Promise\wait;
class CollectTest extends TestCase
class IteratorToArrayTest extends TestCase
{
public function testCollect()
public function testNonEmpty()
{
$iterator = Iterator\fromIterable(["abc", "foo", "bar"], 5);
$this->assertSame(["abc", "foo", "bar"], wait(Iterator\collect($iterator)));
$this->assertSame(["abc", "foo", "bar"], wait(Iterator\toArray($iterator)));
}
public function testEmpty()
{
$iterator = Iterator\fromIterable([], 5);
$this->assertSame([], wait(Iterator\collect($iterator)));
$this->assertSame([], wait(Iterator\toArray($iterator)));
}
}