fix up raw number literal

This commit is contained in:
Sebastian McKenzie
2015-06-17 17:58:03 +01:00
parent 6386b60b9a
commit d647ede94b
5 changed files with 12 additions and 8 deletions

View File

@@ -100,7 +100,11 @@ export function Literal(node) {
// check to see if this is the same number as the raw one in the original source as asm.js uses
// numbers in the form 5.0 for type hinting
var raw = node.raw;
this.push(val === +raw ? raw : val + "");
if (val === +raw && raw[raw.length - 1] !== ".") {
this.push(raw);
} else {
this.push(val + "");
}
} else if (type === "boolean") {
this.push(val ? "true" : "false");
} else if (node.regex) {

View File

@@ -25,4 +25,4 @@
continue _function;
}
}
})(1000000) === "foo";
})(1e6) === "foo";

View File

@@ -26,4 +26,4 @@
continue _function;
}
}
})(1000000, true) === "foo";
})(1e6, true) === "foo";

View File

@@ -27,4 +27,4 @@
_again = true;
continue _function;
}
})(1000000, true) === "foo";
})(1e6, true) === "foo";

View File

@@ -8,7 +8,7 @@
try {
return f(n - 1);
} catch (e) {}
})(1000000) === "foo";
})(1e6) === "foo";
(function f(_x) {
var _again = true;
@@ -29,7 +29,7 @@
continue _function;
}
}
})(1000000) === "foo";
})(1e6) === "foo";
(function f(n) {
if (n <= 0) {
@@ -41,7 +41,7 @@
} catch (e) {
return f(n - 1);
} finally {}
})(1000000) === "foo";
})(1e6) === "foo";
(function f(_x2) {
var _again2 = true;
@@ -60,4 +60,4 @@
continue _function2;
}
}
})(1000000) === "foo";
})(1e6) === "foo";