DecimalArccscTest::testSimple()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
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
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