Completed
Pull Request — master (#51)
by
unknown
08:53
created

DecimalArcsinTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A arcsinProvider() 0 8 1
A testSimple() 0 10 1
A testArcsinGreaterThanOne() 0 4 1
A testArcsinFewerThanNegativeOne() 0 4 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
/**
6
 * @group arcsin
7
 */
8
class DecimalArcsinTest extends PHPUnit_Framework_TestCase
9
{
10
    public function arcsinProvider() {
11
        // Some values provided by wolframalpha
12
        return [
13
            ['0.154', '0.15461530016096', 14],
14
            ['1', '1.57079632679489662', 17],
15
            ['-1', '-1.57079632679489662', 17],
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider arcsinProvider
21
     */
22
    public function testSimple($nr, $answer, $digits)
23
    {
24
        $x = Decimal::fromString($nr);
25
        $arcsinX = $x->arcsin($digits);
26
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($arcsinX),
29
            "The answer must be " . $answer . ", but was " . $arcsinX
30
        );
31
    }
32
33
    /**
34
     * @expectedException \DomainException
35
     * @expectedExceptionMessage The arcsin of this number is undefined.
36
     */
37
    public function testArcsinGreaterThanOne()
38
    {
39
        Decimal::fromString('25.546')->arcsin();
40
    }
41
42
    /**
43
     * @expectedException \DomainException
44
     * @expectedExceptionMessage The arcsin of this number is undefined.
45
     */
46
    public function testArcsinFewerThanNegativeOne()
47
    {
48
        Decimal::fromString('-304.75')->arcsin();
49
    }
50
}
51