Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions jerry-core/ecma/builtin-objects/ecma-builtin-math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ ecma_builtin_math_object_max (ecma_value_t this_arg __attr_unused___, /**< 'this
ret_num = arg_num;
}
}
else if (ecma_number_is_infinity (ret_num)) /* ret_num is negative infinity */
else if (ecma_number_is_infinity (ret_num))
{
JERRY_ASSERT (ecma_number_is_negative (ret_num));

ret_num = arg_num;
if (ecma_number_is_negative (ret_num))
{
ret_num = arg_num;
}
}
else
{
Expand Down Expand Up @@ -443,11 +444,12 @@ ecma_builtin_math_object_min (ecma_value_t this_arg __attr_unused___, /**< 'this
ret_num = arg_num;
}
}
else if (ecma_number_is_infinity (ret_num)) /* ret_num is positive infinity */
else if (ecma_number_is_infinity (ret_num))
{
JERRY_ASSERT (!ecma_number_is_negative (ret_num));

ret_num = arg_num;
if (!ecma_number_is_negative (ret_num))
{
ret_num = arg_num;
}
}
else
{
Expand Down
10 changes: 10 additions & 0 deletions tests/jerry/math-max.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
10 changes: 10 additions & 0 deletions tests/jerry/math-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);