Change resource name to a string. (#4724)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1048,11 +1048,9 @@ main (void)
|
||||
"SyntaxError: Primary expression expected [<anonymous>:2:10]",
|
||||
false);
|
||||
|
||||
const jerry_char_t file_str[] = "filename.js";
|
||||
jerry_parse_options_t parse_options;
|
||||
parse_options.options = JERRY_PARSE_HAS_RESOURCE;
|
||||
parse_options.resource_name_p = file_str;
|
||||
parse_options.resource_name_length = sizeof (file_str) - 1;
|
||||
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) "filename.js");
|
||||
|
||||
test_syntax_error ("b = 'hello';\nvar a = (;",
|
||||
&parse_options,
|
||||
@@ -1073,6 +1071,7 @@ main (void)
|
||||
"SyntaxError: Expected ')' token [filename.js:10:36]",
|
||||
false);
|
||||
|
||||
jerry_release_value (parse_options.resource_name);
|
||||
jerry_cleanup ();
|
||||
}
|
||||
|
||||
|
||||
@@ -225,12 +225,12 @@ run (const char *resource_name_p, /**< resource name */
|
||||
{
|
||||
jerry_parse_options_t parse_options;
|
||||
parse_options.options = JERRY_PARSE_HAS_RESOURCE;
|
||||
parse_options.resource_name_p = (const jerry_char_t *) resource_name_p;
|
||||
parse_options.resource_name_length = strlen (resource_name_p);
|
||||
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) resource_name_p);
|
||||
|
||||
jerry_value_t code = jerry_parse ((const jerry_char_t *) source_p,
|
||||
strlen (source_p),
|
||||
&parse_options);
|
||||
jerry_release_value (parse_options.resource_name);
|
||||
TEST_ASSERT (!jerry_value_is_error (code));
|
||||
|
||||
jerry_value_t result = jerry_run (code);
|
||||
|
||||
@@ -68,10 +68,8 @@ main (void)
|
||||
" return f1; \n"
|
||||
"} \n"
|
||||
"f1();");
|
||||
const char *resource_1 = "demo1.js";
|
||||
|
||||
parse_options.resource_name_p = (const jerry_char_t *) resource_1;
|
||||
parse_options.resource_name_length = strlen (resource_1);
|
||||
parse_options.resource_name = jerry_create_string ((jerry_char_t *) "demo1.js");
|
||||
|
||||
jerry_value_t program = jerry_parse ((const jerry_char_t *) source_1,
|
||||
strlen (source_1),
|
||||
@@ -83,10 +81,9 @@ main (void)
|
||||
TEST_ASSERT (jerry_value_is_object (run_result));
|
||||
|
||||
jerry_value_t resource_value = jerry_get_resource_name (run_result);
|
||||
jerry_value_t resource1_name_value = jerry_create_string ((const jerry_char_t *) resource_1);
|
||||
TEST_ASSERT (jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, resource_value, resource1_name_value));
|
||||
jerry_release_value (resource1_name_value);
|
||||
TEST_ASSERT (jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.resource_name));
|
||||
jerry_release_value (resource_value);
|
||||
jerry_release_value (parse_options.resource_name);
|
||||
|
||||
jerry_release_value (run_result);
|
||||
jerry_release_value (program);
|
||||
@@ -100,10 +97,8 @@ main (void)
|
||||
" return f2; \n"
|
||||
"} \n"
|
||||
"f2(); \n");
|
||||
const char *resource_2 = "demo2.js";
|
||||
|
||||
parse_options.resource_name_p = (const jerry_char_t *) resource_2;
|
||||
parse_options.resource_name_length = strlen (resource_2);
|
||||
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) "demo2.js");
|
||||
|
||||
program = jerry_parse ((const jerry_char_t *) source_2,
|
||||
strlen (source_2),
|
||||
@@ -115,10 +110,9 @@ main (void)
|
||||
TEST_ASSERT (jerry_value_is_object (run_result));
|
||||
|
||||
resource_value = jerry_get_resource_name (run_result);
|
||||
jerry_value_t resource2_name_value = jerry_create_string ((const jerry_char_t *) resource_2);
|
||||
TEST_ASSERT (jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, resource_value, resource2_name_value));
|
||||
jerry_release_value (resource2_name_value);
|
||||
TEST_ASSERT (jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.resource_name));
|
||||
jerry_release_value (resource_value);
|
||||
jerry_release_value (parse_options.resource_name);
|
||||
|
||||
jerry_release_value (run_result);
|
||||
jerry_release_value (program);
|
||||
|
||||
Reference in New Issue
Block a user