Passed
Push — master ( 54e8a7...8a4054 )
by Sérgio
03:36
created

MemoizeTest::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Prelude\Tests;
4
5
use function Prelude\memoize;
6
7
class MemoizeTest extends \PHPUnit\Framework\TestCase
8
{
9
    public function test()
10
    {
11
        $count = 0;
12
        $inc = memoize(function ($n) use (&$count) {
13
            $count += 1;
14
            return $n + 1;
15
        });
16
17
        $this->assertEquals($inc(-1), 0);
18
        $this->assertEquals($inc(-1), 0);
19
        $this->assertEquals($inc(-1), 0);
20
        $this->assertEquals($count, 1);
21
    }
22
}
23