Fix Number.prototype.toFixed if argument is outside int32 range

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
Dániel Bátyai
2015-07-06 15:17:27 +02:00
parent 4e5e7bb4c8
commit 47cd42ecc5
2 changed files with 20 additions and 4 deletions
+16
View File
@@ -35,10 +35,26 @@ assert((0.0).toFixed(1) === "0.0");
assert((-0.0).toFixed(0) === "-0");
assert((-0.0).toFixed(1) === "-0.0");
assert((123456789012345678901.0).toFixed(20) === "123456789012345680000.00000000000000000000");
assert((123.56).toFixed(NaN) === "124");
assert((123.56).toFixed(-0.9) === "124");
var obj = { toFixed : Number.prototype.toFixed };
assert(obj.toFixed(0) === "NaN");
try {
assert(obj.toFixed(Infinity));
assert(false);
} catch (e) {
assert(e instanceof RangeError);
}
try {
assert(obj.toFixed(-Infinity));
assert(false);
} catch (e) {
assert(e instanceof RangeError);
}
try {
assert(obj.toFixed(-1));
assert(false);