2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Iter;
|
|
|
|
|
2020-08-17 23:33:18 +02:00
|
|
|
use Psl\Iter;
|
2019-12-24 01:52:07 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class IsIterableTest extends TestCase
|
|
|
|
{
|
2020-08-17 23:33:18 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider provideIsIterableData
|
|
|
|
*/
|
|
|
|
public function testIsIterable($expected, $value): void
|
|
|
|
{
|
|
|
|
self::assertSame($expected, Iter\is_iterable($value));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function provideIsIterableData(): iterable
|
|
|
|
{
|
|
|
|
yield [false, false];
|
|
|
|
yield [true, false];
|
|
|
|
yield [null, false];
|
|
|
|
yield [[], true];
|
|
|
|
yield [Iter\to_iterator([1, 2]), true];
|
|
|
|
yield [$this, false];
|
|
|
|
yield [STDIN, false];
|
|
|
|
yield [(fn() => yield false)(), true];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|