Improve Infinity handling in Math.min/max methods.
In Math.max case: if we already found an infinity value update the result only when the previous value was a negative infinity. In Math.min case: if we already found an infinity value update the result only when the previous value was a positive infinity. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
@@ -27,3 +27,13 @@ assert(Math['max'] () === -Infinity);
|
||||
|
||||
assert(Math['max'] (0.0, -0.0) === 0.0);
|
||||
assert(Math['max'] (-0.0, 0.0) === 0.0);
|
||||
|
||||
assert(Math['max'] (2, Infinity) === Infinity);
|
||||
assert(Math['max'] (Infinity, 2) === Infinity);
|
||||
assert(Math['max'] (2, -Infinity) === 2);
|
||||
assert(Math['max'] (-Infinity, 2) === 2);
|
||||
|
||||
assert(Math['max'] (-2, Infinity) === Infinity);
|
||||
assert(Math['max'] (Infinity, -2) === Infinity);
|
||||
assert(Math['max'] (-2, -Infinity) === -2);
|
||||
assert(Math['max'] (-Infinity, -2) === -2);
|
||||
|
||||
Vendored
+10
@@ -27,3 +27,13 @@ assert(Math['min'] () === Infinity);
|
||||
|
||||
assert(Math['min'] (0.0, -0.0) === -0.0);
|
||||
assert(Math['min'] (-0.0, 0.0) === -0.0);
|
||||
|
||||
assert(Math['min'] (2, -Infinity) === -Infinity);
|
||||
assert(Math['min'] (-Infinity, 2) === -Infinity);
|
||||
assert(Math['min'] (2, Infinity) === 2);
|
||||
assert(Math['min'] (Infinity, 2) === 2);
|
||||
|
||||
assert(Math['min'] (-2, Infinity) === -2);
|
||||
assert(Math['min'] (Infinity, -2) === -2);
|
||||
assert(Math['min'] (-2, -Infinity) === -Infinity);
|
||||
assert(Math['min'] (-Infinity, -2) === -Infinity);
|
||||
|
||||
Reference in New Issue
Block a user