2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Iter;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2020-09-01 07:50:23 +02:00
|
|
|
use Psl\Iter;
|
|
|
|
use Psl\Str;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
final class PullTest extends TestCase
|
2019-12-24 01:52:07 +01:00
|
|
|
{
|
2020-09-01 07:50:23 +02:00
|
|
|
public function testPull(): void
|
|
|
|
{
|
|
|
|
$result = Iter\pull(
|
|
|
|
Iter\range(0, 10),
|
2020-10-15 10:18:03 +02:00
|
|
|
static fn ($i) => Str\chr($i + 65),
|
|
|
|
static fn ($i) => 2 ** $i
|
2020-09-01 07:50:23 +02:00
|
|
|
);
|
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
static::assertSame([
|
2020-09-01 07:50:23 +02:00
|
|
|
1 => 'A', 2 => 'B', 4 => 'C', 8 => 'D', 16 => 'E', 32 => 'F',
|
|
|
|
64 => 'G', 128 => 'H', 256 => 'I', 512 => 'J', 1024 => 'K'
|
|
|
|
], Iter\to_array_with_keys($result));
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|