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