Browse Source

Dynamic typing converts "TRUE" and "FALSE" to boolean

pull/181/head
Matthew Holt 10 years ago
parent
commit
4efe5b68f9
  1. 4
      papaparse.js
  2. 4
      tests/test-cases.js
  3. 2
      tests/test-runner.js

4
papaparse.js

@ -788,9 +788,9 @@
if (_config.dynamicTyping) if (_config.dynamicTyping)
{ {
var value = _results.data[i][j]; var value = _results.data[i][j];
if (value == "true") if (value == "true" || value == "TRUE")
_results.data[i][j] = true; _results.data[i][j] = true;
else if (value == "false") else if (value == "false" || value == "FALSE")
_results.data[i][j] = false; _results.data[i][j] = false;
else else
_results.data[i][j] = tryParseFloat(value); _results.data[i][j] = tryParseFloat(value);

4
tests/test-cases.js

@ -592,10 +592,10 @@ var PARSE_TESTS = [
}, },
{ {
description: "Dynamic typing converts boolean literals", description: "Dynamic typing converts boolean literals",
input: 'true,false,T,F,TRUE,False', input: 'true,false,T,F,TRUE,FALSE,True,False',
config: { dynamicTyping: true }, config: { dynamicTyping: true },
expected: { expected: {
data: [[true, false, "T", "F", "TRUE", "False"]], data: [[true, false, "T", "F", true, false, "True", "False"]],
errors: [] errors: []
} }
}, },

2
tests/test-runner.js

@ -178,7 +178,7 @@ function compare(actualData, actualErrors, expected)
return { return {
data: data, data: data,
errors: errors errors: errors
} };
function compareData(actual, expected) function compareData(actual, expected)

Loading…
Cancel
Save