Passed
Push — master ( 3f4370...54e8a7 )
by Sérgio
03:37
created

AnyTest::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Prelude\Tests;
4
5
use function Prelude\any;
6
7
class AnyTest extends \PHPUnit\Framework\TestCase
8
{
9
    public function test()
10
    {
11
        $isEven = function ($n) { return $n % 2 === 0; };
12
        $isOdd = function ($n) { return $n % 2 === 1; };
13
14
        $this->assertTrue(any($isEven)([1, 3, 4, 5, 7]));
15
        $this->assertFalse(any($isEven)([1, 3, 5, 7]));
16
17
        $this->assertTrue(any($isOdd)([1, 3, 5, 7]));
18
        $this->assertFalse(any($isOdd)([2, 4, 6]));
19
20
        $this->assertTrue(any('is_array')([2, []]));
21
        $this->assertFalse(any('is_array')(['s', 'x']));
22
    }
23
}
24