fix(dynamic-typing): accept an explicit leading plus sign on numbers
The FLOAT gate in testFloat allowed only a minus sign on the mantissa, while the exponent right after it already allowed either sign. dynamicTyping therefore left +42 and +1.5E-03 as strings and converted -42 and -1.5E-03, silently producing columns that mix numbers and strings depending on how each row wrote its sign. parseFloat already accepts a leading plus and returns the right value, so the regex was stricter than the conversion it guards. Allow either sign on the mantissa, matching the exponent. The 2^53 precision guard is unchanged, and a plus that is not a sign is still rejected. Fixes #1070
This commit is contained in:
1 parent
b604b5b84b
commit
378043f104
2 files changed
+19
-1
No files matched your search
@@ -932,6 +932,24 @@ var PARSE_TESTS = [
|
||||
errors: []
|
||||
}
|
||||
},
|
||||
{
|
||||
description: "Dynamic typing converts numeric literals with an explicit plus sign",
|
||||
input: '+1,+2.2,+1e3\r\n+4,+4.5,+1.5E-03\r\n+.5,+9007199254740991,+9007199254740992',
|
||||
config: { dynamicTyping: true },
|
||||
expected: {
|
||||
data: [[1, 2.2, 1000], [4, 4.5, 0.0015], [0.5, 9007199254740991, "+9007199254740992"]],
|
||||
errors: []
|
||||
}
|
||||
},
|
||||
{
|
||||
description: "Dynamic typing doesn't convert a plus sign that isn't a sign",
|
||||
input: '+,++1,+-1\r\n+a,1+2,+ 1',
|
||||
config: { dynamicTyping: true },
|
||||
expected: {
|
||||
data: [["+", "++1", "+-1"], ["+a", "1+2", "+ 1"]],
|
||||
errors: []
|
||||
}
|
||||
},
|
||||
{
|
||||
description: "Dynamic typing converts boolean literals",
|
||||
input: 'true,false,T,F,TRUE,FALSE,True,False',
|
||||
|
||||
Reference in new issue
Block a user