Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comparisons #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Fix comparisons #3

wants to merge 7 commits into from

Conversation

wirwolf
Copy link
Contributor

@wirwolf wirwolf commented Jun 2, 2017

$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);

@wirwolf wirwolf changed the title Update BC.php Fix comparetion Jun 2, 2017
@wirwolf
Copy link
Contributor Author

wirwolf commented Jun 6, 2017

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

@danhunsaker danhunsaker changed the title Fix comparetion Fix comparisons Jun 6, 2017
@wirwolf
Copy link
Contributor Author

wirwolf commented Jun 7, 2017

Please check coverage parser because if i run PHPUnit coverage in local machine i see 100%

@danhunsaker
Copy link
Owner

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. ☹️

@wirwolf
Copy link
Contributor Author

wirwolf commented Jun 9, 2017

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?

@danhunsaker
Copy link
Owner

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.

@wirwolf
Copy link
Contributor Author

wirwolf commented Aug 12, 2017

Up. This fix is actual now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants