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

MemoizeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test() 0 13 1
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