mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
Rename Iterator\collect to Iterator\toArray
This commit is contained in:
parent
a60a8e1906
commit
b73e03bfe2
@ -625,7 +625,7 @@ namespace Amp\Iterator
|
|||||||
*
|
*
|
||||||
* @return Promise<array>
|
* @return Promise<array>
|
||||||
*/
|
*/
|
||||||
function collect(Iterator $iterator): Promise
|
function toArray(Iterator $iterator): Promise
|
||||||
{
|
{
|
||||||
return call(function () use ($iterator) {
|
return call(function () use ($iterator) {
|
||||||
$array = [];
|
$array = [];
|
||||||
|
@ -6,17 +6,17 @@ use Amp\Iterator;
|
|||||||
use Amp\PHPUnit\TestCase;
|
use Amp\PHPUnit\TestCase;
|
||||||
use function Amp\Promise\wait;
|
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);
|
$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()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$iterator = Iterator\fromIterable([], 5);
|
$iterator = Iterator\fromIterable([], 5);
|
||||||
$this->assertSame([], wait(Iterator\collect($iterator)));
|
$this->assertSame([], wait(Iterator\toArray($iterator)));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user