endtoend-test-psl/tests/Psl/Iter/ReverseTest.php
2020-10-15 11:05:30 +02:00

26 lines
551 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Iter;
use PHPUnit\Framework\TestCase;
use Psl\Iter;
final class ReverseTest extends TestCase
{
public function testReverse(): void
{
$result = Iter\reverse(['foo', 'bar', 'baz', 'qux']);
static::assertSame(['qux', 'baz', 'bar', 'foo'], Iter\to_array_with_keys($result));
}
public function testReverseEarlyReturnForEmptyIterables(): void
{
$result = Iter\reverse(Iter\to_iterator([]));
static::assertSame([], Iter\to_array($result));
}
}