| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65   i::byte buffer[32]; | 65   i::byte buffer[32]; | 
| 66   for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { | 66   for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { | 
| 67     const i::byte* keyword = | 67     const i::byte* keyword = | 
| 68         reinterpret_cast<const i::byte*>(key_token.keyword); | 68         reinterpret_cast<const i::byte*>(key_token.keyword); | 
| 69     int length = i::StrLength(key_token.keyword); | 69     int length = i::StrLength(key_token.keyword); | 
| 70     CHECK(static_cast<int>(sizeof(buffer)) >= length); | 70     CHECK(static_cast<int>(sizeof(buffer)) >= length); | 
| 71     { | 71     { | 
| 72       i::Utf8ToUtf16CharacterStream stream(keyword, length); | 72       i::Utf8ToUtf16CharacterStream stream(keyword, length); | 
| 73       i::Scanner scanner(&unicode_cache); | 73       i::Scanner scanner(&unicode_cache); | 
| 74       // The scanner should parse Harmony keywords for this test. | 74       // The scanner should parse Harmony keywords for this test. | 
| 75       scanner.SetHarmonyScoping(true); |  | 
| 76       scanner.SetHarmonyModules(true); | 75       scanner.SetHarmonyModules(true); | 
| 77       scanner.SetHarmonyClasses(true); | 76       scanner.SetHarmonyClasses(true); | 
| 78       scanner.Initialize(&stream); | 77       scanner.Initialize(&stream); | 
| 79       CHECK_EQ(key_token.token, scanner.Next()); | 78       CHECK_EQ(key_token.token, scanner.Next()); | 
| 80       CHECK_EQ(i::Token::EOS, scanner.Next()); | 79       CHECK_EQ(i::Token::EOS, scanner.Next()); | 
| 81     } | 80     } | 
| 82     // Removing characters will make keyword matching fail. | 81     // Removing characters will make keyword matching fail. | 
| 83     { | 82     { | 
| 84       i::Utf8ToUtf16CharacterStream stream(keyword, length - 1); | 83       i::Utf8ToUtf16CharacterStream stream(keyword, length - 1); | 
| 85       i::Scanner scanner(&unicode_cache); | 84       i::Scanner scanner(&unicode_cache); | 
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1044       i::Handle<i::String> source = | 1043       i::Handle<i::String> source = | 
| 1045           factory->NewStringFromUtf8(i::CStrVector(program.start())) | 1044           factory->NewStringFromUtf8(i::CStrVector(program.start())) | 
| 1046               .ToHandleChecked(); | 1045               .ToHandleChecked(); | 
| 1047       i::Handle<i::Script> script = factory->NewScript(source); | 1046       i::Handle<i::Script> script = factory->NewScript(source); | 
| 1048       i::Zone zone; | 1047       i::Zone zone; | 
| 1049       i::ParseInfo info(&zone, script); | 1048       i::ParseInfo info(&zone, script); | 
| 1050       i::Parser parser(&info); | 1049       i::Parser parser(&info); | 
| 1051       parser.set_allow_harmony_arrow_functions(true); | 1050       parser.set_allow_harmony_arrow_functions(true); | 
| 1052       parser.set_allow_harmony_classes(true); | 1051       parser.set_allow_harmony_classes(true); | 
| 1053       parser.set_allow_harmony_object_literals(true); | 1052       parser.set_allow_harmony_object_literals(true); | 
| 1054       parser.set_allow_harmony_scoping(true); |  | 
| 1055       parser.set_allow_harmony_sloppy(true); | 1053       parser.set_allow_harmony_sloppy(true); | 
| 1056       info.set_global(); | 1054       info.set_global(); | 
| 1057       CHECK(parser.Parse(&info)); | 1055       CHECK(parser.Parse(&info)); | 
| 1058       CHECK(i::Rewriter::Rewrite(&info)); | 1056       CHECK(i::Rewriter::Rewrite(&info)); | 
| 1059       CHECK(i::Scope::Analyze(&info)); | 1057       CHECK(i::Scope::Analyze(&info)); | 
| 1060       CHECK(info.function() != NULL); | 1058       CHECK(info.function() != NULL); | 
| 1061 | 1059 | 
| 1062       i::Scope* script_scope = info.function()->scope(); | 1060       i::Scope* script_scope = info.function()->scope(); | 
| 1063       CHECK(script_scope->is_script_scope()); | 1061       CHECK(script_scope->is_script_scope()); | 
| 1064       CHECK_EQ(1, script_scope->inner_scopes()->length()); | 1062       CHECK_EQ(1, script_scope->inner_scopes()->length()); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 1079       CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0, | 1077       CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0, | 
| 1080                scope->inner_uses_super_property()); | 1078                scope->inner_uses_super_property()); | 
| 1081       CHECK_EQ((source_data[i].expected & INNER_THIS) != 0, | 1079       CHECK_EQ((source_data[i].expected & INNER_THIS) != 0, | 
| 1082                scope->inner_uses_this()); | 1080                scope->inner_uses_this()); | 
| 1083     } | 1081     } | 
| 1084   } | 1082   } | 
| 1085 } | 1083 } | 
| 1086 | 1084 | 
| 1087 | 1085 | 
| 1088 TEST(ScopePositions) { | 1086 TEST(ScopePositions) { | 
| 1089   v8::internal::FLAG_harmony_scoping = true; |  | 
| 1090 |  | 
| 1091   // Test the parser for correctly setting the start and end positions | 1087   // Test the parser for correctly setting the start and end positions | 
| 1092   // of a scope. We check the scope positions of exactly one scope | 1088   // of a scope. We check the scope positions of exactly one scope | 
| 1093   // nested in the global scope of a program. 'inner source' is the | 1089   // nested in the global scope of a program. 'inner source' is the | 
| 1094   // source code that determines the part of the source belonging | 1090   // source code that determines the part of the source belonging | 
| 1095   // to the nested scope. 'outer_prefix' and 'outer_suffix' are | 1091   // to the nested scope. 'outer_prefix' and 'outer_suffix' are | 
| 1096   // parts of the source that belong to the global scope. | 1092   // parts of the source that belong to the global scope. | 
| 1097   struct SourceData { | 1093   struct SourceData { | 
| 1098     const char* outer_prefix; | 1094     const char* outer_prefix; | 
| 1099     const char* inner_source; | 1095     const char* inner_source; | 
| 1100     const char* outer_suffix; | 1096     const char* outer_suffix; | 
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1294 | 1290 | 
| 1295     // Parse program source. | 1291     // Parse program source. | 
| 1296     i::Handle<i::String> source = factory->NewStringFromUtf8( | 1292     i::Handle<i::String> source = factory->NewStringFromUtf8( | 
| 1297         i::CStrVector(program.start())).ToHandleChecked(); | 1293         i::CStrVector(program.start())).ToHandleChecked(); | 
| 1298     CHECK_EQ(source->length(), kProgramSize); | 1294     CHECK_EQ(source->length(), kProgramSize); | 
| 1299     i::Handle<i::Script> script = factory->NewScript(source); | 1295     i::Handle<i::Script> script = factory->NewScript(source); | 
| 1300     i::Zone zone; | 1296     i::Zone zone; | 
| 1301     i::ParseInfo info(&zone, script); | 1297     i::ParseInfo info(&zone, script); | 
| 1302     i::Parser parser(&info); | 1298     i::Parser parser(&info); | 
| 1303     parser.set_allow_lazy(true); | 1299     parser.set_allow_lazy(true); | 
| 1304     parser.set_allow_harmony_scoping(true); |  | 
| 1305     parser.set_allow_harmony_arrow_functions(true); | 1300     parser.set_allow_harmony_arrow_functions(true); | 
| 1306     info.set_global(); | 1301     info.set_global(); | 
| 1307     info.set_language_mode(source_data[i].language_mode); | 1302     info.set_language_mode(source_data[i].language_mode); | 
| 1308     parser.Parse(&info); | 1303     parser.Parse(&info); | 
| 1309     CHECK(info.function() != NULL); | 1304     CHECK(info.function() != NULL); | 
| 1310 | 1305 | 
| 1311     // Check scope types and positions. | 1306     // Check scope types and positions. | 
| 1312     i::Scope* scope = info.function()->scope(); | 1307     i::Scope* scope = info.function()->scope(); | 
| 1313     CHECK(scope->is_script_scope()); | 1308     CHECK(scope->is_script_scope()); | 
| 1314     CHECK_EQ(scope->start_position(), 0); | 1309     CHECK_EQ(scope->start_position(), 0); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1370   i::DeleteArray(message); | 1365   i::DeleteArray(message); | 
| 1371   i::DeleteArray(arg); | 1366   i::DeleteArray(arg); | 
| 1372   data.Dispose(); | 1367   data.Dispose(); | 
| 1373   return i::Handle<i::String>::cast(result); | 1368   return i::Handle<i::String>::cast(result); | 
| 1374 } | 1369 } | 
| 1375 | 1370 | 
| 1376 | 1371 | 
| 1377 enum ParserFlag { | 1372 enum ParserFlag { | 
| 1378   kAllowLazy, | 1373   kAllowLazy, | 
| 1379   kAllowNatives, | 1374   kAllowNatives, | 
| 1380   kAllowHarmonyScoping, |  | 
| 1381   kAllowHarmonyModules, | 1375   kAllowHarmonyModules, | 
| 1382   kAllowHarmonyNumericLiterals, | 1376   kAllowHarmonyNumericLiterals, | 
| 1383   kAllowHarmonyArrowFunctions, | 1377   kAllowHarmonyArrowFunctions, | 
| 1384   kAllowHarmonyClasses, | 1378   kAllowHarmonyClasses, | 
| 1385   kAllowHarmonyObjectLiterals, | 1379   kAllowHarmonyObjectLiterals, | 
| 1386   kAllowHarmonyRestParameters, | 1380   kAllowHarmonyRestParameters, | 
| 1387   kAllowHarmonyTemplates, | 1381   kAllowHarmonyTemplates, | 
| 1388   kAllowHarmonySloppy, | 1382   kAllowHarmonySloppy, | 
| 1389   kAllowHarmonyUnicode, | 1383   kAllowHarmonyUnicode, | 
| 1390   kAllowHarmonyComputedPropertyNames, | 1384   kAllowHarmonyComputedPropertyNames, | 
| 1391   kAllowStrongMode | 1385   kAllowStrongMode | 
| 1392 }; | 1386 }; | 
| 1393 | 1387 | 
| 1394 | 1388 | 
| 1395 enum ParserSyncTestResult { | 1389 enum ParserSyncTestResult { | 
| 1396   kSuccessOrError, | 1390   kSuccessOrError, | 
| 1397   kSuccess, | 1391   kSuccess, | 
| 1398   kError | 1392   kError | 
| 1399 }; | 1393 }; | 
| 1400 | 1394 | 
| 1401 template <typename Traits> | 1395 template <typename Traits> | 
| 1402 void SetParserFlags(i::ParserBase<Traits>* parser, | 1396 void SetParserFlags(i::ParserBase<Traits>* parser, | 
| 1403                     i::EnumSet<ParserFlag> flags) { | 1397                     i::EnumSet<ParserFlag> flags) { | 
| 1404   parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 1398   parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 
| 1405   parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1399   parser->set_allow_natives(flags.Contains(kAllowNatives)); | 
| 1406   parser->set_allow_harmony_scoping(flags.Contains(kAllowHarmonyScoping)); |  | 
| 1407   parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules)); | 1400   parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules)); | 
| 1408   parser->set_allow_harmony_numeric_literals( | 1401   parser->set_allow_harmony_numeric_literals( | 
| 1409       flags.Contains(kAllowHarmonyNumericLiterals)); | 1402       flags.Contains(kAllowHarmonyNumericLiterals)); | 
| 1410   parser->set_allow_harmony_object_literals( | 1403   parser->set_allow_harmony_object_literals( | 
| 1411       flags.Contains(kAllowHarmonyObjectLiterals)); | 1404       flags.Contains(kAllowHarmonyObjectLiterals)); | 
| 1412   parser->set_allow_harmony_arrow_functions( | 1405   parser->set_allow_harmony_arrow_functions( | 
| 1413       flags.Contains(kAllowHarmonyArrowFunctions)); | 1406       flags.Contains(kAllowHarmonyArrowFunctions)); | 
| 1414   parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); | 1407   parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); | 
| 1415   parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates)); | 1408   parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates)); | 
| 1416   parser->set_allow_harmony_rest_params( | 1409   parser->set_allow_harmony_rest_params( | 
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1966 | 1959 | 
| 1967   const char* statement_data[] = { | 1960   const char* statement_data[] = { | 
| 1968     FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) | 1961     FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) | 
| 1969     NULL | 1962     NULL | 
| 1970   }; | 1963   }; | 
| 1971 | 1964 | 
| 1972   static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; | 1965   static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; | 
| 1973   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 1966   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 
| 1974                     always_flags, arraysize(always_flags)); | 1967                     always_flags, arraysize(always_flags)); | 
| 1975 | 1968 | 
| 1976   static const ParserFlag classes_flags[] = { | 1969   static const ParserFlag classes_flags[] = {kAllowHarmonyArrowFunctions, | 
| 1977       kAllowHarmonyArrowFunctions, kAllowHarmonyClasses, kAllowHarmonyScoping}; | 1970                                              kAllowHarmonyClasses}; | 
| 1978   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 1971   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 
| 1979                     classes_flags, arraysize(classes_flags)); | 1972                     classes_flags, arraysize(classes_flags)); | 
| 1980 } | 1973 } | 
| 1981 | 1974 | 
| 1982 | 1975 | 
| 1983 TEST(ErrorsReservedWords) { | 1976 TEST(ErrorsReservedWords) { | 
| 1984   // Tests that both preparsing and parsing produce the right kind of errors for | 1977   // Tests that both preparsing and parsing produce the right kind of errors for | 
| 1985   // using future reserved words as identifiers. These tests don't depend on the | 1978   // using future reserved words as identifiers. These tests don't depend on the | 
| 1986   // strict mode. | 1979   // strict mode. | 
| 1987   const char* context_data[][2] = { | 1980   const char* context_data[][2] = { | 
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3366                       midfix, inner_comment, inner, suffix); | 3359                       midfix, inner_comment, inner, suffix); | 
| 3367           i::Handle<i::String> source = | 3360           i::Handle<i::String> source = | 
| 3368               factory->InternalizeUtf8String(program.start()); | 3361               factory->InternalizeUtf8String(program.start()); | 
| 3369           source->PrintOn(stdout); | 3362           source->PrintOn(stdout); | 
| 3370           printf("\n"); | 3363           printf("\n"); | 
| 3371 | 3364 | 
| 3372           i::Handle<i::Script> script = factory->NewScript(source); | 3365           i::Handle<i::Script> script = factory->NewScript(source); | 
| 3373           i::Zone zone; | 3366           i::Zone zone; | 
| 3374           i::ParseInfo info(&zone, script); | 3367           i::ParseInfo info(&zone, script); | 
| 3375           i::Parser parser(&info); | 3368           i::Parser parser(&info); | 
| 3376           parser.set_allow_harmony_scoping(true); |  | 
| 3377           CHECK(parser.Parse(&info)); | 3369           CHECK(parser.Parse(&info)); | 
| 3378           CHECK(i::Compiler::Analyze(&info)); | 3370           CHECK(i::Compiler::Analyze(&info)); | 
| 3379           CHECK(info.function() != NULL); | 3371           CHECK(info.function() != NULL); | 
| 3380 | 3372 | 
| 3381           i::Scope* scope = info.function()->scope(); | 3373           i::Scope* scope = info.function()->scope(); | 
| 3382           CHECK_EQ(scope->inner_scopes()->length(), 1); | 3374           CHECK_EQ(scope->inner_scopes()->length(), 1); | 
| 3383           i::Scope* inner_scope = scope->inner_scopes()->at(0); | 3375           i::Scope* inner_scope = scope->inner_scopes()->at(0); | 
| 3384           const i::AstRawString* var_name = | 3376           const i::AstRawString* var_name = | 
| 3385               info.ast_value_factory()->GetOneByteString("x"); | 3377               info.ast_value_factory()->GetOneByteString("x"); | 
| 3386           i::Variable* var = inner_scope->Lookup(var_name); | 3378           i::Variable* var = inner_scope->Lookup(var_name); | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3514     "(a = b) => {}", | 3506     "(a = b) => {}", | 
| 3515     "(a = b, c) => {}", | 3507     "(a = b, c) => {}", | 
| 3516     "(a, b = c) => {}", | 3508     "(a, b = c) => {}", | 
| 3517     "(foo ? bar : baz) => {}", | 3509     "(foo ? bar : baz) => {}", | 
| 3518     "(a, foo ? bar : baz) => {}", | 3510     "(a, foo ? bar : baz) => {}", | 
| 3519     "(foo ? bar : baz, a) => {}", | 3511     "(foo ? bar : baz, a) => {}", | 
| 3520     NULL | 3512     NULL | 
| 3521   }; | 3513   }; | 
| 3522 | 3514 | 
| 3523   // The test is quite slow, so run it with a reduced set of flags. | 3515   // The test is quite slow, so run it with a reduced set of flags. | 
| 3524   static const ParserFlag flags[] = {kAllowLazy, kAllowHarmonyScoping}; | 3516   static const ParserFlag flags[] = {kAllowLazy}; | 
| 3525   static const ParserFlag always_flags[] = { kAllowHarmonyArrowFunctions }; | 3517   static const ParserFlag always_flags[] = { kAllowHarmonyArrowFunctions }; | 
| 3526   RunParserSyncTest(context_data, statement_data, kError, flags, | 3518   RunParserSyncTest(context_data, statement_data, kError, flags, | 
| 3527                     arraysize(flags), always_flags, arraysize(always_flags)); | 3519                     arraysize(flags), always_flags, arraysize(always_flags)); | 
| 3528 } | 3520 } | 
| 3529 | 3521 | 
| 3530 | 3522 | 
| 3531 TEST(NoErrorsArrowFunctions) { | 3523 TEST(NoErrorsArrowFunctions) { | 
| 3532   // Tests that parser and preparser accept valid arrow functions syntax. | 3524   // Tests that parser and preparser accept valid arrow functions syntax. | 
| 3533   const char* context_data[][2] = { | 3525   const char* context_data[][2] = { | 
| 3534     {"", ";"}, | 3526     {"", ";"}, | 
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4042                                    {"'use strict'; if (true) {", "}"}, | 4034                                    {"'use strict'; if (true) {", "}"}, | 
| 4043                                    {NULL, NULL}}; | 4035                                    {NULL, NULL}}; | 
| 4044   const char* statement_data[] = { | 4036   const char* statement_data[] = { | 
| 4045     "class name {}", | 4037     "class name {}", | 
| 4046     "class name extends F {}", | 4038     "class name extends F {}", | 
| 4047     "class name extends (F, G) {}", | 4039     "class name extends (F, G) {}", | 
| 4048     "class name extends class {} {}", | 4040     "class name extends class {} {}", | 
| 4049     "class name extends class base {} {}", | 4041     "class name extends class base {} {}", | 
| 4050     NULL}; | 4042     NULL}; | 
| 4051 | 4043 | 
| 4052   static const ParserFlag always_flags[] = { | 4044   static const ParserFlag always_flags[] = {kAllowHarmonyClasses}; | 
| 4053       kAllowHarmonyClasses, kAllowHarmonyScoping}; |  | 
| 4054   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 4045   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 
| 4055                     always_flags, arraysize(always_flags)); | 4046                     always_flags, arraysize(always_flags)); | 
| 4056 } | 4047 } | 
| 4057 | 4048 | 
| 4058 | 4049 | 
| 4059 TEST(ClassBodyNoErrors) { | 4050 TEST(ClassBodyNoErrors) { | 
| 4060   // Tests that parser and preparser accept valid class syntax. | 4051   // Tests that parser and preparser accept valid class syntax. | 
| 4061   const char* context_data[][2] = {{"(class {", "});"}, | 4052   const char* context_data[][2] = {{"(class {", "});"}, | 
| 4062                                    {"(class extends Base {", "});"}, | 4053                                    {"(class extends Base {", "});"}, | 
| 4063                                    {"class C {", "}"}, | 4054                                    {"class C {", "}"}, | 
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4562   const char* context_data[][2] = {{"'use strict';", ""}, | 4553   const char* context_data[][2] = {{"'use strict';", ""}, | 
| 4563                                    {"function foo(){ 'use strict';", "}"}, | 4554                                    {"function foo(){ 'use strict';", "}"}, | 
| 4564                                    {NULL, NULL}}; | 4555                                    {NULL, NULL}}; | 
| 4565 | 4556 | 
| 4566   const char* data[] = { | 4557   const char* data[] = { | 
| 4567       "for(const x = 1; ; ) {}", | 4558       "for(const x = 1; ; ) {}", | 
| 4568       "for(const x = 1, y = 2;;){}", | 4559       "for(const x = 1, y = 2;;){}", | 
| 4569       "for(const x in [1,2,3]) {}", | 4560       "for(const x in [1,2,3]) {}", | 
| 4570       "for(const x of [1,2,3]) {}", | 4561       "for(const x of [1,2,3]) {}", | 
| 4571       NULL}; | 4562       NULL}; | 
| 4572   static const ParserFlag always_flags[] = {kAllowHarmonyScoping}; | 4563   RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); | 
| 4573   RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |  | 
| 4574                     arraysize(always_flags)); |  | 
| 4575 } | 4564 } | 
| 4576 | 4565 | 
| 4577 | 4566 | 
| 4578 TEST(ConstParsingInForInError) { | 4567 TEST(ConstParsingInForInError) { | 
| 4579   const char* context_data[][2] = {{"'use strict';", ""}, | 4568   const char* context_data[][2] = {{"'use strict';", ""}, | 
| 4580                                    {"function foo(){ 'use strict';", "}"}, | 4569                                    {"function foo(){ 'use strict';", "}"}, | 
| 4581                                    {NULL, NULL}}; | 4570                                    {NULL, NULL}}; | 
| 4582 | 4571 | 
| 4583   const char* data[] = { | 4572   const char* data[] = { | 
| 4584       "for(const x,y = 1; ; ) {}", | 4573       "for(const x,y = 1; ; ) {}", | 
| 4585       "for(const x = 4 in [1,2,3]) {}", | 4574       "for(const x = 4 in [1,2,3]) {}", | 
| 4586       "for(const x = 4, y in [1,2,3]) {}", | 4575       "for(const x = 4, y in [1,2,3]) {}", | 
| 4587       "for(const x = 4 of [1,2,3]) {}", | 4576       "for(const x = 4 of [1,2,3]) {}", | 
| 4588       "for(const x = 4, y of [1,2,3]) {}", | 4577       "for(const x = 4, y of [1,2,3]) {}", | 
| 4589       "for(const x = 1, y = 2 in []) {}", | 4578       "for(const x = 1, y = 2 in []) {}", | 
| 4590       "for(const x,y in []) {}", | 4579       "for(const x,y in []) {}", | 
| 4591       "for(const x = 1, y = 2 of []) {}", | 4580       "for(const x = 1, y = 2 of []) {}", | 
| 4592       "for(const x,y of []) {}", | 4581       "for(const x,y of []) {}", | 
| 4593       NULL}; | 4582       NULL}; | 
| 4594   static const ParserFlag always_flags[] = {kAllowHarmonyScoping}; | 4583   RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0); | 
| 4595   RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |  | 
| 4596                     arraysize(always_flags)); |  | 
| 4597 } | 4584 } | 
| 4598 | 4585 | 
| 4599 | 4586 | 
| 4600 TEST(InvalidUnicodeEscapes) { | 4587 TEST(InvalidUnicodeEscapes) { | 
| 4601   const char* context_data[][2] = {{"", ""}, | 4588   const char* context_data[][2] = {{"", ""}, | 
| 4602                                    {"'use strict';", ""}, | 4589                                    {"'use strict';", ""}, | 
| 4603                                    {NULL, NULL}}; | 4590                                    {NULL, NULL}}; | 
| 4604   const char* data[] = { | 4591   const char* data[] = { | 
| 4605     "var foob\\u123r = 0;", | 4592     "var foob\\u123r = 0;", | 
| 4606     "var \\u123roo = 0;", | 4593     "var \\u123roo = 0;", | 
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4941     "for(let x = 1;;){}", | 4928     "for(let x = 1;;){}", | 
| 4942     "for(let x of []){}", | 4929     "for(let x of []){}", | 
| 4943     "for(let x in []){}", | 4930     "for(let x in []){}", | 
| 4944     "class C {}", | 4931     "class C {}", | 
| 4945     "class C extends D {}", | 4932     "class C extends D {}", | 
| 4946     "(class {})", | 4933     "(class {})", | 
| 4947     "(class extends D {})", | 4934     "(class extends D {})", | 
| 4948     "(class C {})", | 4935     "(class C {})", | 
| 4949     "(class C extends D {})", | 4936     "(class C extends D {})", | 
| 4950     NULL}; | 4937     NULL}; | 
| 4951   static const ParserFlag always_true_flags[] = { | 4938   static const ParserFlag always_true_flags[] = {kAllowHarmonyClasses}; | 
| 4952       kAllowHarmonyScoping, kAllowHarmonyClasses}; |  | 
| 4953   static const ParserFlag always_false_flags[] = {kAllowHarmonySloppy}; | 4939   static const ParserFlag always_false_flags[] = {kAllowHarmonySloppy}; | 
| 4954   RunParserSyncTest(context_data, bad_data, kError, NULL, 0, | 4940   RunParserSyncTest(context_data, bad_data, kError, NULL, 0, | 
| 4955                     always_true_flags, arraysize(always_true_flags), | 4941                     always_true_flags, arraysize(always_true_flags), | 
| 4956                     always_false_flags, arraysize(always_false_flags)); | 4942                     always_false_flags, arraysize(always_false_flags)); | 
| 4957 | 4943 | 
| 4958   const char* good_data[] = { | 4944   const char* good_data[] = { | 
| 4959     "let = 1;", | 4945     "let = 1;", | 
| 4960     "for(let = 1;;){}", | 4946     "for(let = 1;;){}", | 
| 4961     NULL}; | 4947     NULL}; | 
| 4962   RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, | 4948   RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5078         factory->NewStringFromAsciiChecked(kSources[i]); | 5064         factory->NewStringFromAsciiChecked(kSources[i]); | 
| 5079 | 5065 | 
| 5080     // Show that parsing as a module works | 5066     // Show that parsing as a module works | 
| 5081     { | 5067     { | 
| 5082       i::Handle<i::Script> script = factory->NewScript(source); | 5068       i::Handle<i::Script> script = factory->NewScript(source); | 
| 5083       i::Zone zone; | 5069       i::Zone zone; | 
| 5084       i::ParseInfo info(&zone, script); | 5070       i::ParseInfo info(&zone, script); | 
| 5085       i::Parser parser(&info); | 5071       i::Parser parser(&info); | 
| 5086       parser.set_allow_harmony_classes(true); | 5072       parser.set_allow_harmony_classes(true); | 
| 5087       parser.set_allow_harmony_modules(true); | 5073       parser.set_allow_harmony_modules(true); | 
| 5088       parser.set_allow_harmony_scoping(true); |  | 
| 5089       info.set_module(); | 5074       info.set_module(); | 
| 5090       if (!parser.Parse(&info)) { | 5075       if (!parser.Parse(&info)) { | 
| 5091         i::Handle<i::JSObject> exception_handle( | 5076         i::Handle<i::JSObject> exception_handle( | 
| 5092             i::JSObject::cast(isolate->pending_exception())); | 5077             i::JSObject::cast(isolate->pending_exception())); | 
| 5093         i::Handle<i::String> message_string = | 5078         i::Handle<i::String> message_string = | 
| 5094             i::Handle<i::String>::cast(i::Object::GetProperty( | 5079             i::Handle<i::String>::cast(i::Object::GetProperty( | 
| 5095                   isolate, exception_handle, "message").ToHandleChecked()); | 5080                   isolate, exception_handle, "message").ToHandleChecked()); | 
| 5096 | 5081 | 
| 5097         v8::base::OS::Print( | 5082         v8::base::OS::Print( | 
| 5098             "Parser failed on:\n" | 5083             "Parser failed on:\n" | 
| 5099             "\t%s\n" | 5084             "\t%s\n" | 
| 5100             "with error:\n" | 5085             "with error:\n" | 
| 5101             "\t%s\n" | 5086             "\t%s\n" | 
| 5102             "However, we expected no error.", | 5087             "However, we expected no error.", | 
| 5103             source->ToCString().get(), message_string->ToCString().get()); | 5088             source->ToCString().get(), message_string->ToCString().get()); | 
| 5104         CHECK(false); | 5089         CHECK(false); | 
| 5105       } | 5090       } | 
| 5106     } | 5091     } | 
| 5107 | 5092 | 
| 5108     // And that parsing a script does not. | 5093     // And that parsing a script does not. | 
| 5109     { | 5094     { | 
| 5110       i::Handle<i::Script> script = factory->NewScript(source); | 5095       i::Handle<i::Script> script = factory->NewScript(source); | 
| 5111       i::Zone zone; | 5096       i::Zone zone; | 
| 5112       i::ParseInfo info(&zone, script); | 5097       i::ParseInfo info(&zone, script); | 
| 5113       i::Parser parser(&info); | 5098       i::Parser parser(&info); | 
| 5114       parser.set_allow_harmony_classes(true); | 5099       parser.set_allow_harmony_classes(true); | 
| 5115       parser.set_allow_harmony_modules(true); | 5100       parser.set_allow_harmony_modules(true); | 
| 5116       parser.set_allow_harmony_scoping(true); |  | 
| 5117       info.set_global(); | 5101       info.set_global(); | 
| 5118       CHECK(!parser.Parse(&info)); | 5102       CHECK(!parser.Parse(&info)); | 
| 5119     } | 5103     } | 
| 5120   } | 5104   } | 
| 5121 } | 5105 } | 
| 5122 | 5106 | 
| 5123 | 5107 | 
| 5124 TEST(ImportExportParsingErrors) { | 5108 TEST(ImportExportParsingErrors) { | 
| 5125   const char* kErrorSources[] = { | 5109   const char* kErrorSources[] = { | 
| 5126       "export {", | 5110       "export {", | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5197   for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { | 5181   for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { | 
| 5198     i::Handle<i::String> source = | 5182     i::Handle<i::String> source = | 
| 5199         factory->NewStringFromAsciiChecked(kErrorSources[i]); | 5183         factory->NewStringFromAsciiChecked(kErrorSources[i]); | 
| 5200 | 5184 | 
| 5201     i::Handle<i::Script> script = factory->NewScript(source); | 5185     i::Handle<i::Script> script = factory->NewScript(source); | 
| 5202     i::Zone zone; | 5186     i::Zone zone; | 
| 5203     i::ParseInfo info(&zone, script); | 5187     i::ParseInfo info(&zone, script); | 
| 5204     i::Parser parser(&info); | 5188     i::Parser parser(&info); | 
| 5205     parser.set_allow_harmony_classes(true); | 5189     parser.set_allow_harmony_classes(true); | 
| 5206     parser.set_allow_harmony_modules(true); | 5190     parser.set_allow_harmony_modules(true); | 
| 5207     parser.set_allow_harmony_scoping(true); |  | 
| 5208     info.set_module(); | 5191     info.set_module(); | 
| 5209     CHECK(!parser.Parse(&info)); | 5192     CHECK(!parser.Parse(&info)); | 
| 5210   } | 5193   } | 
| 5211 } | 5194 } | 
| 5212 | 5195 | 
| 5213 | 5196 | 
| 5214 TEST(ModuleParsingInternals) { | 5197 TEST(ModuleParsingInternals) { | 
| 5215   i::FLAG_harmony_modules = true; | 5198   i::FLAG_harmony_modules = true; | 
| 5216 | 5199 | 
| 5217   i::Isolate* isolate = CcTest::i_isolate(); | 5200   i::Isolate* isolate = CcTest::i_isolate(); | 
| 5218   i::Factory* factory = isolate->factory(); | 5201   i::Factory* factory = isolate->factory(); | 
| 5219   v8::HandleScope handles(CcTest::isolate()); | 5202   v8::HandleScope handles(CcTest::isolate()); | 
| 5220   v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 5203   v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 
| 5221   v8::Context::Scope context_scope(context); | 5204   v8::Context::Scope context_scope(context); | 
| 5222   isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 5205   isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 
| 5223                                         128 * 1024); | 5206                                         128 * 1024); | 
| 5224 | 5207 | 
| 5225   static const char kSource[] = | 5208   static const char kSource[] = | 
| 5226       "let x = 5;" | 5209       "let x = 5;" | 
| 5227       "export { x as y };" | 5210       "export { x as y };" | 
| 5228       "import { q as z } from 'm.js';" | 5211       "import { q as z } from 'm.js';" | 
| 5229       "import n from 'n.js'"; | 5212       "import n from 'n.js'"; | 
| 5230   i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 5213   i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 
| 5231   i::Handle<i::Script> script = factory->NewScript(source); | 5214   i::Handle<i::Script> script = factory->NewScript(source); | 
| 5232   i::Zone zone; | 5215   i::Zone zone; | 
| 5233   i::ParseInfo info(&zone, script); | 5216   i::ParseInfo info(&zone, script); | 
| 5234   i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 5217   i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 
| 5235   i::Parser parser(&info); | 5218   i::Parser parser(&info); | 
| 5236   parser.set_allow_harmony_modules(true); | 5219   parser.set_allow_harmony_modules(true); | 
| 5237   parser.set_allow_harmony_scoping(true); |  | 
| 5238   info.set_module(); | 5220   info.set_module(); | 
| 5239   CHECK(parser.Parse(&info)); | 5221   CHECK(parser.Parse(&info)); | 
| 5240   CHECK(i::Compiler::Analyze(&info)); | 5222   CHECK(i::Compiler::Analyze(&info)); | 
| 5241 | 5223 | 
| 5242   i::FunctionLiteral* func = info.function(); | 5224   i::FunctionLiteral* func = info.function(); | 
| 5243   i::Scope* module_scope = func->scope(); | 5225   i::Scope* module_scope = func->scope(); | 
| 5244   i::Scope* outer_scope = module_scope->outer_scope(); | 5226   i::Scope* outer_scope = module_scope->outer_scope(); | 
| 5245   CHECK(outer_scope->is_script_scope()); | 5227   CHECK(outer_scope->is_script_scope()); | 
| 5246   CHECK_NULL(outer_scope->outer_scope()); | 5228   CHECK_NULL(outer_scope->outer_scope()); | 
| 5247   CHECK_EQ(1, outer_scope->num_modules()); | 5229   CHECK_EQ(1, outer_scope->num_modules()); | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5328                                    {"'use strong'; for (x in y)", ""}, | 5310                                    {"'use strong'; for (x in y)", ""}, | 
| 5329                                    {"'use strong'; do ", " while (false)"}, | 5311                                    {"'use strong'; do ", " while (false)"}, | 
| 5330                                    {NULL, NULL}}; | 5312                                    {NULL, NULL}}; | 
| 5331 | 5313 | 
| 5332   const char* statement_data[] = { | 5314   const char* statement_data[] = { | 
| 5333     "let x = 1;", | 5315     "let x = 1;", | 
| 5334     "const x = 1;", | 5316     "const x = 1;", | 
| 5335     "class C {}", | 5317     "class C {}", | 
| 5336     NULL}; | 5318     NULL}; | 
| 5337 | 5319 | 
| 5338   static const ParserFlag always_flags[] = { | 5320   static const ParserFlag always_flags[] = {kAllowHarmonyClasses, | 
| 5339       kAllowHarmonyClasses, kAllowHarmonyScoping, kAllowStrongMode}; | 5321                                             kAllowStrongMode}; | 
| 5340   RunParserSyncTest(context_data, statement_data, kError, NULL, 0, | 5322   RunParserSyncTest(context_data, statement_data, kError, NULL, 0, | 
| 5341                     always_flags, arraysize(always_flags)); | 5323                     always_flags, arraysize(always_flags)); | 
| 5342 } | 5324 } | 
| 5343 | 5325 | 
| 5344 | 5326 | 
| 5345 void TestLanguageMode(const char* source, | 5327 void TestLanguageMode(const char* source, | 
| 5346                       i::LanguageMode expected_language_mode) { | 5328                       i::LanguageMode expected_language_mode) { | 
| 5347   i::Isolate* isolate = CcTest::i_isolate(); | 5329   i::Isolate* isolate = CcTest::i_isolate(); | 
| 5348   i::Factory* factory = isolate->factory(); | 5330   i::Factory* factory = isolate->factory(); | 
| 5349   v8::HandleScope handles(CcTest::isolate()); | 5331   v8::HandleScope handles(CcTest::isolate()); | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5414       "class C {static *eval() {}}", | 5396       "class C {static *eval() {}}", | 
| 5415       "class C {static *arguments() {}}", | 5397       "class C {static *arguments() {}}", | 
| 5416       "class C {static get eval() {}}", | 5398       "class C {static get eval() {}}", | 
| 5417       "class C {static get arguments() {}}", | 5399       "class C {static get arguments() {}}", | 
| 5418       "class C {static set eval(_) {}}", | 5400       "class C {static set eval(_) {}}", | 
| 5419       "class C {static set arguments(_) {}}", | 5401       "class C {static set arguments(_) {}}", | 
| 5420 | 5402 | 
| 5421       NULL}; | 5403       NULL}; | 
| 5422 | 5404 | 
| 5423   static const ParserFlag always_flags[] = { | 5405   static const ParserFlag always_flags[] = { | 
| 5424       kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, kAllowHarmonyScoping, | 5406       kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, kAllowStrongMode}; | 
| 5425       kAllowStrongMode}; |  | 
| 5426   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 5407   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 
| 5427                     always_flags, arraysize(always_flags)); | 5408                     always_flags, arraysize(always_flags)); | 
| 5428 } | 5409 } | 
| 5429 | 5410 | 
| 5430 | 5411 | 
| 5431 TEST(FunctionLiteralDuplicateParameters) { | 5412 TEST(FunctionLiteralDuplicateParameters) { | 
| 5432   const char* strict_context_data[][2] = | 5413   const char* strict_context_data[][2] = | 
| 5433       {{"'use strict';(function(", "){})();"}, | 5414       {{"'use strict';(function(", "){})();"}, | 
| 5434        {"(function(", ") { 'use strict'; })();"}, | 5415        {"(function(", ") { 'use strict'; })();"}, | 
| 5435        {"'use strict'; function fn(", ") {}; fn();"}, | 5416        {"'use strict'; function fn(", ") {}; fn();"}, | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5487 | 5468 | 
| 5488   const char* let_declarations[] = { | 5469   const char* let_declarations[] = { | 
| 5489     "let x = 0;", | 5470     "let x = 0;", | 
| 5490     "for (let i = 0; i < 10; i++) { }", | 5471     "for (let i = 0; i < 10; i++) { }", | 
| 5491     NULL}; | 5472     NULL}; | 
| 5492 | 5473 | 
| 5493   const char* const_declarations[] = { | 5474   const char* const_declarations[] = { | 
| 5494     "const x = 0;", | 5475     "const x = 0;", | 
| 5495     NULL}; | 5476     NULL}; | 
| 5496 | 5477 | 
| 5497   static const ParserFlag always_flags[] = {kAllowStrongMode, | 5478   static const ParserFlag always_flags[] = {kAllowStrongMode}; | 
| 5498                                             kAllowHarmonyScoping}; |  | 
| 5499   RunParserSyncTest(strong_context_data, var_declarations, kError, NULL, 0, | 5479   RunParserSyncTest(strong_context_data, var_declarations, kError, NULL, 0, | 
| 5500                     always_flags, arraysize(always_flags)); | 5480                     always_flags, arraysize(always_flags)); | 
| 5501   RunParserSyncTest(strong_context_data, let_declarations, kSuccess, NULL, 0, | 5481   RunParserSyncTest(strong_context_data, let_declarations, kSuccess, NULL, 0, | 
| 5502                     always_flags, arraysize(always_flags)); | 5482                     always_flags, arraysize(always_flags)); | 
| 5503   RunParserSyncTest(strong_context_data, const_declarations, kSuccess, NULL, 0, | 5483   RunParserSyncTest(strong_context_data, const_declarations, kSuccess, NULL, 0, | 
| 5504                     always_flags, arraysize(always_flags)); | 5484                     always_flags, arraysize(always_flags)); | 
| 5505 | 5485 | 
| 5506   RunParserSyncTest(strict_context_data, var_declarations, kSuccess, NULL, 0, | 5486   RunParserSyncTest(strict_context_data, var_declarations, kSuccess, NULL, 0, | 
| 5507                     always_flags, arraysize(always_flags)); | 5487                     always_flags, arraysize(always_flags)); | 
| 5508   RunParserSyncTest(strict_context_data, let_declarations, kSuccess, NULL, 0, | 5488   RunParserSyncTest(strict_context_data, let_declarations, kSuccess, NULL, 0, | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 5528       "do; while (1);", | 5508       "do; while (1);", | 
| 5529       "for (;;);", | 5509       "for (;;);", | 
| 5530       "for (x in []);", | 5510       "for (x in []);", | 
| 5531       "for (x of []);", | 5511       "for (x of []);", | 
| 5532       "for (const x = 0;;);", | 5512       "for (const x = 0;;);", | 
| 5533       "for (const x in []);", | 5513       "for (const x in []);", | 
| 5534       "for (const x of []);", | 5514       "for (const x of []);", | 
| 5535       NULL}; | 5515       NULL}; | 
| 5536 | 5516 | 
| 5537   static const ParserFlag always_flags[] = { | 5517   static const ParserFlag always_flags[] = { | 
| 5538       kAllowStrongMode, kAllowHarmonyScoping | 5518       kAllowStrongMode, | 
| 5539   }; | 5519   }; | 
| 5540   RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 5520   RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 
| 5541                     arraysize(always_flags)); | 5521                     arraysize(always_flags)); | 
| 5542   RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 5522   RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 
| 5543                     arraysize(always_flags)); | 5523                     arraysize(always_flags)); | 
| 5544   RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 5524   RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 
| 5545                     arraysize(always_flags)); | 5525                     arraysize(always_flags)); | 
| 5546 } | 5526 } | 
| 5547 | 5527 | 
| 5548 | 5528 | 
| 5549 TEST(StrongForIn) { | 5529 TEST(StrongForIn) { | 
| 5550   const char* sloppy_context_data[][2] = {{"", ""}, {NULL}}; | 5530   const char* sloppy_context_data[][2] = {{"", ""}, {NULL}}; | 
| 5551   const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; | 5531   const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; | 
| 5552   const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; | 5532   const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; | 
| 5553 | 5533 | 
| 5554   const char* data[] = { | 5534   const char* data[] = { | 
| 5555       "for (x in []) {}", | 5535       "for (x in []) {}", | 
| 5556       "for (const x in []) {}", | 5536       "for (const x in []) {}", | 
| 5557       NULL}; | 5537       NULL}; | 
| 5558 | 5538 | 
| 5559   static const ParserFlag always_flags[] = { | 5539   static const ParserFlag always_flags[] = { | 
| 5560       kAllowStrongMode, kAllowHarmonyScoping | 5540       kAllowStrongMode, | 
| 5561   }; | 5541   }; | 
| 5562   RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 5542   RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 
| 5563                     arraysize(always_flags)); | 5543                     arraysize(always_flags)); | 
| 5564   RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 5544   RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 
| 5565                     arraysize(always_flags)); | 5545                     arraysize(always_flags)); | 
| 5566   RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 5546   RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 
| 5567                     arraysize(always_flags)); | 5547                     arraysize(always_flags)); | 
| 5568 } | 5548 } | 
| 5569 | 5549 | 
| 5570 | 5550 | 
| 5571 TEST(ArrowFunctionASIErrors) { | 5551 TEST(ArrowFunctionASIErrors) { | 
| 5572   const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, | 5552   const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, | 
| 5573                                    {NULL, NULL}}; | 5553                                    {NULL, NULL}}; | 
| 5574 | 5554 | 
| 5575   const char* data[] = { | 5555   const char* data[] = { | 
| 5576       "(a\n=> a)(1)", | 5556       "(a\n=> a)(1)", | 
| 5577       "(a/*\n*/=> a)(1)", | 5557       "(a/*\n*/=> a)(1)", | 
| 5578       "((a)\n=> a)(1)", | 5558       "((a)\n=> a)(1)", | 
| 5579       "((a)/*\n*/=> a)(1)", | 5559       "((a)/*\n*/=> a)(1)", | 
| 5580       "((a, b)\n=> a + b)(1, 2)", | 5560       "((a, b)\n=> a + b)(1, 2)", | 
| 5581       "((a, b)/*\n*/=> a + b)(1, 2)", | 5561       "((a, b)/*\n*/=> a + b)(1, 2)", | 
| 5582       NULL}; | 5562       NULL}; | 
| 5583   static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; | 5563   static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; | 
| 5584   RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 5564   RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 
| 5585                     arraysize(always_flags)); | 5565                     arraysize(always_flags)); | 
| 5586 } | 5566 } | 
| OLD | NEW | 
|---|