OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 } | 1278 } |
1279 | 1279 |
1280 enum ParserFlag { | 1280 enum ParserFlag { |
1281 kAllowLazy, | 1281 kAllowLazy, |
1282 kAllowNatives, | 1282 kAllowNatives, |
1283 kAllowHarmonyFunctionSent, | 1283 kAllowHarmonyFunctionSent, |
1284 kAllowHarmonyRestrictiveGenerators, | 1284 kAllowHarmonyRestrictiveGenerators, |
1285 kAllowHarmonyTrailingCommas, | 1285 kAllowHarmonyTrailingCommas, |
1286 kAllowHarmonyClassFields, | 1286 kAllowHarmonyClassFields, |
1287 kAllowHarmonyObjectRestSpread, | 1287 kAllowHarmonyObjectRestSpread, |
| 1288 kAllowHarmonyDynamicImport, |
1288 }; | 1289 }; |
1289 | 1290 |
1290 enum ParserSyncTestResult { | 1291 enum ParserSyncTestResult { |
1291 kSuccessOrError, | 1292 kSuccessOrError, |
1292 kSuccess, | 1293 kSuccess, |
1293 kError | 1294 kError |
1294 }; | 1295 }; |
1295 | 1296 |
1296 void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { | 1297 void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { |
1297 i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives); | 1298 i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives); |
1298 i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent); | 1299 i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent); |
1299 i::FLAG_harmony_restrictive_generators = | 1300 i::FLAG_harmony_restrictive_generators = |
1300 flags.Contains(kAllowHarmonyRestrictiveGenerators); | 1301 flags.Contains(kAllowHarmonyRestrictiveGenerators); |
1301 i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); | 1302 i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); |
1302 i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); | 1303 i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); |
1303 i::FLAG_harmony_object_rest_spread = | 1304 i::FLAG_harmony_object_rest_spread = |
1304 flags.Contains(kAllowHarmonyObjectRestSpread); | 1305 flags.Contains(kAllowHarmonyObjectRestSpread); |
| 1306 i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport); |
1305 } | 1307 } |
1306 | 1308 |
1307 void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { | 1309 void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
1308 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1310 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
1309 parser->set_allow_harmony_function_sent( | 1311 parser->set_allow_harmony_function_sent( |
1310 flags.Contains(kAllowHarmonyFunctionSent)); | 1312 flags.Contains(kAllowHarmonyFunctionSent)); |
1311 parser->set_allow_harmony_restrictive_generators( | 1313 parser->set_allow_harmony_restrictive_generators( |
1312 flags.Contains(kAllowHarmonyRestrictiveGenerators)); | 1314 flags.Contains(kAllowHarmonyRestrictiveGenerators)); |
1313 parser->set_allow_harmony_trailing_commas( | 1315 parser->set_allow_harmony_trailing_commas( |
1314 flags.Contains(kAllowHarmonyTrailingCommas)); | 1316 flags.Contains(kAllowHarmonyTrailingCommas)); |
1315 parser->set_allow_harmony_class_fields( | 1317 parser->set_allow_harmony_class_fields( |
1316 flags.Contains(kAllowHarmonyClassFields)); | 1318 flags.Contains(kAllowHarmonyClassFields)); |
1317 parser->set_allow_harmony_object_rest_spread( | 1319 parser->set_allow_harmony_object_rest_spread( |
1318 flags.Contains(kAllowHarmonyObjectRestSpread)); | 1320 flags.Contains(kAllowHarmonyObjectRestSpread)); |
| 1321 parser->set_allow_harmony_dynamic_import( |
| 1322 flags.Contains(kAllowHarmonyDynamicImport)); |
1319 } | 1323 } |
1320 | 1324 |
1321 void TestParserSyncWithFlags(i::Handle<i::String> source, | 1325 void TestParserSyncWithFlags(i::Handle<i::String> source, |
1322 i::EnumSet<ParserFlag> flags, | 1326 i::EnumSet<ParserFlag> flags, |
1323 ParserSyncTestResult result, | 1327 ParserSyncTestResult result, |
1324 bool is_module = false, | 1328 bool is_module = false, bool test_preparser = true, |
1325 bool test_preparser = true) { | 1329 bool ignore_error_msg = false) { |
1326 i::Isolate* isolate = CcTest::i_isolate(); | 1330 i::Isolate* isolate = CcTest::i_isolate(); |
1327 i::Factory* factory = isolate->factory(); | 1331 i::Factory* factory = isolate->factory(); |
1328 | 1332 |
1329 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1333 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); |
1330 int preparser_materialized_literals = -1; | 1334 int preparser_materialized_literals = -1; |
1331 int parser_materialized_literals = -2; | 1335 int parser_materialized_literals = -2; |
1332 | 1336 |
1333 // Preparse the data. | 1337 // Preparse the data. |
1334 i::PendingCompilationErrorHandler pending_error_handler; | 1338 i::PendingCompilationErrorHandler pending_error_handler; |
1335 if (test_preparser) { | 1339 if (test_preparser) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 v8::base::OS::Print( | 1396 v8::base::OS::Print( |
1393 "Parser failed on:\n" | 1397 "Parser failed on:\n" |
1394 "\t%s\n" | 1398 "\t%s\n" |
1395 "with error:\n" | 1399 "with error:\n" |
1396 "\t%s\n" | 1400 "\t%s\n" |
1397 "However, the preparser succeeded", | 1401 "However, the preparser succeeded", |
1398 source->ToCString().get(), message_string->ToCString().get()); | 1402 source->ToCString().get(), message_string->ToCString().get()); |
1399 CHECK(false); | 1403 CHECK(false); |
1400 } | 1404 } |
1401 // Check that preparser and parser produce the same error. | 1405 // Check that preparser and parser produce the same error. |
1402 if (test_preparser) { | 1406 if (test_preparser && !ignore_error_msg) { |
1403 i::Handle<i::String> preparser_message = | 1407 i::Handle<i::String> preparser_message = |
1404 pending_error_handler.FormatMessage(CcTest::i_isolate()); | 1408 pending_error_handler.FormatMessage(CcTest::i_isolate()); |
1405 if (!i::String::Equals(message_string, preparser_message)) { | 1409 if (!i::String::Equals(message_string, preparser_message)) { |
1406 v8::base::OS::Print( | 1410 v8::base::OS::Print( |
1407 "Expected parser and preparser to produce the same error on:\n" | 1411 "Expected parser and preparser to produce the same error on:\n" |
1408 "\t%s\n" | 1412 "\t%s\n" |
1409 "However, found the following error messages\n" | 1413 "However, found the following error messages\n" |
1410 "\tparser: %s\n" | 1414 "\tparser: %s\n" |
1411 "\tpreparser: %s\n", | 1415 "\tpreparser: %s\n", |
1412 source->ToCString().get(), message_string->ToCString().get(), | 1416 source->ToCString().get(), message_string->ToCString().get(), |
(...skipping 26 matching lines...) Expand all Loading... |
1439 "Preparser materialized literals (%d) differ from Parser materialized " | 1443 "Preparser materialized literals (%d) differ from Parser materialized " |
1440 "literals (%d) on:\n" | 1444 "literals (%d) on:\n" |
1441 "\t%s\n" | 1445 "\t%s\n" |
1442 "However, parser and preparser succeeded", | 1446 "However, parser and preparser succeeded", |
1443 preparser_materialized_literals, parser_materialized_literals, | 1447 preparser_materialized_literals, parser_materialized_literals, |
1444 source->ToCString().get()); | 1448 source->ToCString().get()); |
1445 CHECK(false); | 1449 CHECK(false); |
1446 } | 1450 } |
1447 } | 1451 } |
1448 | 1452 |
1449 | |
1450 void TestParserSync(const char* source, const ParserFlag* varying_flags, | 1453 void TestParserSync(const char* source, const ParserFlag* varying_flags, |
1451 size_t varying_flags_length, | 1454 size_t varying_flags_length, |
1452 ParserSyncTestResult result = kSuccessOrError, | 1455 ParserSyncTestResult result = kSuccessOrError, |
1453 const ParserFlag* always_true_flags = NULL, | 1456 const ParserFlag* always_true_flags = NULL, |
1454 size_t always_true_flags_length = 0, | 1457 size_t always_true_flags_length = 0, |
1455 const ParserFlag* always_false_flags = NULL, | 1458 const ParserFlag* always_false_flags = NULL, |
1456 size_t always_false_flags_length = 0, | 1459 size_t always_false_flags_length = 0, |
1457 bool is_module = false, bool test_preparser = true) { | 1460 bool is_module = false, bool test_preparser = true, |
| 1461 bool ignore_error_msg = false) { |
1458 i::Handle<i::String> str = | 1462 i::Handle<i::String> str = |
1459 CcTest::i_isolate()->factory()->NewStringFromAsciiChecked(source); | 1463 CcTest::i_isolate()->factory()->NewStringFromAsciiChecked(source); |
1460 for (int bits = 0; bits < (1 << varying_flags_length); bits++) { | 1464 for (int bits = 0; bits < (1 << varying_flags_length); bits++) { |
1461 i::EnumSet<ParserFlag> flags; | 1465 i::EnumSet<ParserFlag> flags; |
1462 for (size_t flag_index = 0; flag_index < varying_flags_length; | 1466 for (size_t flag_index = 0; flag_index < varying_flags_length; |
1463 ++flag_index) { | 1467 ++flag_index) { |
1464 if ((bits & (1 << flag_index)) != 0) flags.Add(varying_flags[flag_index]); | 1468 if ((bits & (1 << flag_index)) != 0) flags.Add(varying_flags[flag_index]); |
1465 } | 1469 } |
1466 for (size_t flag_index = 0; flag_index < always_true_flags_length; | 1470 for (size_t flag_index = 0; flag_index < always_true_flags_length; |
1467 ++flag_index) { | 1471 ++flag_index) { |
1468 flags.Add(always_true_flags[flag_index]); | 1472 flags.Add(always_true_flags[flag_index]); |
1469 } | 1473 } |
1470 for (size_t flag_index = 0; flag_index < always_false_flags_length; | 1474 for (size_t flag_index = 0; flag_index < always_false_flags_length; |
1471 ++flag_index) { | 1475 ++flag_index) { |
1472 flags.Remove(always_false_flags[flag_index]); | 1476 flags.Remove(always_false_flags[flag_index]); |
1473 } | 1477 } |
1474 TestParserSyncWithFlags(str, flags, result, is_module, test_preparser); | 1478 TestParserSyncWithFlags(str, flags, result, is_module, test_preparser, |
| 1479 ignore_error_msg); |
1475 } | 1480 } |
1476 } | 1481 } |
1477 | 1482 |
1478 | 1483 |
1479 TEST(ParserSync) { | 1484 TEST(ParserSync) { |
1480 const char* context_data[][2] = { | 1485 const char* context_data[][2] = { |
1481 { "", "" }, | 1486 { "", "" }, |
1482 { "{", "}" }, | 1487 { "{", "}" }, |
1483 { "if (true) ", " else {}" }, | 1488 { "if (true) ", " else {}" }, |
1484 { "if (true) {} else ", "" }, | 1489 { "if (true) {} else ", "" }, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 " }; \n" | 1609 " }; \n" |
1605 "}; \n"; | 1610 "}; \n"; |
1606 v8_compile(v8_str(script)); | 1611 v8_compile(v8_str(script)); |
1607 CHECK(try_catch.HasCaught()); | 1612 CHECK(try_catch.HasCaught()); |
1608 v8::String::Utf8Value exception(try_catch.Exception()); | 1613 v8::String::Utf8Value exception(try_catch.Exception()); |
1609 CHECK_EQ(0, | 1614 CHECK_EQ(0, |
1610 strcmp("SyntaxError: Octal literals are not allowed in strict mode.", | 1615 strcmp("SyntaxError: Octal literals are not allowed in strict mode.", |
1611 *exception)); | 1616 *exception)); |
1612 } | 1617 } |
1613 | 1618 |
1614 | 1619 void RunParserSyncTest( |
1615 void RunParserSyncTest(const char* context_data[][2], | 1620 const char* context_data[][2], const char* statement_data[], |
1616 const char* statement_data[], | 1621 ParserSyncTestResult result, const ParserFlag* flags = NULL, |
1617 ParserSyncTestResult result, | 1622 int flags_len = 0, const ParserFlag* always_true_flags = NULL, |
1618 const ParserFlag* flags = NULL, int flags_len = 0, | 1623 int always_true_len = 0, const ParserFlag* always_false_flags = NULL, |
1619 const ParserFlag* always_true_flags = NULL, | 1624 int always_false_len = 0, bool is_module = false, |
1620 int always_true_len = 0, | 1625 bool test_preparser = true, bool ignore_error_msg = false) { |
1621 const ParserFlag* always_false_flags = NULL, | |
1622 int always_false_len = 0, bool is_module = false, | |
1623 bool test_preparser = true) { | |
1624 v8::HandleScope handles(CcTest::isolate()); | 1626 v8::HandleScope handles(CcTest::isolate()); |
1625 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1627 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
1626 v8::Context::Scope context_scope(context); | 1628 v8::Context::Scope context_scope(context); |
1627 | 1629 |
1628 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 1630 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
1629 i::GetCurrentStackPosition() - 128 * 1024); | 1631 i::GetCurrentStackPosition() - 128 * 1024); |
1630 | 1632 |
1631 // Experimental feature flags should not go here; pass the flags as | 1633 // Experimental feature flags should not go here; pass the flags as |
1632 // always_true_flags if the test needs them. | 1634 // always_true_flags if the test needs them. |
1633 static const ParserFlag default_flags[] = { | 1635 static const ParserFlag default_flags[] = { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 // Plug the source code pieces together. | 1670 // Plug the source code pieces together. |
1669 i::ScopedVector<char> program(kProgramSize + 1); | 1671 i::ScopedVector<char> program(kProgramSize + 1); |
1670 int length = i::SNPrintF(program, | 1672 int length = i::SNPrintF(program, |
1671 "%s%s%s", | 1673 "%s%s%s", |
1672 context_data[i][0], | 1674 context_data[i][0], |
1673 statement_data[j], | 1675 statement_data[j], |
1674 context_data[i][1]); | 1676 context_data[i][1]); |
1675 CHECK(length == kProgramSize); | 1677 CHECK(length == kProgramSize); |
1676 TestParserSync(program.start(), flags, flags_len, result, | 1678 TestParserSync(program.start(), flags, flags_len, result, |
1677 always_true_flags, always_true_len, always_false_flags, | 1679 always_true_flags, always_true_len, always_false_flags, |
1678 always_false_len, is_module, test_preparser); | 1680 always_false_len, is_module, test_preparser, |
| 1681 ignore_error_msg); |
1679 } | 1682 } |
1680 } | 1683 } |
1681 delete[] generated_flags; | 1684 delete[] generated_flags; |
1682 } | 1685 } |
1683 | 1686 |
1684 | 1687 void RunModuleParserSyncTest( |
1685 void RunModuleParserSyncTest(const char* context_data[][2], | 1688 const char* context_data[][2], const char* statement_data[], |
1686 const char* statement_data[], | 1689 ParserSyncTestResult result, const ParserFlag* flags = NULL, |
1687 ParserSyncTestResult result, | 1690 int flags_len = 0, const ParserFlag* always_true_flags = NULL, |
1688 const ParserFlag* flags = NULL, int flags_len = 0, | 1691 int always_true_len = 0, const ParserFlag* always_false_flags = NULL, |
1689 const ParserFlag* always_true_flags = NULL, | 1692 int always_false_len = 0, bool test_preparser = true, |
1690 int always_true_len = 0, | 1693 bool ignore_error_msg = false) { |
1691 const ParserFlag* always_false_flags = NULL, | |
1692 int always_false_len = 0, | |
1693 bool test_preparser = true) { | |
1694 RunParserSyncTest(context_data, statement_data, result, flags, flags_len, | 1694 RunParserSyncTest(context_data, statement_data, result, flags, flags_len, |
1695 always_true_flags, always_true_len, always_false_flags, | 1695 always_true_flags, always_true_len, always_false_flags, |
1696 always_false_len, true, test_preparser); | 1696 always_false_len, true, test_preparser, ignore_error_msg); |
1697 } | 1697 } |
1698 | 1698 |
1699 | 1699 |
1700 TEST(ErrorsEvalAndArguments) { | 1700 TEST(ErrorsEvalAndArguments) { |
1701 // Tests that both preparsing and parsing produce the right kind of errors for | 1701 // Tests that both preparsing and parsing produce the right kind of errors for |
1702 // using "eval" and "arguments" as identifiers. Without the strict mode, it's | 1702 // using "eval" and "arguments" as identifiers. Without the strict mode, it's |
1703 // ok to use "eval" or "arguments" as identifiers. With the strict mode, it | 1703 // ok to use "eval" or "arguments" as identifiers. With the strict mode, it |
1704 // isn't. | 1704 // isn't. |
1705 const char* context_data[][2] = { | 1705 const char* context_data[][2] = { |
1706 {"\"use strict\";", ""}, | 1706 {"\"use strict\";", ""}, |
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4135 "new super(12, 45)", | 4135 "new super(12, 45)", |
4136 "new new super", | 4136 "new new super", |
4137 "new new super()", | 4137 "new new super()", |
4138 "new new super()()", | 4138 "new new super()()", |
4139 NULL | 4139 NULL |
4140 }; | 4140 }; |
4141 | 4141 |
4142 RunParserSyncTest(context_data, expression_data, kError); | 4142 RunParserSyncTest(context_data, expression_data, kError); |
4143 } | 4143 } |
4144 | 4144 |
| 4145 TEST(ImportExpressionSuccess) { |
| 4146 // clang-format off |
| 4147 const char* context_data[][2] = { |
| 4148 {"", ""}, |
| 4149 {NULL, NULL} |
| 4150 }; |
| 4151 |
| 4152 const char* data[] = { |
| 4153 "new import(x)", |
| 4154 "import(1)", |
| 4155 "import(y=x)", |
| 4156 "f(...[import(y=x)])", |
| 4157 "x = {[import(y=x)]: 1}", |
| 4158 "var {[import(y=x)]: x} = {}", |
| 4159 "({[import(y=x)]: x} = {})", |
| 4160 "async () => { await import(x) }", |
| 4161 "() => { import(x) }", |
| 4162 "(import(y=x))", |
| 4163 "{import(y=x)}", |
| 4164 "import(import(x))", |
| 4165 "x = import(x)", |
| 4166 "var x = import(x)", |
| 4167 "let x = import(x)", |
| 4168 "for(x of import(x)) {}", |
| 4169 "import(x).then()", |
| 4170 NULL |
| 4171 }; |
| 4172 |
| 4173 // clang-format on |
| 4174 |
| 4175 // We ignore test error messages because the error message from the |
| 4176 // parser/preparser is different for the same data depending on the |
| 4177 // context. |
| 4178 // For example, a top level "import(" is parsed as an |
| 4179 // import declaration. The parser parses the import token correctly |
| 4180 // and then shows an "Unexpected token (" error message. The |
| 4181 // preparser does not understand the import keyword (this test is |
| 4182 // run without kAllowHarmonyDynamicImport flag), so this results in |
| 4183 // an "Unexpected token import" error. |
| 4184 RunParserSyncTest(context_data, data, kError); |
| 4185 RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, 0, |
| 4186 true, true); |
| 4187 static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; |
| 4188 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| 4189 arraysize(flags)); |
| 4190 RunModuleParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| 4191 arraysize(flags)); |
| 4192 } |
| 4193 |
| 4194 TEST(ImportExpressionErrors) { |
| 4195 { |
| 4196 // clang-format off |
| 4197 const char* context_data[][2] = { |
| 4198 {"", ""}, |
| 4199 {"var ", ""}, |
| 4200 {"let ", ""}, |
| 4201 {"new ", ""}, |
| 4202 {NULL, NULL} |
| 4203 }; |
| 4204 |
| 4205 const char* data[] = { |
| 4206 "import(", |
| 4207 "import)", |
| 4208 "import()", |
| 4209 "import('x", |
| 4210 "import('x']", |
| 4211 "import['x')", |
| 4212 "import = x", |
| 4213 "import[", |
| 4214 "import[]", |
| 4215 "import]", |
| 4216 "import[x]", |
| 4217 "import{", |
| 4218 "import{x", |
| 4219 "import{x}", |
| 4220 "import(x, y)", |
| 4221 "import(...y)", |
| 4222 "import(x,)", |
| 4223 "import(,)", |
| 4224 "import(,y)", |
| 4225 "import(;)", |
| 4226 "[import]", |
| 4227 "{import}", |
| 4228 "import+", |
| 4229 "import = 1", |
| 4230 "import.wat", |
| 4231 NULL |
| 4232 }; |
| 4233 |
| 4234 // clang-format on |
| 4235 RunParserSyncTest(context_data, data, kError); |
| 4236 // We ignore the error messages for the reason explained in the |
| 4237 // ImportExpressionSuccess test. |
| 4238 RunModuleParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0, NULL, |
| 4239 0, true, true); |
| 4240 static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; |
| 4241 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| 4242 arraysize(flags)); |
| 4243 |
| 4244 // We ignore test error messages because the error message from |
| 4245 // the parser/preparser is different for the same data depending |
| 4246 // on the context. For example, a top level "import{" is parsed |
| 4247 // as an import declaration. The parser parses the import token |
| 4248 // correctly and then shows an "Unexpected end of input" error |
| 4249 // message because of the '{'. The preparser shows an "Unexpected |
| 4250 // token {" because it's not a valid token in a CallExpression. |
| 4251 RunModuleParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| 4252 arraysize(flags), NULL, 0, true, true); |
| 4253 } |
| 4254 |
| 4255 { |
| 4256 // clang-format off |
| 4257 const char* context_data[][2] = { |
| 4258 {"var ", ""}, |
| 4259 {"let ", ""}, |
| 4260 {NULL, NULL} |
| 4261 }; |
| 4262 |
| 4263 const char* data[] = { |
| 4264 "import('x')", |
| 4265 NULL |
| 4266 }; |
| 4267 |
| 4268 // clang-format on |
| 4269 RunParserSyncTest(context_data, data, kError); |
| 4270 RunModuleParserSyncTest(context_data, data, kError); |
| 4271 |
| 4272 static const ParserFlag flags[] = {kAllowHarmonyDynamicImport}; |
| 4273 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| 4274 arraysize(flags)); |
| 4275 RunModuleParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| 4276 arraysize(flags)); |
| 4277 } |
| 4278 } |
4145 | 4279 |
4146 TEST(SuperCall) { | 4280 TEST(SuperCall) { |
4147 const char* context_data[][2] = {{"", ""}, | 4281 const char* context_data[][2] = {{"", ""}, |
4148 {NULL, NULL}}; | 4282 {NULL, NULL}}; |
4149 | 4283 |
4150 const char* success_data[] = { | 4284 const char* success_data[] = { |
4151 "class C extends B { constructor() { super(); } }", | 4285 "class C extends B { constructor() { super(); } }", |
4152 "class C extends B { constructor() { () => super(); } }", | 4286 "class C extends B { constructor() { () => super(); } }", |
4153 NULL | 4287 NULL |
4154 }; | 4288 }; |
(...skipping 5007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9162 eager_info.literal()->scope()->inner_scope()->inner_scope(); | 9296 eager_info.literal()->scope()->inner_scope()->inner_scope(); |
9163 DCHECK_NOT_NULL(scope); | 9297 DCHECK_NOT_NULL(scope); |
9164 DCHECK_NULL(scope->sibling()); | 9298 DCHECK_NULL(scope->sibling()); |
9165 DCHECK(scope->is_function_scope()); | 9299 DCHECK(scope->is_function_scope()); |
9166 | 9300 |
9167 size_t index = 0; | 9301 size_t index = 0; |
9168 i::ScopeTestHelper::CompareScopeToData( | 9302 i::ScopeTestHelper::CompareScopeToData( |
9169 scope, lazy_info.preparsed_scope_data(), index); | 9303 scope, lazy_info.preparsed_scope_data(), index); |
9170 } | 9304 } |
9171 } | 9305 } |
OLD | NEW |