Rename resource_name to source_name (#4846)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -4,29 +4,29 @@ Stopped at tests/debugger/do_variables.js:15
|
||||
level | type
|
||||
0 | global
|
||||
(jerry-debugger) variables
|
||||
name | type | value
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | undefined | undefined
|
||||
c | undefined | undefined
|
||||
createRealm | Function |
|
||||
resourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
name | type | value
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | undefined | undefined
|
||||
c | undefined | undefined
|
||||
createRealm | Function |
|
||||
sourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
(jerry-debugger) variables 1
|
||||
name | type | value
|
||||
(jerry-debugger) variables 0
|
||||
name | type | value
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | undefined | undefined
|
||||
c | undefined | undefined
|
||||
createRealm | Function |
|
||||
resourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
name | type | value
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | undefined | undefined
|
||||
c | undefined | undefined
|
||||
createRealm | Function |
|
||||
sourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
(jerry-debugger) b tests/debugger/do_variables.js:20
|
||||
Breakpoint 1 at tests/debugger/do_variables.js:20 (in function() at line:19, col:10)
|
||||
(jerry-debugger) c
|
||||
@@ -44,17 +44,17 @@ n | Number | 9
|
||||
name | type | value
|
||||
x | Number | 3
|
||||
(jerry-debugger) variables 2
|
||||
name | type | value
|
||||
addThree | Function |
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | Number | 5
|
||||
c | Number | 4
|
||||
createRealm | Function |
|
||||
resourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
name | type | value
|
||||
addThree | Function |
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | Number | 5
|
||||
c | Number | 4
|
||||
createRealm | Function |
|
||||
sourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
(jerry-debugger) b tests/debugger/do_variables.js:30
|
||||
Breakpoint 2 at tests/debugger/do_variables.js:30 (in f() at line:28, col:1)
|
||||
(jerry-debugger) c
|
||||
@@ -64,18 +64,18 @@ level | type
|
||||
0 | local
|
||||
1 | global
|
||||
(jerry-debugger) variables 1
|
||||
name | type | value
|
||||
d | Number | 12
|
||||
addThree | Function |
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | Number | 5
|
||||
c | Number | 4
|
||||
createRealm | Function |
|
||||
resourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
name | type | value
|
||||
d | Number | 12
|
||||
addThree | Function |
|
||||
f | Function |
|
||||
addX | Function |
|
||||
z | Number | 5
|
||||
c | Number | 4
|
||||
createRealm | Function |
|
||||
sourceName | Function |
|
||||
print | Function |
|
||||
gc | Function |
|
||||
assert | Function |
|
||||
(jerry-debugger) variables 0
|
||||
name | type | value
|
||||
b | undefined | undefined
|
||||
|
||||
+3
-3
@@ -13,11 +13,11 @@
|
||||
// limitations under the License.
|
||||
|
||||
export function getName() {
|
||||
return resourceName();
|
||||
return sourceName();
|
||||
}
|
||||
|
||||
export function getNamePromise(collector) {
|
||||
return new Promise((resolve) => { collector["start"] = resourceName(); resolve(); })
|
||||
.then(() => { collector["middle"] = resourceName(); });
|
||||
return new Promise((resolve) => { collector["start"] = sourceName(); resolve(); })
|
||||
.then(() => { collector["middle"] = sourceName(); });
|
||||
}
|
||||
|
||||
+6
-6
@@ -12,16 +12,16 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { getName, getNamePromise } from "./module-resource-name-export.mjs"
|
||||
import { getName, getNamePromise } from "./module-source-name-export.mjs"
|
||||
|
||||
assert(getName().endsWith("module-resource-name-export.mjs"));
|
||||
assert(getName().endsWith("module-source-name-export.mjs"));
|
||||
|
||||
var collector = {};
|
||||
getNamePromise(collector).then(() => { collector["end"] = resourceName(); });
|
||||
getNamePromise(collector).then(() => { collector["end"] = sourceName(); });
|
||||
|
||||
function __checkAsync() {
|
||||
assert(collector["start"].endsWith("module-resource-name-export.mjs"));
|
||||
assert(collector["middle"].endsWith("module-resource-name-export.mjs"));
|
||||
assert(collector["end"].endsWith("module-resource-name.mjs"));
|
||||
assert(collector["start"].endsWith("module-source-name-export.mjs"));
|
||||
assert(collector["middle"].endsWith("module-source-name-export.mjs"));
|
||||
assert(collector["end"].endsWith("module-source-name.mjs"));
|
||||
assert(Object.keys(collector).length === 3);
|
||||
}
|
||||
@@ -51,4 +51,4 @@ try {
|
||||
/* Check properties of a */
|
||||
assert(Object.keys(a) == "one,two");
|
||||
/* Check properties of global object */
|
||||
assert(Object.keys(this) == "assert,gc,print,resourceName,createRealm,a,fail,fail_two");
|
||||
assert(Object.keys(this) == "assert,gc,print,sourceName,createRealm,a,fail,fail_two");
|
||||
|
||||
@@ -79,7 +79,7 @@ set(SOURCE_UNIT_TEST_MAIN_MODULES
|
||||
test-error-callback.c
|
||||
test-regexp.c
|
||||
test-regression-3588.c
|
||||
test-resource-name.c
|
||||
test-source-name.c
|
||||
test-script-user-value.c
|
||||
test-snapshot.c
|
||||
test-source-info.c
|
||||
|
||||
@@ -251,7 +251,7 @@ register_callback (jerry_external_handler_t handler_p, /**< callback function */
|
||||
} /* register_callback */
|
||||
|
||||
static jerry_value_t
|
||||
run (const char *source_name_p, /**< resource name */
|
||||
run (const char *source_name_p, /**< source name */
|
||||
const char *source_p) /**< source code */
|
||||
{
|
||||
jerry_parse_options_t parse_options;
|
||||
|
||||
@@ -47,10 +47,10 @@ main (void)
|
||||
|
||||
jerry_value_t global = jerry_current_realm ();
|
||||
|
||||
/* Register the "resourceName" method. */
|
||||
/* Register the "sourceName" method. */
|
||||
{
|
||||
jerry_value_t func = jerry_function_external (source_name_handler);
|
||||
jerry_value_t name = jerry_string_sz ("resourceName");
|
||||
jerry_value_t name = jerry_string_sz ("sourceName");
|
||||
jerry_value_t result = jerry_object_set (global, name, func);
|
||||
jerry_value_free (result);
|
||||
jerry_value_free (name);
|
||||
@@ -63,9 +63,9 @@ main (void)
|
||||
parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME;
|
||||
|
||||
const char *source_1 = ("function f1 () {\n"
|
||||
" if (resourceName() !== 'demo1.js') return false; \n"
|
||||
" if (resourceName(f1) !== 'demo1.js') return false; \n"
|
||||
" if (resourceName(5) !== '<anonymous>') return false; \n"
|
||||
" if (sourceName() !== 'demo1.js') return false; \n"
|
||||
" if (sourceName(f1) !== 'demo1.js') return false; \n"
|
||||
" if (sourceName(5) !== '<anonymous>') return false; \n"
|
||||
" return f1; \n"
|
||||
"} \n"
|
||||
"f1();");
|
||||
@@ -79,23 +79,24 @@ main (void)
|
||||
TEST_ASSERT (!jerry_value_is_exception (run_result));
|
||||
TEST_ASSERT (jerry_value_is_object (run_result));
|
||||
|
||||
jerry_value_t resource_value = jerry_source_name (run_result);
|
||||
jerry_value_t compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
jerry_value_t source_name_value = jerry_source_name (run_result);
|
||||
jerry_value_t compare_result =
|
||||
jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
|
||||
jerry_value_free (run_result);
|
||||
jerry_value_free (program);
|
||||
|
||||
const char *source_2 = ("function f2 () { \n"
|
||||
" if (resourceName() !== 'demo2.js') return false; \n"
|
||||
" if (resourceName(f2) !== 'demo2.js') return false; \n"
|
||||
" if (resourceName(f1) !== 'demo1.js') return false; \n"
|
||||
" if (resourceName(Object.prototype) !== '<anonymous>') return false; \n"
|
||||
" if (resourceName(Function) !== '<anonymous>') return false; \n"
|
||||
" if (sourceName() !== 'demo2.js') return false; \n"
|
||||
" if (sourceName(f2) !== 'demo2.js') return false; \n"
|
||||
" if (sourceName(f1) !== 'demo1.js') return false; \n"
|
||||
" if (sourceName(Object.prototype) !== '<anonymous>') return false; \n"
|
||||
" if (sourceName(Function) !== '<anonymous>') return false; \n"
|
||||
" return f2; \n"
|
||||
"} \n"
|
||||
"f2(); \n");
|
||||
@@ -109,12 +110,12 @@ main (void)
|
||||
TEST_ASSERT (!jerry_value_is_exception (run_result));
|
||||
TEST_ASSERT (jerry_value_is_object (run_result));
|
||||
|
||||
resource_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
source_name_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
|
||||
jerry_value_free (run_result);
|
||||
@@ -130,33 +131,33 @@ main (void)
|
||||
program = jerry_parse ((const jerry_char_t *) source_3, strlen (source_3), &parse_options);
|
||||
TEST_ASSERT (!jerry_value_is_exception (program));
|
||||
|
||||
resource_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
source_name_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
|
||||
run_result = jerry_module_link (program, NULL, NULL);
|
||||
TEST_ASSERT (!jerry_value_is_exception (run_result));
|
||||
|
||||
resource_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, anon);
|
||||
source_name_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, anon);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (run_result);
|
||||
|
||||
run_result = jerry_module_evaluate (program);
|
||||
TEST_ASSERT (!jerry_value_is_exception (run_result));
|
||||
|
||||
resource_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, anon);
|
||||
source_name_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, anon);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (run_result);
|
||||
jerry_value_free (program);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
@@ -174,12 +175,12 @@ main (void)
|
||||
TEST_ASSERT (!jerry_value_is_exception (run_result));
|
||||
TEST_ASSERT (jerry_value_is_object (run_result));
|
||||
|
||||
resource_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
source_name_value = jerry_source_name (run_result);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
jerry_value_free (compare_result);
|
||||
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
jerry_value_free (run_result);
|
||||
jerry_value_free (program);
|
||||
@@ -193,11 +194,11 @@ main (void)
|
||||
program = jerry_parse ((const jerry_char_t *) source_5, strlen (source_5), &parse_options);
|
||||
TEST_ASSERT (!jerry_value_is_exception (program));
|
||||
|
||||
resource_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
source_name_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (compare_result);
|
||||
jerry_value_free (parse_options.user_value);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
@@ -211,11 +212,11 @@ main (void)
|
||||
program = jerry_parse ((const jerry_char_t *) source_6, strlen (source_6), &parse_options);
|
||||
if (!jerry_value_is_exception (program))
|
||||
{
|
||||
resource_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name);
|
||||
source_name_value = jerry_source_name (program);
|
||||
compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name);
|
||||
TEST_ASSERT (jerry_value_is_true (compare_result));
|
||||
|
||||
jerry_value_free (resource_value);
|
||||
jerry_value_free (source_name_value);
|
||||
jerry_value_free (compare_result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user