diff --git a/Libraries/LibJS/Runtime/MathObject.cpp b/Libraries/LibJS/Runtime/MathObject.cpp index e1f0fae96e..c9390abb74 100644 --- a/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Libraries/LibJS/Runtime/MathObject.cpp @@ -126,8 +126,7 @@ Value MathObject::round(Interpreter& interpreter) Value MathObject::max(Interpreter& interpreter) { if (!interpreter.argument_count()) { - // FIXME: I think this should return *negative* infinity. - return js_infinity(); + return Value(-js_infinity().as_double()); } else if (interpreter.argument_count() == 1) { return interpreter.argument(0).to_number(); } else { diff --git a/Libraries/LibJS/Tests/Math.max.js b/Libraries/LibJS/Tests/Math.max.js index 1f27e1775c..2b4a814a9f 100644 --- a/Libraries/LibJS/Tests/Math.max.js +++ b/Libraries/LibJS/Tests/Math.max.js @@ -1,5 +1,6 @@ try { assert(Math.max.length === 2); + assert(Math.max() === -Infinity); assert(Math.max(1) === 1); assert(Math.max(2, 1) === 2); assert(Math.max(1, 2, 3) === 3);