Completed
Push — master ( 7a222d...ef221c )
by Andreu
06:00
created

DecimalArccscTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

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