-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix regression in lib/clean_number (alternate) #1185
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1522,7 +1522,12 @@ describe('Test lib.js:', function() { | |
['-100.001', -100.001], | ||
[' $4.325 #%\t', 4.325], | ||
[' " #1" ', 1], | ||
[' \'\n \r -9.2e7 \t\' ', -9.2e7] | ||
[' \'\n \r -9.2e7 \t\' ', -9.2e7], | ||
['1,690,000', 1690000], | ||
['1 690 000', 1690000], | ||
['2 2', 22], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh good call - |
||
['$5,162,000.00', 5162000], | ||
[' $1,410,000.00 ', 1410000], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another one: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here's the old replace call c = c.toString().replace(/['"%,$# ]/g, ''); we didn't do anything to |
||
].forEach(function(v) { | ||
expect(Lib.cleanNumber(v[0])).toBe(v[1], v[0]); | ||
}); | ||
|
@@ -1531,7 +1536,7 @@ describe('Test lib.js:', function() { | |
it('should not accept other objects or cruft in the middle', function() { | ||
[ | ||
NaN, Infinity, -Infinity, null, undefined, new Date(), '', | ||
' ', '\t', '2 2', '2%2', '2$2', {1: 2}, [1], ['1'], {}, [] | ||
' ', '\t', '2\t2', '2%2', '2$2', {1: 2}, [1], ['1'], {}, [] | ||
].forEach(function(v) { | ||
expect(Lib.cleanNumber(v)).toBeUndefined(v); | ||
}); | ||
|
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.
@alexcjohnson
From https://en.wikipedia.org/wiki/Decimal_mark
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.
so maybe we should also include
'
and-
(or is that a\cdot
)?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.
I'd vote to not do any more replacements than we did previously, we'll start to hit other issues if we try to accept other separators like that automatically in every number string we see. We can build tools into the workspace that help people with these situations but lets keep them out of plotly.js