This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use Litipk\BigNumbers\Decimal as Decimal; | ||
|
||
/** | ||
* @group arcsin | ||
*/ | ||
class DecimalArcsinTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function arcsinProvider() { | ||
// Some values providede by wolframalpha | ||
return [ | ||
['0.154', '0.15461530016096', 14], | ||
['1', '1.57079632679489662', 17], | ||
['-1', '-1.57079632679489662', 17], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider arcsinProvider | ||
*/ | ||
public function testSimple($nr, $answer, $digits) | ||
{ | ||
$x = Decimal::fromString($nr); | ||
$arcsinX = $x->arcsin($digits); | ||
|
||
$this->assertTrue( | ||
Decimal::fromString($answer)->equals($arcsinX), | ||
"The answer must be " . $answer . ", but was " . $arcsinX | ||
); | ||
} | ||
|
||
/** | ||
* @expectedException \DomainException | ||
* @expectedExceptionMessage The arcsin of this number is undefined. | ||
*/ | ||
public function testArcsinGreaterThanOne() | ||
{ | ||
Decimal::fromString('25.546')->arcsin(); | ||
} | ||
|
||
/** | ||
* @expectedException \DomainException | ||
* @expectedExceptionMessage The arcsin of this number is undefined. | ||
*/ | ||
public function testArcsinFewerThanNegativeOne() | ||
{ | ||
Decimal::fromString('-304.75')->arcsin(); | ||
} | ||
} |