-
Notifications
You must be signed in to change notification settings - Fork 35
fix: incorrect reduction of subtraction from zero (#88) #93
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
Conversation
alexander-akait
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more tests
| test( | ||
| 'should reduce substracted division expression from zero', | ||
| testValue, | ||
| 'calc( 0 - (100vw - 10px) / 2 )', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests when 0 is other value
|
The changes I made affected only the '0 - something => -something' case, so correct me if I'm wrong please but I don't see a point of adding tests when 0 is another value. Tests like The '0 - something => -something' case currently has the following tests:
I've added the cases:
To test the actual code I changed, the expressions on the right side should not be reducable, and they should preserve the node. One example is |
|
/cc @ben-eb can you look on this? |
|
I don't have much to add really, I wasn't involved with the more recent refactoring. Thanks for the contribution, @jasminexie 😃 |
|
Thanks |
This PR should fix #88, where a division expression subtracted from zero is incorrectly reduced. Apparently
reducer.jsdoes not reduce division expressions if the denominator cannot be reduced to a value, so similar multiplication tests pass while division did not.