Navigation Menu

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 handling of non-integer values #15

Merged
merged 1 commit into from Sep 26, 2014
Merged

Fix handling of non-integer values #15

merged 1 commit into from Sep 26, 2014

Conversation

eemeli
Copy link
Contributor

@eemeli eemeli commented Sep 26, 2014

I found this by chasing the source for an issue raised by @rxaviers here: eemeli/make-plural#2

In brief, there are incorrect comparisons in at least the functions mod() and _in() that make use of praseInt() rather than parseFloat(), which end up discarding the fractional part of the inputs, so we end up with:

$ ./src/cli.js 'n = 1' '1.1'
true

This does not match the syntax, which takes n as "absolute value of the source number (integer and decimals)" and defines the in_relation set by = as "only includes integers in the specified range".

I also added tests for the above, including the Latvian "zero" rule, as well as a test for '1.0' (correctly) failing i = 1 and v = 0.

santhoshtr added a commit that referenced this pull request Sep 26, 2014
Fix handling of non-integer values
@santhoshtr santhoshtr merged commit 6b17882 into santhoshtr:master Sep 26, 2014
@santhoshtr
Copy link
Owner

Thanks!

@eemeli eemeli deleted the fix_in branch September 26, 2014 11:04
rxaviers added a commit to globalizejs/globalize that referenced this pull request Sep 26, 2014
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.

None yet

2 participants