DecimalArccscTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
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
use PHPUnit\Framework\TestCase;
5
6
/**
7
 * @group arccsc
8
 */
9
class DecimalArccscTest extends TestCase
10
{
11
    public function arccscProvider() {
12
        // Some values provided by wolframalpha
13
        return [
14
            ['25.546', '0.03915507577327', 14],
15
            ['1.5', '0.729728', 6],
16
            ['1', '1.57079632679489662', 17],
17
            ['-1', '-1.57079632679489662', 17],
18
        ];
19
    }
20
21
    /**
22
     * @dataProvider arccscProvider
23
     */
24
    public function testSimple($nr, $answer, $digits)
25
    {
26
        $x = Decimal::fromString($nr);
27
        $arccscX = $x->arccsc($digits);
28
29
        $this->assertTrue(
30
            Decimal::fromString($answer)->equals($arccscX),
31
            "The answer must be " . $answer . ", but was " . $arccscX
32
        );
33
    }
34
35
    /**
36
     * @expectedException \DomainException
37
     * @expectedExceptionMessage The arccosecant of this number is undefined.
38
     */
39
    public function testArccscBetweenOneAndNegativeOne()
40
    {
41
        Decimal::fromString('0.546')->arccsc();
42
    }
43
}
44