mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 17:56:09 +01:00
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Iter;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Iter;
|
|
|
|
class AllTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testAll(bool $expected, iterable $iterable, callable $predicate): void
|
|
{
|
|
self::assertSame($expected, Iter\all($iterable, $predicate));
|
|
}
|
|
|
|
public function provideData(): iterable
|
|
{
|
|
yield [false, [false, true, true], fn (bool $value): bool => $value];
|
|
yield [false, [false, true, true], fn (bool $value): bool => !$value];
|
|
yield [true, [true, true, true], fn (bool $value): bool => $value];
|
|
yield [false, [true, true, true], fn (bool $value): bool => !$value];
|
|
yield [false, [false, false, false], fn (bool $value): bool => $value];
|
|
yield [true, [false, false, false], fn (bool $value): bool => !$value];
|
|
yield [true, [false, false, false], fn (bool $value): bool => true];
|
|
yield [false, [false, false, false], fn (bool $value): bool => false];
|
|
yield [false, [1, 2, 3], fn (int $i): bool => $i > 3];
|
|
yield [true, [4, 5, 6], fn (int $i): bool => $i > 3];
|
|
yield [false, [1, 2, 3, 4, 5, 6], fn (int $i): bool => $i > 3];
|
|
yield [true, [], fn (bool $value): bool => false];
|
|
}
|
|
}
|