| Index: test/cctest/test-parsing.cc
|
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
|
| index 90d081808f8eb3f4277daac0e09bb1ec9b595101..a0e2d0a936ea56bab4beee0b8dc480c1a7d5811d 100644
|
| --- a/test/cctest/test-parsing.cc
|
| +++ b/test/cctest/test-parsing.cc
|
| @@ -1541,11 +1541,10 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
| uintptr_t stack_limit = isolate->stack_guard()->real_climit();
|
| int preparser_materialized_literals = -1;
|
| int parser_materialized_literals = -2;
|
| - bool test_preparser = !is_module;
|
|
|
| // Preparse the data.
|
| i::CompleteParserRecorder log;
|
| - if (test_preparser) {
|
| + {
|
| i::Scanner scanner(isolate->unicode_cache());
|
| i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
|
| i::Zone zone(CcTest::i_isolate()->allocator());
|
| @@ -1602,7 +1601,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
| CHECK(false);
|
| }
|
|
|
| - if (test_preparser && !preparse_error) {
|
| + if (!preparse_error) {
|
| v8::base::OS::Print(
|
| "Parser failed on:\n"
|
| "\t%s\n"
|
| @@ -1613,7 +1612,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
| CHECK(false);
|
| }
|
| // Check that preparser and parser produce the same error.
|
| - if (test_preparser) {
|
| + {
|
| i::Handle<i::String> preparser_message =
|
| FormatMessage(log.ErrorMessageData());
|
| if (!i::String::Equals(message_string, preparser_message)) {
|
| @@ -1628,7 +1627,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
| CHECK(false);
|
| }
|
| }
|
| - } else if (test_preparser && preparse_error) {
|
| + } else if (preparse_error) {
|
| v8::base::OS::Print(
|
| "Preparser failed on:\n"
|
| "\t%s\n"
|
| @@ -1645,8 +1644,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
|
| "However, parser and preparser succeeded",
|
| source->ToCString().get());
|
| CHECK(false);
|
| - } else if (test_preparser &&
|
| - preparser_materialized_literals != parser_materialized_literals) {
|
| + } else if (preparser_materialized_literals != parser_materialized_literals) {
|
| v8::base::OS::Print(
|
| "Preparser materialized literals (%d) differ from Parser materialized "
|
| "literals (%d) on:\n"
|
| @@ -5471,6 +5469,8 @@ TEST(BasicImportExportParsing) {
|
| "export { static } from 'm.js'",
|
| "export { let } from 'm.js'",
|
| "var a; export { a as b, a as c };",
|
| + "var a; export { a as await };",
|
| + "var a; export { a as enum };",
|
|
|
| "import 'somemodule.js';",
|
| "import { } from 'm.js';",
|
| @@ -5596,6 +5596,8 @@ TEST(ImportExportParsingErrors) {
|
| "import { y as yield } from 'm.js'",
|
| "import { s as static } from 'm.js'",
|
| "import { l as let } from 'm.js'",
|
| + "import { a as await } from 'm.js';",
|
| + "import { a as enum } from 'm.js';",
|
| "import { x }, def from 'm.js';",
|
| "import def, def2 from 'm.js';",
|
| "import * as x, def from 'm.js';",
|
| @@ -5665,6 +5667,142 @@ TEST(ModuleTopLevelFunctionDecl) {
|
| }
|
| }
|
|
|
| +TEST(ModuleAwaitReserved) {
|
| + // clang-format off
|
| + const char* kErrorSources[] = {
|
| + "await;",
|
| + "await: ;",
|
| + "var await;",
|
| + "var [await] = [];",
|
| + "var { await } = {};",
|
| + "var { x: await } = {};",
|
| + "{ var await; }",
|
| + "let await;",
|
| + "let [await] = [];",
|
| + "let { await } = {};",
|
| + "let { x: await } = {};",
|
| + "{ let await; }",
|
| + "const await = null;",
|
| + "const [await] = [];",
|
| + "const { await } = {};",
|
| + "const { x: await } = {};",
|
| + "{ const await = null; }",
|
| + "function await() {}",
|
| + "function f(await) {}",
|
| + "function* await() {}",
|
| + "function* g(await) {}",
|
| + "(function await() {});",
|
| + "(function (await) {});",
|
| + "(function* await() {});",
|
| + "(function* (await) {});",
|
| + "(await) => {};",
|
| + "await => {};",
|
| + "class await {}",
|
| + "class C { constructor(await) {} }",
|
| + "class C { m(await) {} }",
|
| + "class C { static m(await) {} }",
|
| + "class C { *m(await) {} }",
|
| + "class C { static *m(await) {} }",
|
| + "(class await {})",
|
| + "(class { constructor(await) {} });",
|
| + "(class { m(await) {} });",
|
| + "(class { static m(await) {} });",
|
| + "(class { *m(await) {} });",
|
| + "(class { static *m(await) {} });",
|
| + "({ m(await) {} });",
|
| + "({ *m(await) {} });",
|
| + "({ set p(await) {} });",
|
| + "try {} catch (await) {}",
|
| + "try {} catch (await) {} finally {}",
|
| + NULL
|
| + };
|
| + // clang-format on
|
| + const char* context_data[][2] = {{"", ""}, {NULL, NULL}};
|
| +
|
| + RunModuleParserSyncTest(context_data, kErrorSources, kError);
|
| +}
|
| +
|
| +TEST(ModuleAwaitReservedPreParse) {
|
| + const char* context_data[][2] = {{"", ""}, {NULL, NULL}};
|
| + const char* error_data[] = {"function f() { var await = 0; }", NULL};
|
| +
|
| + RunModuleParserSyncTest(context_data, error_data, kError);
|
| +}
|
| +
|
| +TEST(ModuleAwaitPermitted) {
|
| + // clang-format off
|
| + const char* kValidSources[] = {
|
| + "({}).await;",
|
| + "({ await: null });",
|
| + "({ await() {} });",
|
| + "({ get await() {} });",
|
| + "({ set await(x) {} });",
|
| + "(class { await() {} });",
|
| + "(class { static await() {} });",
|
| + "(class { *await() {} });",
|
| + "(class { static *await() {} });",
|
| + NULL
|
| + };
|
| + // clang-format on
|
| + const char* context_data[][2] = {{"", ""}, {NULL, NULL}};
|
| +
|
| + RunModuleParserSyncTest(context_data, kValidSources, kSuccess);
|
| +}
|
| +
|
| +TEST(EnumReserved) {
|
| + // clang-format off
|
| + const char* kErrorSources[] = {
|
| + "enum;",
|
| + "enum: ;",
|
| + "var enum;",
|
| + "var [enum] = [];",
|
| + "var { enum } = {};",
|
| + "var { x: enum } = {};",
|
| + "{ var enum; }",
|
| + "let enum;",
|
| + "let [enum] = [];",
|
| + "let { enum } = {};",
|
| + "let { x: enum } = {};",
|
| + "{ let enum; }",
|
| + "const enum = null;",
|
| + "const [enum] = [];",
|
| + "const { enum } = {};",
|
| + "const { x: enum } = {};",
|
| + "{ const enum = null; }",
|
| + "function enum() {}",
|
| + "function f(enum) {}",
|
| + "function* enum() {}",
|
| + "function* g(enum) {}",
|
| + "(function enum() {});",
|
| + "(function (enum) {});",
|
| + "(function* enum() {});",
|
| + "(function* (enum) {});",
|
| + "(enum) => {};",
|
| + "enum => {};",
|
| + "class enum {}",
|
| + "class C { constructor(enum) {} }",
|
| + "class C { m(enum) {} }",
|
| + "class C { static m(enum) {} }",
|
| + "class C { *m(enum) {} }",
|
| + "class C { static *m(enum) {} }",
|
| + "(class enum {})",
|
| + "(class { constructor(enum) {} });",
|
| + "(class { m(enum) {} });",
|
| + "(class { static m(enum) {} });",
|
| + "(class { *m(enum) {} });",
|
| + "(class { static *m(enum) {} });",
|
| + "({ m(enum) {} });",
|
| + "({ *m(enum) {} });",
|
| + "({ set p(enum) {} });",
|
| + "try {} catch (enum) {}",
|
| + "try {} catch (enum) {} finally {}",
|
| + NULL
|
| + };
|
| + // clang-format on
|
| + const char* context_data[][2] = {{"", ""}, {NULL, NULL}};
|
| +
|
| + RunModuleParserSyncTest(context_data, kErrorSources, kError);
|
| +}
|
|
|
| TEST(ModuleParsingInternals) {
|
| i::Isolate* isolate = CcTest::i_isolate();
|
|
|