Completed
Push — master ( b9f967...7a222d )
by Andreu
9s
created

DecimalExpTest::testSimple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 3
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
/**
6
 * @group cos
7
 */
8
class DecimalExpTest extends PHPUnit_Framework_TestCase
9
{
10
    public function expProvider() {
11
        // Some values provided by Mathematica
12
        return [
13
            ['0', '1', 0],
14
            ['0', '1', 1],
15
            ['0', '1', 2],
16
17
            ['1', '3', 0],
18
            ['1', '2.7', 1],
19
            ['1', '2.72', 2],
20
            ['1', '2.718', 3],
21
22
            ['-1', '0', 0],
23
            ['-1', '0.4', 1],
24
            ['-1', '0.37', 2]
25
        ];
26
    }
27
28
    /**
29
     * @dataProvider expProvider
30
     */
31
    public function testSimple($nr, $answer, $digits)
32
    {
33
        $x = Decimal::fromString($nr);
34
        $expX = $x->exp((int)$digits);
35
36
        $this->assertTrue(
37
            Decimal::fromString($answer)->equals($expX),
38
            "The answer must be " . $answer . ", but was " . $expX
39
        );
40
    }
41
}
42