Skip to content

Commit

Permalink
Release prep (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
phpfui authored Mar 5, 2021
1 parent 16dde01 commit aa37abb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Unlimited variable name lengths
* String support, as function parameters or as evaluated as a number by PHP
* Exceptions on divide by zero, or treat as zero
* Unary Minus (e.g. -3)
* Unary Plus and Minus (e.g. +3 or -sin(12))
* Pi ($pi) and Euler's number ($e) support to 11 decimal places
* Easily extensible

Expand Down Expand Up @@ -176,9 +176,6 @@ $executor->addOperator("/", false, 180, function($a, $b) {
echo $executor->execute('1/0');
```

## Unary Minus Operator:
Negative numbers are supported via the unary minus operator. Positive numbers are not explicitly supported as unsigned numbers are assumed positive.

## String Support:
Expressions can contain double or single quoted strings that are evaluated the same way as PHP evalutes strings as numbers. You can also pass strings to functions.

Expand All @@ -202,4 +199,4 @@ Full class documentation via [PHPFUI/InstaDoc](http://phpfui.com/?n=NXP&c=MathEx

## Future Enhancements

This package will continue to track currently supported versions of PHP. PHP 7.1 and earlier support will be dropped when PHP 8 is released.
This package will continue to track currently supported versions of PHP.
25 changes: 14 additions & 11 deletions tests/MathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ public function providerExpressions()
['(4*2) - 5'],
['4*-5'],
['4 * -5'],
['+5'],
['+(3+2)'],
['+(+3+2)'],
['+(-3+2)'],
['-5'],
['-(-5)'],
['-(+5)'],
['+(-5)'],
['+(+5)'],
['-(3+2)'],
['-(-3+-2)'],

['abs(1.5)'],
['acos(0.15)'],
Expand Down Expand Up @@ -92,6 +103,9 @@ public function providerExpressions()
['rad2deg(1.5)'],
['round(1.5)'],
['sin(1.5)'],
['sin(12)'],
['+sin(12)'],
['-sin(12)'],
['sinh(1.5)'],
['sqrt(1.5)'],
['tan(1.5)'],
Expand Down Expand Up @@ -252,17 +266,6 @@ public function testZeroDivision()
$this->assertEquals(0, $calculator->execute('10 / 0'));
}

public function testUnaryOperators()
{
$calculator = new MathExecutor();
$this->assertEquals(5, $calculator->execute('+5'));
$this->assertEquals(5, $calculator->execute('+(3+2)'));
$this->assertEquals(-5, $calculator->execute('-5'));
$this->assertEquals(5, $calculator->execute('-(-5)'));
$this->assertEquals(-5, $calculator->execute('+(-5)'));
$this->assertEquals(-5, $calculator->execute('-(3+2)'));
}

public function testZeroDivisionException()
{
$calculator = new MathExecutor();
Expand Down

0 comments on commit aa37abb

Please sign in to comment.