1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 18:38:17 +01:00
amp/test/Iterator/ToArrayTest.php

22 lines
517 B
PHP
Raw Normal View History

2018-10-05 21:06:27 +02:00
<?php
2020-05-13 17:15:21 +02:00
namespace Amp\Test\Iterator;
2018-10-05 21:06:27 +02:00
use Amp\Iterator;
2020-09-28 05:19:52 +02:00
use Amp\PHPUnit\AsyncTestCase;
2018-10-05 21:06:27 +02:00
2020-09-28 05:19:52 +02:00
class ToArrayTest extends AsyncTestCase
2018-10-05 21:06:27 +02:00
{
2020-09-28 05:19:52 +02:00
public function testNonEmpty(): \Generator
2018-10-05 21:06:27 +02:00
{
$iterator = Iterator\fromIterable(["abc", "foo", "bar"], 5);
2020-09-28 05:19:52 +02:00
$this->assertSame(["abc", "foo", "bar"], yield Iterator\toArray($iterator));
2018-10-05 21:06:27 +02:00
}
2020-09-28 05:19:52 +02:00
public function testEmpty(): \Generator
2018-10-05 21:06:27 +02:00
{
$iterator = Iterator\fromIterable([], 5);
2020-09-28 05:19:52 +02:00
$this->assertSame([], yield Iterator\toArray($iterator));
2018-10-05 21:06:27 +02:00
}
}