Fix argument boundary check order during number format conversion (#4031)

Also added some tests related to the issues caused by the wrong order

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-07-24 15:55:12 +02:00
committed by GitHub
parent d39a076b2e
commit da5b058dec
2 changed files with 44 additions and 7 deletions
@@ -59,3 +59,31 @@ try {
} catch (e) {
assert(e instanceof TypeError)
}
assert((+Infinity).toPrecision(1000) === "Infinity");
var n = new Number(+Infinity);
assert(n.toPrecision(1000) === "Infinity");
assert((-Infinity).toPrecision(1000) === "-Infinity");
var n = new Number(-Infinity);
assert(n.toPrecision(1000) === "-Infinity");
assert(NaN.toPrecision(undefined) === "NaN");
var calls = 0;
var p = {
valueOf: function() {
calls++;
return Infinity;
}
};
assert(NaN.toPrecision(p) === "NaN");
assert(calls === 1);
var n = new Number(NaN);
calls = 0;
assert(n.toPrecision(p) === "NaN");
assert(calls === 1);