Fix float point number comparsion (#3596)

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
This commit is contained in:
Roland Takacs
2020-03-02 15:57:11 +01:00
committed by GitHub
parent aa17a4fa5d
commit 19c61e14c0
2 changed files with 8 additions and 2 deletions
+5 -2
View File
@@ -98,9 +98,12 @@ ecma_op_same_value (ecma_value_t x, /**< ecma value */
ecma_number_t x_num = ecma_get_number_from_value (x);
ecma_number_t y_num = ecma_get_number_from_value (y);
if (ecma_number_is_nan (x_num) == ecma_number_is_nan (y_num))
bool is_x_nan = ecma_number_is_nan (x_num);
bool is_y_nan = ecma_number_is_nan (y_num);
if (is_x_nan || is_y_nan)
{
return true;
return is_x_nan && is_y_nan;
}
if (ecma_number_is_zero (x_num)
+3
View File
@@ -23,6 +23,9 @@ assert(Object.is(null, null) === true);
assert(Object.is(2, 8) === false);
assert(Object.is(8, 8) === true);
assert(Object.is(3.14, 6.28) === false);
assert(Object.is(3.14, 3.14) === true);
assert(Object.is('foo', 'foo') === true);
assert(Object.is('foo', 'bar') === false);
assert(Object.is(new String('foo'), 'foo') === false);