Skip to content

Commit

Permalink
propse fix for issue misoproject#217
Browse files Browse the repository at this point in the history
123.23e-3 was not passing as number
  • Loading branch information
Alexandre Masselot committed Nov 7, 2013
1 parent 6e38ea1 commit 3a9e01b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@

number : {
name : "number",
regexp : /^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,
regexp : /^\s*[\-\.]?[0-9]+([\.][0-9]+)?([eE]\-?\d+)?\s*$/,
coerce : function(v) {
var cv = +v;
if (_.isNull(v) || typeof v === "undefined" || _.isNaN(cv)) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var Dataset = global.Miso.Dataset;

var numbers = ['123', '0.34', '.23'];
var numbers = ['123', '0.34', '.23', '1.23e-2', '1.23e2'];
var not_numbers = [null, NaN,undefined];


Expand Down Expand Up @@ -45,7 +45,7 @@


test("Coerce number type", function() {
var coerced = [123, 0.34, 0.23];
var coerced = [123, 0.34, 0.23, 0.0123, 123];
_.each(numbers, function(num, i) {
equals(Dataset.types.number.coerce(num), coerced[i], "Should return true for a number");
});
Expand Down

0 comments on commit 3a9e01b

Please sign in to comment.