mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2025-01-22 05:11:47 +01:00
[Arr] increase code coverage
This commit is contained in:
parent
1d27476584
commit
5bf80569ec
@ -40,19 +40,21 @@ function sort_with_keys_by(iterable $iterable, callable $scalar_func, ?callable
|
||||
fn ($a, $b): int => $a[0] <=> $b[0];
|
||||
}
|
||||
|
||||
$result = Iter\map_with_key(
|
||||
sort_with_keys(
|
||||
Iter\map(
|
||||
$iterable,
|
||||
/**
|
||||
* @psalm-param Tv $value
|
||||
*
|
||||
* @psalm-return array{0: Ts, 1: Tv}
|
||||
*/
|
||||
fn ($value) => [$scalar_func($value), $value],
|
||||
),
|
||||
$tuple_comparator
|
||||
$sorted = sort_with_keys(
|
||||
Iter\map(
|
||||
$iterable,
|
||||
/**
|
||||
* @psalm-param Tv $value
|
||||
*
|
||||
* @psalm-return array{0: Ts, 1: Tv}
|
||||
*/
|
||||
fn ($value) => [$scalar_func($value), $value],
|
||||
),
|
||||
$tuple_comparator
|
||||
);
|
||||
|
||||
$result = Iter\map_with_key(
|
||||
$sorted,
|
||||
/**
|
||||
* @psalm-param Tk $k
|
||||
* @psalm-param array{0: Ts, 1: Tv} $v
|
||||
|
@ -19,6 +19,14 @@ class RandomTest extends TestCase
|
||||
static::assertContains($value, $values);
|
||||
}
|
||||
|
||||
public function testRandomWithOneItem(): void
|
||||
{
|
||||
$values = ['a'];
|
||||
$value = Arr\random($values);
|
||||
|
||||
static::assertSame('a', $value);
|
||||
}
|
||||
|
||||
public function testRandomThrowsWhenTheGivenArrayIsEmpty(): void
|
||||
{
|
||||
$this->expectException(Exception\InvariantViolationException::class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user