This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from codisart/add-arcsec-arccsc-methods
[TECH] Add two new methods and their tests. Thanks to @codisart .
- Loading branch information
Showing
3 changed files
with
146 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,42 @@ | ||
<?php | ||
|
||
use Litipk\BigNumbers\Decimal as Decimal; | ||
|
||
/** | ||
* @group arccsc | ||
*/ | ||
class DecimalArccscTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function arccscProvider() { | ||
// Some values provided by wolframalpha | ||
return [ | ||
['25.546', '0.03915507577327', 14], | ||
['1.5', '0.729728', 6], | ||
['1', '1.57079632679489662', 17], | ||
['-1', '-1.57079632679489662', 17], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider arccscProvider | ||
*/ | ||
public function testSimple($nr, $answer, $digits) | ||
{ | ||
$x = Decimal::fromString($nr); | ||
$arccscX = $x->arccsc($digits); | ||
|
||
$this->assertTrue( | ||
Decimal::fromString($answer)->equals($arccscX), | ||
"The answer must be " . $answer . ", but was " . $arccscX | ||
); | ||
} | ||
|
||
/** | ||
* @expectedException \DomainException | ||
* @expectedExceptionMessage The arccosecant of this number is undefined. | ||
*/ | ||
public function testArccscBetweenOneAndNegativeOne() | ||
{ | ||
Decimal::fromString('0.546')->arccsc(); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
use Litipk\BigNumbers\Decimal as Decimal; | ||
|
||
/** | ||
* @group arcsec | ||
*/ | ||
class DecimalArcsecTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function arcsecProvider() { | ||
// Some values provided by wolframalpha | ||
return [ | ||
['25.546', '1.53164125102163', 14], | ||
['1.5', '0.841068', 6], | ||
['1', '0', 17], | ||
['-1', '3.14159265358979324', 17], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider arcsecProvider | ||
*/ | ||
public function testSimple($nr, $answer, $digits) | ||
{ | ||
$x = Decimal::fromString($nr); | ||
$arcsecX = $x->arcsec($digits); | ||
|
||
$this->assertTrue( | ||
Decimal::fromString($answer)->equals($arcsecX), | ||
"The answer must be " . $answer . ", but was " . $arcsecX | ||
); | ||
} | ||
|
||
/** | ||
* @expectedException \DomainException | ||
* @expectedExceptionMessage The arcsecant of this number is undefined. | ||
*/ | ||
public function testArcsecBetweenOneAndNegativeOne() | ||
{ | ||
Decimal::fromString('0.546')->arcsec(); | ||
} | ||
} |