diff --git a/jerry-core/ecma/operations/ecma-conversion.cpp b/jerry-core/ecma/operations/ecma-conversion.cpp index 71245c570..468e0a0d8 100644 --- a/jerry-core/ecma/operations/ecma-conversion.cpp +++ b/jerry-core/ecma/operations/ecma-conversion.cpp @@ -102,22 +102,28 @@ ecma_op_same_value (ecma_value_t x, /**< ecma-value */ { return false; } - - if (is_x_undefined - || is_x_null) + else if (is_x_undefined || is_x_null) { return true; } - - if (is_x_number) + else if (is_x_number) { ecma_number_t *x_num_p = ecma_get_number_from_value (x); ecma_number_t *y_num_p = ecma_get_number_from_value (y); - if (ecma_number_is_nan (*x_num_p) - && ecma_number_is_nan (*y_num_p)) + bool is_x_nan = ecma_number_is_nan (*x_num_p); + bool is_y_nan = ecma_number_is_nan (*y_num_p); + + if (is_x_nan || is_y_nan) { - return true; + /* + * If both are NaN + * return true; + * else + * // one of the numbers is NaN, and another - is not + * return false; + */ + return (is_x_nan && is_y_nan); } else if (ecma_number_is_zero (*x_num_p) && ecma_number_is_zero (*y_num_p) @@ -125,26 +131,28 @@ ecma_op_same_value (ecma_value_t x, /**< ecma-value */ { return false; } - - return (*x_num_p == *y_num_p); + else + { + return (*x_num_p == *y_num_p); + } } - - if (is_x_string) + else if (is_x_string) { ecma_string_t* x_str_p = ecma_get_string_from_value (x); ecma_string_t* y_str_p = ecma_get_string_from_value (y); return ecma_compare_ecma_strings (x_str_p, y_str_p); } - - if (is_x_boolean) + else if (is_x_boolean) { return (ecma_is_value_true (x) == ecma_is_value_true (y)); } + else + { + JERRY_ASSERT (is_x_object); - JERRY_ASSERT (is_x_object); - - return (ecma_get_object_from_value (x) == ecma_get_object_from_value (y)); + return (ecma_get_object_from_value (x) == ecma_get_object_from_value (y)); + } } /* ecma_op_same_value */ /** diff --git a/tests/jerry/regression-test-issue-130.js b/tests/jerry/regression-test-issue-130.js new file mode 100644 index 000000000..b8a6a1f67 --- /dev/null +++ b/tests/jerry/regression-test-issue-130.js @@ -0,0 +1,17 @@ +// Copyright 2015 Samsung Electronics Co., Ltd. +// Copyright 2015 University of Szeged. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +v_1 = Math.floor('\u3d52'); +v_1 = Math.floor([]);