bcmath
bcmath copied to clipboard
Fix comparisons
$res = BC::parse('0 | 0'); var_dump($res);
Old version:
Replacing 0|0 with in the (0|0) section of (0|0)
Replacing (0|0) with in (0|0)
string(0) ""
New version: Replacing 0|0 with 0 in the (0|0) section of (0|0) Replacing (0|0) with 0 in (0|0) string(1) "0"
if i add some logic to parse:
$isPlayed = BC::parse('{totalMoney} <= {playedMoney} | {balance} <= 1' , [ 'totalMoney' => $bonusUser->totalMoney, 'playedMoney' => $bonusUser->playedMoney, 'balance' => $financeClient->balance ], 2, true); var_dump($res);
andru@developer-a ~/Web/www/bcmath $ phpunit -v --color -c .travis-phpunit.xml PHPUnit 5.3.5 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.30-11+deb.sury.org~trusty+3 with Xdebug 2.5.1 Configuration: /home/andru/Web/www/bcmath/.travis-phpunit.xml
....................... 23 / 23 (100%)
Time: 8.48 seconds, Memory: 6.00MB
OK (23 tests, 72 assertions)
Generating code coverage report in Clover XML format ... done
https://www.dropbox.com/s/bm7stcnli109k9p/%D1%81%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA50.png?dl=0 https://www.dropbox.com/s/aq4avopo3tmkzi6/%D1%81%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA51.png?dl=0
Please check coverage parser because if i run PHPUnit coverage in local machine i see 100%
I actually want to do this a slightly different way; I just haven't had a moment to sit down and do it.
I was originally a bit worried about how boolean operations would be processed if there were more than one in an expression, but I figured it wouldn't be a feature used very often, so I didn't bother improving the implementation at the time. This PR reminded me I still hadn't addressed that, and apparently it's a useful feature after all, so I'm gonna sit down and make it happen soon. Just haven't gotten there, yet. I'll leave this open to remind me to follow through.
Should have said something sooner, actually. Sorry about that. :frowning_face:
Can i use this logic in my project? After you make the logic in your own, will I be able to use your code without changes in my project?
I don't see why not. It will output the same way. The only differences will be in exactly how the parser handles booleans, that's all.
Up. This fix is actual now.