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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user