Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 872653e

Browse files
committed
[TECH] Add the infite decimal method and tests
1 parent 828b361 commit 872653e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/InfiniteDecimal.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,20 @@ public function sin($scale = null)
311311
);
312312
}
313313

314+
/**
315+
* Throws exception because cosecant is undefined in the infinite.
316+
*
317+
* @param integer $scale
318+
* @return null
319+
*/
320+
public function cosec($scale = null)
321+
{
322+
throw new \DomainException(($this === self::$pInf) ?
323+
"Cosecant function hasn't limit in the positive infinite." :
324+
"Cosecant function hasn't limit in the negative infinite."
325+
);
326+
}
327+
314328
/**
315329
* Throws exception because cosine is undefined in the infinite.
316330
*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Litipk\BigNumbers\InfiniteDecimal as InfiniteDecimal;
4+
5+
/**
6+
* @group cos
7+
*/
8+
class InfiniteDecimalCosecTest extends PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @expectedException \DomainException
12+
* @expectedExceptionMessage Cosecant function hasn't limit in the positive infinite.
13+
*/
14+
public function testFinitePositiveInfiniteCosec()
15+
{
16+
InfiniteDecimal::getPositiveInfinite()->cosec();
17+
}
18+
19+
/**
20+
* @expectedException \DomainException
21+
* @expectedExceptionMessage Cosecant function hasn't limit in the negative infinite.
22+
*/
23+
public function testFiniteNegativeInfiniteCosec()
24+
{
25+
InfiniteDecimal::getNegativeInfinite()->cosec();
26+
}
27+
}

0 commit comments

Comments
 (0)