endtoend-test-psl/tests/Psl/Vec/EnumerateTest.php
2021-02-16 01:49:55 +01:00

32 lines
750 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Vec;
use PHPUnit\Framework\TestCase;
use Psl\Vec;
final class EnumerateTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testEnumerate(array $expected, iterable $iterable): void
{
static::assertSame($expected, Vec\enumerate($iterable));
}
public function provideData(): iterable
{
yield [[], []];
yield [[['a', 'b'], ['c', 'd']], ['a' => 'b', 'c' => 'd']];
yield [[['a', 'b'], ['a', 'b'], ['a', 'b']], (static function () {
yield 'a' => 'b';
yield 'a' => 'b';
yield 'a' => 'b';
})()];
yield [[['a', null], ['b', 0]], ['a' => null, 'b' => 0]];
}
}