[Iter] test merge and zip

This commit is contained in:
azjezz 2020-09-01 06:52:09 +01:00
parent 623d014812
commit 439a28972b
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Psl\Tests\Iter;
use PHPUnit\Framework\TestCase;
use Psl\Iter;
class MergeTest extends TestCase
{
public function testMap(): void
{
$result = Iter\merge([1, 2], [9, 8]);
$entries = Iter\to_array(Iter\enumerate($result));
static::assertSame($entries[0], [0, 1]);
static::assertSame($entries[1], [1, 2]);
static::assertSame($entries[2], [0, 9]);
static::assertSame($entries[3], [1, 8]);
}
}

View File

@ -38,4 +38,11 @@ class ZipTest extends TestCase
static::assertSame([2, 2, 2], $k);
static::assertSame([3, 7, 12], $v);
}
public function testZipWithZeroIterables(): void
{
$result = Iter\zip(...[]);
self::assertCount(0, $result);
}
}