-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix regression in lib/clean_number #1184
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 1 commit
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 |
---|---|---|
|
@@ -1514,24 +1514,30 @@ describe('Test lib.js:', function() { | |
}); | ||
}); | ||
|
||
it('should accept number strings with arbitrary cruft on the outside', function() { | ||
it('should accept number strings with arbitrary cruft', function() { | ||
[ | ||
['0', 0], | ||
['1', 1], | ||
['1.23', 1.23], | ||
['-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], | ||
|
||
// post https://github.com/plotly/plotly.js/issues/1183 | ||
['2 2', 22], | ||
['2%2', 22], | ||
['2$2', 22], | ||
['1,690,000', 1690000] | ||
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. could we add one for 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. Also: 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. You're right that this is what we had before - which is exactly why I changed it, though obviously I forgot about commas in the middle! I really think we should consider interpreting 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. What about |
||
].forEach(function(v) { | ||
expect(Lib.cleanNumber(v[0])).toBe(v[1], v[0]); | ||
}); | ||
}); | ||
|
||
it('should not accept other objects or cruft in the middle', function() { | ||
it('should not accept other objects', function() { | ||
[ | ||
NaN, Infinity, -Infinity, null, undefined, new Date(), '', | ||
' ', '\t', '2 2', '2%2', '2$2', {1: 2}, [1], ['1'], {}, [] | ||
' ', '\t', , {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.
Back to what it was pre #1078 on
https://github.com/plotly/plotly.js/pull/1078/files#diff-9664b6a57e7771275ffd0c8805ea5917L30