mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix property name comparison when external strings are used. (#4033)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
a4952da831
commit
d92d9db40f
@ -1843,25 +1843,11 @@ ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, /**< ecma-
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_string_container_t string1_container = ECMA_STRING_GET_CONTAINER (string1_p);
|
||||
|
||||
if (string1_container != ECMA_STRING_GET_CONTAINER (string2_p))
|
||||
if (ECMA_STRING_GET_CONTAINER (string1_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
|
||||
{
|
||||
return false;
|
||||
return ECMA_STRING_GET_CONTAINER (string2_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC;
|
||||
}
|
||||
|
||||
if (string1_container == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (string1_container == ECMA_STRING_CONTAINER_SYMBOL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return ecma_compare_ecma_strings_longpath (string1_p, string2_p);
|
||||
} /* ecma_compare_ecma_non_direct_strings */
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ static int free_count = 0;
|
||||
static const char *external_1 = "External string! External string! External string! External string!";
|
||||
static const char *external_2 = "Object";
|
||||
static const char *external_3 = "x!?:s";
|
||||
static const char *external_4 = "Object property external string! Object property external string!";
|
||||
|
||||
static void
|
||||
free_external1 (void *ptr)
|
||||
@ -117,6 +118,43 @@ main (void)
|
||||
jerry_release_value (external_string);
|
||||
TEST_ASSERT (free_count == 5);
|
||||
|
||||
/* Test property access. */
|
||||
external_string = jerry_create_external_string ((jerry_char_t *) external_4, NULL);
|
||||
other_string = jerry_create_string ((jerry_char_t *) external_4);
|
||||
|
||||
jerry_value_t obj = jerry_create_object ();
|
||||
result = jerry_set_property (obj, external_string, other_string);
|
||||
TEST_ASSERT (jerry_value_is_boolean (result));
|
||||
TEST_ASSERT (jerry_get_boolean_value (result));
|
||||
jerry_release_value (result);
|
||||
|
||||
jerry_value_t get_result = jerry_get_property (obj, other_string);
|
||||
TEST_ASSERT (jerry_value_is_string (get_result));
|
||||
|
||||
result = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, get_result, external_string);
|
||||
jerry_release_value (get_result);
|
||||
TEST_ASSERT (jerry_value_is_boolean (result));
|
||||
TEST_ASSERT (jerry_get_boolean_value (result));
|
||||
jerry_release_value (result);
|
||||
|
||||
result = jerry_set_property (obj, other_string, external_string);
|
||||
TEST_ASSERT (jerry_value_is_boolean (result));
|
||||
TEST_ASSERT (jerry_get_boolean_value (result));
|
||||
jerry_release_value (result);
|
||||
|
||||
get_result = jerry_get_property (obj, external_string);
|
||||
TEST_ASSERT (jerry_value_is_string (get_result));
|
||||
|
||||
result = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, get_result, other_string);
|
||||
jerry_release_value (get_result);
|
||||
TEST_ASSERT (jerry_value_is_boolean (result));
|
||||
TEST_ASSERT (jerry_get_boolean_value (result));
|
||||
jerry_release_value (result);
|
||||
|
||||
jerry_release_value (obj);
|
||||
jerry_release_value (external_string);
|
||||
jerry_release_value (other_string);
|
||||
|
||||
jerry_cleanup ();
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user