| 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 source_data[i].body, surroundings[j].suffix); | 1061 source_data[i].body, surroundings[j].suffix); |
| 1062 i::Handle<i::String> source = | 1062 i::Handle<i::String> source = |
| 1063 factory->NewStringFromUtf8(i::CStrVector(program.start())) | 1063 factory->NewStringFromUtf8(i::CStrVector(program.start())) |
| 1064 .ToHandleChecked(); | 1064 .ToHandleChecked(); |
| 1065 i::Handle<i::Script> script = factory->NewScript(source); | 1065 i::Handle<i::Script> script = factory->NewScript(source); |
| 1066 i::Zone zone; | 1066 i::Zone zone; |
| 1067 i::ParseInfo info(&zone, script); | 1067 i::ParseInfo info(&zone, script); |
| 1068 i::Parser parser(&info); | 1068 i::Parser parser(&info); |
| 1069 parser.set_allow_harmony_arrow_functions(true); | 1069 parser.set_allow_harmony_arrow_functions(true); |
| 1070 parser.set_allow_harmony_classes(true); | 1070 parser.set_allow_harmony_classes(true); |
| 1071 parser.set_allow_harmony_object_literals(true); | |
| 1072 parser.set_allow_harmony_sloppy(true); | 1071 parser.set_allow_harmony_sloppy(true); |
| 1073 info.set_global(); | 1072 info.set_global(); |
| 1074 CHECK(parser.Parse(&info)); | 1073 CHECK(parser.Parse(&info)); |
| 1075 CHECK(i::Rewriter::Rewrite(&info)); | 1074 CHECK(i::Rewriter::Rewrite(&info)); |
| 1076 CHECK(i::Scope::Analyze(&info)); | 1075 CHECK(i::Scope::Analyze(&info)); |
| 1077 CHECK(info.function() != NULL); | 1076 CHECK(info.function() != NULL); |
| 1078 | 1077 |
| 1079 i::Scope* script_scope = info.function()->scope(); | 1078 i::Scope* script_scope = info.function()->scope(); |
| 1080 CHECK(script_scope->is_script_scope()); | 1079 CHECK(script_scope->is_script_scope()); |
| 1081 CHECK_EQ(1, script_scope->inner_scopes()->length()); | 1080 CHECK_EQ(1, script_scope->inner_scopes()->length()); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); | 1372 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); |
| 1374 } | 1373 } |
| 1375 | 1374 |
| 1376 | 1375 |
| 1377 enum ParserFlag { | 1376 enum ParserFlag { |
| 1378 kAllowLazy, | 1377 kAllowLazy, |
| 1379 kAllowNatives, | 1378 kAllowNatives, |
| 1380 kAllowHarmonyModules, | 1379 kAllowHarmonyModules, |
| 1381 kAllowHarmonyArrowFunctions, | 1380 kAllowHarmonyArrowFunctions, |
| 1382 kAllowHarmonyClasses, | 1381 kAllowHarmonyClasses, |
| 1383 kAllowHarmonyObjectLiterals, | |
| 1384 kAllowHarmonyRestParameters, | 1382 kAllowHarmonyRestParameters, |
| 1385 kAllowHarmonySloppy, | 1383 kAllowHarmonySloppy, |
| 1386 kAllowHarmonyUnicode, | 1384 kAllowHarmonyUnicode, |
| 1387 kAllowHarmonyComputedPropertyNames, | 1385 kAllowHarmonyComputedPropertyNames, |
| 1388 kAllowHarmonySpreadCalls, | 1386 kAllowHarmonySpreadCalls, |
| 1389 kAllowHarmonyDestructuring, | 1387 kAllowHarmonyDestructuring, |
| 1390 kAllowHarmonySpreadArrays, | 1388 kAllowHarmonySpreadArrays, |
| 1391 kAllowHarmonyNewTarget, | 1389 kAllowHarmonyNewTarget, |
| 1392 kAllowStrongMode | 1390 kAllowStrongMode |
| 1393 }; | 1391 }; |
| 1394 | 1392 |
| 1395 | 1393 |
| 1396 enum ParserSyncTestResult { | 1394 enum ParserSyncTestResult { |
| 1397 kSuccessOrError, | 1395 kSuccessOrError, |
| 1398 kSuccess, | 1396 kSuccess, |
| 1399 kError | 1397 kError |
| 1400 }; | 1398 }; |
| 1401 | 1399 |
| 1402 template <typename Traits> | 1400 template <typename Traits> |
| 1403 void SetParserFlags(i::ParserBase<Traits>* parser, | 1401 void SetParserFlags(i::ParserBase<Traits>* parser, |
| 1404 i::EnumSet<ParserFlag> flags) { | 1402 i::EnumSet<ParserFlag> flags) { |
| 1405 parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 1403 parser->set_allow_lazy(flags.Contains(kAllowLazy)); |
| 1406 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1404 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
| 1407 parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules)); | 1405 parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules)); |
| 1408 parser->set_allow_harmony_object_literals( | |
| 1409 flags.Contains(kAllowHarmonyObjectLiterals)); | |
| 1410 parser->set_allow_harmony_arrow_functions( | 1406 parser->set_allow_harmony_arrow_functions( |
| 1411 flags.Contains(kAllowHarmonyArrowFunctions)); | 1407 flags.Contains(kAllowHarmonyArrowFunctions)); |
| 1412 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); | 1408 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); |
| 1413 parser->set_allow_harmony_rest_params( | 1409 parser->set_allow_harmony_rest_params( |
| 1414 flags.Contains(kAllowHarmonyRestParameters)); | 1410 flags.Contains(kAllowHarmonyRestParameters)); |
| 1415 parser->set_allow_harmony_spreadcalls( | 1411 parser->set_allow_harmony_spreadcalls( |
| 1416 flags.Contains(kAllowHarmonySpreadCalls)); | 1412 flags.Contains(kAllowHarmonySpreadCalls)); |
| 1417 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); | 1413 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); |
| 1418 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); | 1414 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); |
| 1419 parser->set_allow_harmony_computed_property_names( | 1415 parser->set_allow_harmony_computed_property_names( |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3719 "new super.x()", | 3715 "new super.x()", |
| 3720 "new super[27]", | 3716 "new super[27]", |
| 3721 "new super[27]()", | 3717 "new super[27]()", |
| 3722 "z.super", // Ok, property lookup. | 3718 "z.super", // Ok, property lookup. |
| 3723 NULL | 3719 NULL |
| 3724 }; | 3720 }; |
| 3725 | 3721 |
| 3726 static const ParserFlag always_flags[] = { | 3722 static const ParserFlag always_flags[] = { |
| 3727 kAllowHarmonyArrowFunctions, | 3723 kAllowHarmonyArrowFunctions, |
| 3728 kAllowHarmonyClasses, | 3724 kAllowHarmonyClasses, |
| 3729 kAllowHarmonyObjectLiterals, | |
| 3730 kAllowHarmonySloppy | 3725 kAllowHarmonySloppy |
| 3731 }; | 3726 }; |
| 3732 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3727 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
| 3733 always_flags, arraysize(always_flags)); | 3728 always_flags, arraysize(always_flags)); |
| 3734 } | 3729 } |
| 3735 | 3730 |
| 3736 | 3731 |
| 3737 TEST(SuperErrors) { | 3732 TEST(SuperErrors) { |
| 3738 const char* context_data[][2] = { | 3733 const char* context_data[][2] = { |
| 3739 {"class C { m() { ", "; } }"}, | 3734 {"class C { m() { ", "; } }"}, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3752 "new super()", | 3747 "new super()", |
| 3753 "new super(12, 45)", | 3748 "new super(12, 45)", |
| 3754 "new new super", | 3749 "new new super", |
| 3755 "new new super()", | 3750 "new new super()", |
| 3756 "new new super()()", | 3751 "new new super()()", |
| 3757 NULL | 3752 NULL |
| 3758 }; | 3753 }; |
| 3759 | 3754 |
| 3760 static const ParserFlag always_flags[] = { | 3755 static const ParserFlag always_flags[] = { |
| 3761 kAllowHarmonyClasses, | 3756 kAllowHarmonyClasses, |
| 3762 kAllowHarmonyObjectLiterals, | |
| 3763 kAllowHarmonySloppy | 3757 kAllowHarmonySloppy |
| 3764 }; | 3758 }; |
| 3765 RunParserSyncTest(context_data, expression_data, kError, NULL, 0, | 3759 RunParserSyncTest(context_data, expression_data, kError, NULL, 0, |
| 3766 always_flags, arraysize(always_flags)); | 3760 always_flags, arraysize(always_flags)); |
| 3767 } | 3761 } |
| 3768 | 3762 |
| 3769 | 3763 |
| 3770 TEST(SuperCall) { | 3764 TEST(SuperCall) { |
| 3771 const char* context_data[][2] = {{"", ""}, | 3765 const char* context_data[][2] = {{"", ""}, |
| 3772 {NULL, NULL}}; | 3766 {NULL, NULL}}; |
| 3773 | 3767 |
| 3774 const char* success_data[] = { | 3768 const char* success_data[] = { |
| 3775 "class C extends B { constructor() { super(); } }", | 3769 "class C extends B { constructor() { super(); } }", |
| 3776 "class C extends B { constructor() { () => super(); } }", | 3770 "class C extends B { constructor() { () => super(); } }", |
| 3777 NULL | 3771 NULL |
| 3778 }; | 3772 }; |
| 3779 | 3773 |
| 3780 static const ParserFlag always_flags[] = { | 3774 static const ParserFlag always_flags[] = { |
| 3781 kAllowHarmonyArrowFunctions, | 3775 kAllowHarmonyArrowFunctions, |
| 3782 kAllowHarmonyClasses, | 3776 kAllowHarmonyClasses, |
| 3783 kAllowHarmonyObjectLiterals, | |
| 3784 kAllowHarmonySloppy | 3777 kAllowHarmonySloppy |
| 3785 }; | 3778 }; |
| 3786 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, | 3779 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, |
| 3787 always_flags, arraysize(always_flags)); | 3780 always_flags, arraysize(always_flags)); |
| 3788 | 3781 |
| 3789 const char* error_data[] = { | 3782 const char* error_data[] = { |
| 3790 "class C { constructor() { super(); } }", | 3783 "class C { constructor() { super(); } }", |
| 3791 "class C { method() { super(); } }", | 3784 "class C { method() { super(); } }", |
| 3792 "class C { method() { () => super(); } }", | 3785 "class C { method() { () => super(); } }", |
| 3793 "class C { *method() { super(); } }", | 3786 "class C { *method() { super(); } }", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3828 "new super.x;", | 3821 "new super.x;", |
| 3829 "new super.x();", | 3822 "new super.x();", |
| 3830 "() => new super.x;", | 3823 "() => new super.x;", |
| 3831 "() => new super.x();", | 3824 "() => new super.x();", |
| 3832 NULL | 3825 NULL |
| 3833 }; | 3826 }; |
| 3834 | 3827 |
| 3835 static const ParserFlag always_flags[] = { | 3828 static const ParserFlag always_flags[] = { |
| 3836 kAllowHarmonyArrowFunctions, | 3829 kAllowHarmonyArrowFunctions, |
| 3837 kAllowHarmonyClasses, | 3830 kAllowHarmonyClasses, |
| 3838 kAllowHarmonyObjectLiterals, | |
| 3839 kAllowHarmonySloppy | 3831 kAllowHarmonySloppy |
| 3840 }; | 3832 }; |
| 3841 RunParserSyncTest(context_data, expression_data, kSuccess, NULL, 0, | 3833 RunParserSyncTest(context_data, expression_data, kSuccess, NULL, 0, |
| 3842 always_flags, arraysize(always_flags)); | 3834 always_flags, arraysize(always_flags)); |
| 3843 } | 3835 } |
| 3844 | 3836 |
| 3845 | 3837 |
| 3846 TEST(SuperNewErrors) { | 3838 TEST(SuperNewErrors) { |
| 3847 const char* context_data[][2] = { | 3839 const char* context_data[][2] = { |
| 3848 {"class C { method() { ", " } }"}, | 3840 {"class C { method() { ", " } }"}, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3866 "new super;", | 3858 "new super;", |
| 3867 "new super();", | 3859 "new super();", |
| 3868 "() => new super;", | 3860 "() => new super;", |
| 3869 "() => new super();", | 3861 "() => new super();", |
| 3870 NULL | 3862 NULL |
| 3871 }; | 3863 }; |
| 3872 | 3864 |
| 3873 static const ParserFlag always_flags[] = { | 3865 static const ParserFlag always_flags[] = { |
| 3874 kAllowHarmonyArrowFunctions, | 3866 kAllowHarmonyArrowFunctions, |
| 3875 kAllowHarmonyClasses, | 3867 kAllowHarmonyClasses, |
| 3876 kAllowHarmonyObjectLiterals, | |
| 3877 kAllowHarmonySloppy | 3868 kAllowHarmonySloppy |
| 3878 }; | 3869 }; |
| 3879 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, | 3870 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
| 3880 always_flags, arraysize(always_flags)); | 3871 always_flags, arraysize(always_flags)); |
| 3881 } | 3872 } |
| 3882 | 3873 |
| 3883 | 3874 |
| 3884 TEST(SuperErrorsNonMethods) { | 3875 TEST(SuperErrorsNonMethods) { |
| 3885 // super is only allowed in methods, accessors and constructors. | 3876 // super is only allowed in methods, accessors and constructors. |
| 3886 const char* context_data[][2] = { | 3877 const char* context_data[][2] = { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3910 "super()", | 3901 "super()", |
| 3911 "new super.x", | 3902 "new super.x", |
| 3912 "new super.x()", | 3903 "new super.x()", |
| 3913 "new super[27]", | 3904 "new super[27]", |
| 3914 "new super[27]()", | 3905 "new super[27]()", |
| 3915 NULL | 3906 NULL |
| 3916 }; | 3907 }; |
| 3917 | 3908 |
| 3918 static const ParserFlag always_flags[] = { | 3909 static const ParserFlag always_flags[] = { |
| 3919 kAllowHarmonyClasses, | 3910 kAllowHarmonyClasses, |
| 3920 kAllowHarmonyObjectLiterals, | |
| 3921 kAllowHarmonySloppy | 3911 kAllowHarmonySloppy |
| 3922 }; | 3912 }; |
| 3923 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, | 3913 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
| 3924 always_flags, arraysize(always_flags)); | 3914 always_flags, arraysize(always_flags)); |
| 3925 } | 3915 } |
| 3926 | 3916 |
| 3927 | 3917 |
| 3928 TEST(NoErrorsMethodDefinition) { | 3918 TEST(NoErrorsMethodDefinition) { |
| 3929 const char* context_data[][2] = {{"({", "});"}, | 3919 const char* context_data[][2] = {{"({", "});"}, |
| 3930 {"'use strict'; ({", "});"}, | 3920 {"'use strict'; ({", "});"}, |
| 3931 {"({*", "});"}, | 3921 {"({*", "});"}, |
| 3932 {"'use strict'; ({*", "});"}, | 3922 {"'use strict'; ({*", "});"}, |
| 3933 {NULL, NULL}}; | 3923 {NULL, NULL}}; |
| 3934 | 3924 |
| 3935 const char* object_literal_body_data[] = { | 3925 const char* object_literal_body_data[] = { |
| 3936 "m() {}", | 3926 "m() {}", |
| 3937 "m(x) { return x; }", | 3927 "m(x) { return x; }", |
| 3938 "m(x, y) {}, n() {}", | 3928 "m(x, y) {}, n() {}", |
| 3939 "set(x, y) {}", | 3929 "set(x, y) {}", |
| 3940 "get(x, y) {}", | 3930 "get(x, y) {}", |
| 3941 NULL | 3931 NULL |
| 3942 }; | 3932 }; |
| 3943 | 3933 |
| 3944 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 3934 RunParserSyncTest(context_data, object_literal_body_data, kSuccess); |
| 3945 RunParserSyncTest(context_data, object_literal_body_data, kSuccess, NULL, 0, | |
| 3946 always_flags, arraysize(always_flags)); | |
| 3947 } | 3935 } |
| 3948 | 3936 |
| 3949 | 3937 |
| 3950 TEST(MethodDefinitionNames) { | 3938 TEST(MethodDefinitionNames) { |
| 3951 const char* context_data[][2] = {{"({", "(x, y) {}});"}, | 3939 const char* context_data[][2] = {{"({", "(x, y) {}});"}, |
| 3952 {"'use strict'; ({", "(x, y) {}});"}, | 3940 {"'use strict'; ({", "(x, y) {}});"}, |
| 3953 {"({*", "(x, y) {}});"}, | 3941 {"({*", "(x, y) {}});"}, |
| 3954 {"'use strict'; ({*", "(x, y) {}});"}, | 3942 {"'use strict'; ({*", "(x, y) {}});"}, |
| 3955 {NULL, NULL}}; | 3943 {NULL, NULL}}; |
| 3956 | 3944 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4010 "try", | 3998 "try", |
| 4011 "typeof", | 3999 "typeof", |
| 4012 "var", | 4000 "var", |
| 4013 "void", | 4001 "void", |
| 4014 "while", | 4002 "while", |
| 4015 "with", | 4003 "with", |
| 4016 "yield", | 4004 "yield", |
| 4017 NULL | 4005 NULL |
| 4018 }; | 4006 }; |
| 4019 | 4007 |
| 4020 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4008 RunParserSyncTest(context_data, name_data, kSuccess); |
| 4021 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, | |
| 4022 always_flags, arraysize(always_flags)); | |
| 4023 } | 4009 } |
| 4024 | 4010 |
| 4025 | 4011 |
| 4026 TEST(MethodDefinitionStrictFormalParamereters) { | 4012 TEST(MethodDefinitionStrictFormalParamereters) { |
| 4027 const char* context_data[][2] = {{"({method(", "){}});"}, | 4013 const char* context_data[][2] = {{"({method(", "){}});"}, |
| 4028 {"'use strict'; ({method(", "){}});"}, | 4014 {"'use strict'; ({method(", "){}});"}, |
| 4029 {"({*method(", "){}});"}, | 4015 {"({*method(", "){}});"}, |
| 4030 {"'use strict'; ({*method(", "){}});"}, | 4016 {"'use strict'; ({*method(", "){}});"}, |
| 4031 {NULL, NULL}}; | 4017 {NULL, NULL}}; |
| 4032 | 4018 |
| 4033 const char* params_data[] = { | 4019 const char* params_data[] = { |
| 4034 "x, x", | 4020 "x, x", |
| 4035 "x, y, x", | 4021 "x, y, x", |
| 4036 "var", | 4022 "var", |
| 4037 "const", | 4023 "const", |
| 4038 NULL | 4024 NULL |
| 4039 }; | 4025 }; |
| 4040 | 4026 |
| 4041 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4027 RunParserSyncTest(context_data, params_data, kError); |
| 4042 RunParserSyncTest(context_data, params_data, kError, NULL, 0, | |
| 4043 always_flags, arraysize(always_flags)); | |
| 4044 } | 4028 } |
| 4045 | 4029 |
| 4046 | 4030 |
| 4047 TEST(MethodDefinitionEvalArguments) { | 4031 TEST(MethodDefinitionEvalArguments) { |
| 4048 const char* strict_context_data[][2] = | 4032 const char* strict_context_data[][2] = |
| 4049 {{"'use strict'; ({method(", "){}});"}, | 4033 {{"'use strict'; ({method(", "){}});"}, |
| 4050 {"'use strict'; ({*method(", "){}});"}, | 4034 {"'use strict'; ({*method(", "){}});"}, |
| 4051 {NULL, NULL}}; | 4035 {NULL, NULL}}; |
| 4052 const char* sloppy_context_data[][2] = | 4036 const char* sloppy_context_data[][2] = |
| 4053 {{"({method(", "){}});"}, | 4037 {{"({method(", "){}});"}, |
| 4054 {"({*method(", "){}});"}, | 4038 {"({*method(", "){}});"}, |
| 4055 {NULL, NULL}}; | 4039 {NULL, NULL}}; |
| 4056 | 4040 |
| 4057 const char* data[] = { | 4041 const char* data[] = { |
| 4058 "eval", | 4042 "eval", |
| 4059 "arguments", | 4043 "arguments", |
| 4060 NULL}; | 4044 NULL}; |
| 4061 | 4045 |
| 4062 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | |
| 4063 | |
| 4064 // Fail in strict mode | 4046 // Fail in strict mode |
| 4065 RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags, | 4047 RunParserSyncTest(strict_context_data, data, kError); |
| 4066 arraysize(always_flags)); | |
| 4067 | 4048 |
| 4068 // OK in sloppy mode | 4049 // OK in sloppy mode |
| 4069 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 4050 RunParserSyncTest(sloppy_context_data, data, kSuccess); |
| 4070 arraysize(always_flags)); | |
| 4071 } | 4051 } |
| 4072 | 4052 |
| 4073 | 4053 |
| 4074 TEST(MethodDefinitionDuplicateEvalArguments) { | 4054 TEST(MethodDefinitionDuplicateEvalArguments) { |
| 4075 const char* context_data[][2] = | 4055 const char* context_data[][2] = |
| 4076 {{"'use strict'; ({method(", "){}});"}, | 4056 {{"'use strict'; ({method(", "){}});"}, |
| 4077 {"'use strict'; ({*method(", "){}});"}, | 4057 {"'use strict'; ({*method(", "){}});"}, |
| 4078 {"({method(", "){}});"}, | 4058 {"({method(", "){}});"}, |
| 4079 {"({*method(", "){}});"}, | 4059 {"({*method(", "){}});"}, |
| 4080 {NULL, NULL}}; | 4060 {NULL, NULL}}; |
| 4081 | 4061 |
| 4082 const char* data[] = { | 4062 const char* data[] = { |
| 4083 "eval, eval", | 4063 "eval, eval", |
| 4084 "eval, a, eval", | 4064 "eval, a, eval", |
| 4085 "arguments, arguments", | 4065 "arguments, arguments", |
| 4086 "arguments, a, arguments", | 4066 "arguments, a, arguments", |
| 4087 NULL}; | 4067 NULL}; |
| 4088 | 4068 |
| 4089 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | |
| 4090 | |
| 4091 // In strict mode, the error is using "eval" or "arguments" as parameter names | 4069 // In strict mode, the error is using "eval" or "arguments" as parameter names |
| 4092 // In sloppy mode, the error is that eval / arguments are duplicated | 4070 // In sloppy mode, the error is that eval / arguments are duplicated |
| 4093 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 4071 RunParserSyncTest(context_data, data, kError); |
| 4094 arraysize(always_flags)); | |
| 4095 } | 4072 } |
| 4096 | 4073 |
| 4097 | 4074 |
| 4098 TEST(MethodDefinitionDuplicateProperty) { | 4075 TEST(MethodDefinitionDuplicateProperty) { |
| 4099 const char* context_data[][2] = {{"'use strict'; ({", "});"}, | 4076 const char* context_data[][2] = {{"'use strict'; ({", "});"}, |
| 4100 {NULL, NULL}}; | 4077 {NULL, NULL}}; |
| 4101 | 4078 |
| 4102 const char* params_data[] = { | 4079 const char* params_data[] = { |
| 4103 "x: 1, x() {}", | 4080 "x: 1, x() {}", |
| 4104 "x() {}, x: 1", | 4081 "x() {}, x: 1", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4118 "*x() {}, *x() {}", | 4095 "*x() {}, *x() {}", |
| 4119 "*x() {}, y() {}, *x() {}", | 4096 "*x() {}, y() {}, *x() {}", |
| 4120 "*x() {}, *\"x\"() {}", | 4097 "*x() {}, *\"x\"() {}", |
| 4121 "*x() {}, *'x'() {}", | 4098 "*x() {}, *'x'() {}", |
| 4122 "*0() {}, *'0'() {}", | 4099 "*0() {}, *'0'() {}", |
| 4123 "*1.0() {}, 1: 1", | 4100 "*1.0() {}, 1: 1", |
| 4124 | 4101 |
| 4125 NULL | 4102 NULL |
| 4126 }; | 4103 }; |
| 4127 | 4104 |
| 4128 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4105 RunParserSyncTest(context_data, params_data, kSuccess); |
| 4129 RunParserSyncTest(context_data, params_data, kSuccess, NULL, 0, | |
| 4130 always_flags, arraysize(always_flags)); | |
| 4131 } | 4106 } |
| 4132 | 4107 |
| 4133 | 4108 |
| 4134 TEST(ClassExpressionNoErrors) { | 4109 TEST(ClassExpressionNoErrors) { |
| 4135 const char* context_data[][2] = {{"(", ");"}, | 4110 const char* context_data[][2] = {{"(", ");"}, |
| 4136 {"var C = ", ";"}, | 4111 {"var C = ", ";"}, |
| 4137 {"bar, ", ";"}, | 4112 {"bar, ", ";"}, |
| 4138 {NULL, NULL}}; | 4113 {NULL, NULL}}; |
| 4139 const char* class_data[] = { | 4114 const char* class_data[] = { |
| 4140 "class {}", | 4115 "class {}", |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 "static get static() {}", | 4182 "static get static() {}", |
| 4208 "static set static(v) {}", | 4183 "static set static(v) {}", |
| 4209 "*static() {}", | 4184 "*static() {}", |
| 4210 "*get() {}", | 4185 "*get() {}", |
| 4211 "*set() {}", | 4186 "*set() {}", |
| 4212 "static *g() {}", | 4187 "static *g() {}", |
| 4213 NULL}; | 4188 NULL}; |
| 4214 | 4189 |
| 4215 static const ParserFlag always_flags[] = { | 4190 static const ParserFlag always_flags[] = { |
| 4216 kAllowHarmonyClasses, | 4191 kAllowHarmonyClasses, |
| 4217 kAllowHarmonyObjectLiterals, | |
| 4218 kAllowHarmonySloppy | 4192 kAllowHarmonySloppy |
| 4219 }; | 4193 }; |
| 4220 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, | 4194 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, |
| 4221 always_flags, arraysize(always_flags)); | 4195 always_flags, arraysize(always_flags)); |
| 4222 } | 4196 } |
| 4223 | 4197 |
| 4224 | 4198 |
| 4225 TEST(ClassPropertyNameNoErrors) { | 4199 TEST(ClassPropertyNameNoErrors) { |
| 4226 const char* context_data[][2] = {{"(class {", "() {}});"}, | 4200 const char* context_data[][2] = {{"(class {", "() {}});"}, |
| 4227 {"(class { get ", "() {}});"}, | 4201 {"(class { get ", "() {}});"}, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4266 "for", | 4240 "for", |
| 4267 "while", | 4241 "while", |
| 4268 "do", | 4242 "do", |
| 4269 "try", | 4243 "try", |
| 4270 "catch", | 4244 "catch", |
| 4271 "finally", | 4245 "finally", |
| 4272 NULL}; | 4246 NULL}; |
| 4273 | 4247 |
| 4274 static const ParserFlag always_flags[] = { | 4248 static const ParserFlag always_flags[] = { |
| 4275 kAllowHarmonyClasses, | 4249 kAllowHarmonyClasses, |
| 4276 kAllowHarmonyObjectLiterals, | |
| 4277 kAllowHarmonySloppy | 4250 kAllowHarmonySloppy |
| 4278 }; | 4251 }; |
| 4279 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, | 4252 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, |
| 4280 always_flags, arraysize(always_flags)); | 4253 always_flags, arraysize(always_flags)); |
| 4281 } | 4254 } |
| 4282 | 4255 |
| 4283 | 4256 |
| 4284 TEST(ClassExpressionErrors) { | 4257 TEST(ClassExpressionErrors) { |
| 4285 const char* context_data[][2] = {{"(", ");"}, | 4258 const char* context_data[][2] = {{"(", ");"}, |
| 4286 {"var C = ", ";"}, | 4259 {"var C = ", ";"}, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4298 "class { m(); n() }", | 4271 "class { m(); n() }", |
| 4299 "class { get m }", | 4272 "class { get m }", |
| 4300 "class { get m() }", | 4273 "class { get m() }", |
| 4301 "class { get m() { }", | 4274 "class { get m() { }", |
| 4302 "class { set m() {} }", // Missing required parameter. | 4275 "class { set m() {} }", // Missing required parameter. |
| 4303 "class { m() {}, n() {} }", // No commas allowed. | 4276 "class { m() {}, n() {} }", // No commas allowed. |
| 4304 NULL}; | 4277 NULL}; |
| 4305 | 4278 |
| 4306 static const ParserFlag always_flags[] = { | 4279 static const ParserFlag always_flags[] = { |
| 4307 kAllowHarmonyClasses, | 4280 kAllowHarmonyClasses, |
| 4308 kAllowHarmonyObjectLiterals, | |
| 4309 kAllowHarmonySloppy | 4281 kAllowHarmonySloppy |
| 4310 }; | 4282 }; |
| 4311 RunParserSyncTest(context_data, class_data, kError, NULL, 0, | 4283 RunParserSyncTest(context_data, class_data, kError, NULL, 0, |
| 4312 always_flags, arraysize(always_flags)); | 4284 always_flags, arraysize(always_flags)); |
| 4313 } | 4285 } |
| 4314 | 4286 |
| 4315 | 4287 |
| 4316 TEST(ClassDeclarationErrors) { | 4288 TEST(ClassDeclarationErrors) { |
| 4317 const char* context_data[][2] = {{"", ""}, | 4289 const char* context_data[][2] = {{"", ""}, |
| 4318 {"{", "}"}, | 4290 {"{", "}"}, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4366 "private", | 4338 "private", |
| 4367 "protected", | 4339 "protected", |
| 4368 "public", | 4340 "public", |
| 4369 "static", | 4341 "static", |
| 4370 "var", | 4342 "var", |
| 4371 "yield", | 4343 "yield", |
| 4372 NULL}; | 4344 NULL}; |
| 4373 | 4345 |
| 4374 static const ParserFlag always_flags[] = { | 4346 static const ParserFlag always_flags[] = { |
| 4375 kAllowHarmonyClasses, | 4347 kAllowHarmonyClasses, |
| 4376 kAllowHarmonyObjectLiterals, | |
| 4377 kAllowHarmonySloppy | 4348 kAllowHarmonySloppy |
| 4378 }; | 4349 }; |
| 4379 RunParserSyncTest(context_data, class_name, kError, NULL, 0, | 4350 RunParserSyncTest(context_data, class_name, kError, NULL, 0, |
| 4380 always_flags, arraysize(always_flags)); | 4351 always_flags, arraysize(always_flags)); |
| 4381 } | 4352 } |
| 4382 | 4353 |
| 4383 | 4354 |
| 4384 TEST(ClassGetterParamNameErrors) { | 4355 TEST(ClassGetterParamNameErrors) { |
| 4385 const char* context_data[][2] = { | 4356 const char* context_data[][2] = { |
| 4386 {"class C { get name(", ") {} }"}, | 4357 {"class C { get name(", ") {} }"}, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4400 "private", | 4371 "private", |
| 4401 "protected", | 4372 "protected", |
| 4402 "public", | 4373 "public", |
| 4403 "static", | 4374 "static", |
| 4404 "var", | 4375 "var", |
| 4405 "yield", | 4376 "yield", |
| 4406 NULL}; | 4377 NULL}; |
| 4407 | 4378 |
| 4408 static const ParserFlag always_flags[] = { | 4379 static const ParserFlag always_flags[] = { |
| 4409 kAllowHarmonyClasses, | 4380 kAllowHarmonyClasses, |
| 4410 kAllowHarmonyObjectLiterals, | |
| 4411 kAllowHarmonySloppy | 4381 kAllowHarmonySloppy |
| 4412 }; | 4382 }; |
| 4413 RunParserSyncTest(context_data, class_name, kError, NULL, 0, | 4383 RunParserSyncTest(context_data, class_name, kError, NULL, 0, |
| 4414 always_flags, arraysize(always_flags)); | 4384 always_flags, arraysize(always_flags)); |
| 4415 } | 4385 } |
| 4416 | 4386 |
| 4417 | 4387 |
| 4418 TEST(ClassStaticPrototypeErrors) { | 4388 TEST(ClassStaticPrototypeErrors) { |
| 4419 const char* context_data[][2] = {{"class C {", "}"}, | 4389 const char* context_data[][2] = {{"class C {", "}"}, |
| 4420 {"(class {", "});"}, | 4390 {"(class {", "});"}, |
| 4421 {NULL, NULL}}; | 4391 {NULL, NULL}}; |
| 4422 | 4392 |
| 4423 const char* class_body_data[] = { | 4393 const char* class_body_data[] = { |
| 4424 "static prototype() {}", | 4394 "static prototype() {}", |
| 4425 "static get prototype() {}", | 4395 "static get prototype() {}", |
| 4426 "static set prototype(_) {}", | 4396 "static set prototype(_) {}", |
| 4427 "static *prototype() {}", | 4397 "static *prototype() {}", |
| 4428 "static 'prototype'() {}", | 4398 "static 'prototype'() {}", |
| 4429 "static *'prototype'() {}", | 4399 "static *'prototype'() {}", |
| 4430 "static prot\\u006ftype() {}", | 4400 "static prot\\u006ftype() {}", |
| 4431 "static 'prot\\u006ftype'() {}", | 4401 "static 'prot\\u006ftype'() {}", |
| 4432 "static get 'prot\\u006ftype'() {}", | 4402 "static get 'prot\\u006ftype'() {}", |
| 4433 "static set 'prot\\u006ftype'(_) {}", | 4403 "static set 'prot\\u006ftype'(_) {}", |
| 4434 "static *'prot\\u006ftype'() {}", | 4404 "static *'prot\\u006ftype'() {}", |
| 4435 NULL}; | 4405 NULL}; |
| 4436 | 4406 |
| 4437 static const ParserFlag always_flags[] = { | 4407 static const ParserFlag always_flags[] = { |
| 4438 kAllowHarmonyClasses, | 4408 kAllowHarmonyClasses, |
| 4439 kAllowHarmonyObjectLiterals, | |
| 4440 kAllowHarmonySloppy | 4409 kAllowHarmonySloppy |
| 4441 }; | 4410 }; |
| 4442 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, | 4411 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, |
| 4443 always_flags, arraysize(always_flags)); | 4412 always_flags, arraysize(always_flags)); |
| 4444 } | 4413 } |
| 4445 | 4414 |
| 4446 | 4415 |
| 4447 TEST(ClassSpecialConstructorErrors) { | 4416 TEST(ClassSpecialConstructorErrors) { |
| 4448 const char* context_data[][2] = {{"class C {", "}"}, | 4417 const char* context_data[][2] = {{"class C {", "}"}, |
| 4449 {"(class {", "});"}, | 4418 {"(class {", "});"}, |
| 4450 {NULL, NULL}}; | 4419 {NULL, NULL}}; |
| 4451 | 4420 |
| 4452 const char* class_body_data[] = { | 4421 const char* class_body_data[] = { |
| 4453 "get constructor() {}", | 4422 "get constructor() {}", |
| 4454 "get constructor(_) {}", | 4423 "get constructor(_) {}", |
| 4455 "*constructor() {}", | 4424 "*constructor() {}", |
| 4456 "get 'constructor'() {}", | 4425 "get 'constructor'() {}", |
| 4457 "*'constructor'() {}", | 4426 "*'constructor'() {}", |
| 4458 "get c\\u006fnstructor() {}", | 4427 "get c\\u006fnstructor() {}", |
| 4459 "*c\\u006fnstructor() {}", | 4428 "*c\\u006fnstructor() {}", |
| 4460 "get 'c\\u006fnstructor'() {}", | 4429 "get 'c\\u006fnstructor'() {}", |
| 4461 "get 'c\\u006fnstructor'(_) {}", | 4430 "get 'c\\u006fnstructor'(_) {}", |
| 4462 "*'c\\u006fnstructor'() {}", | 4431 "*'c\\u006fnstructor'() {}", |
| 4463 NULL}; | 4432 NULL}; |
| 4464 | 4433 |
| 4465 static const ParserFlag always_flags[] = { | 4434 static const ParserFlag always_flags[] = { |
| 4466 kAllowHarmonyClasses, | 4435 kAllowHarmonyClasses, |
| 4467 kAllowHarmonyObjectLiterals, | |
| 4468 kAllowHarmonySloppy | 4436 kAllowHarmonySloppy |
| 4469 }; | 4437 }; |
| 4470 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, | 4438 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, |
| 4471 always_flags, arraysize(always_flags)); | 4439 always_flags, arraysize(always_flags)); |
| 4472 } | 4440 } |
| 4473 | 4441 |
| 4474 | 4442 |
| 4475 TEST(ClassConstructorNoErrors) { | 4443 TEST(ClassConstructorNoErrors) { |
| 4476 const char* context_data[][2] = {{"class C {", "}"}, | 4444 const char* context_data[][2] = {{"class C {", "}"}, |
| 4477 {"(class {", "});"}, | 4445 {"(class {", "});"}, |
| 4478 {NULL, NULL}}; | 4446 {NULL, NULL}}; |
| 4479 | 4447 |
| 4480 const char* class_body_data[] = { | 4448 const char* class_body_data[] = { |
| 4481 "constructor() {}", | 4449 "constructor() {}", |
| 4482 "static constructor() {}", | 4450 "static constructor() {}", |
| 4483 "static get constructor() {}", | 4451 "static get constructor() {}", |
| 4484 "static set constructor(_) {}", | 4452 "static set constructor(_) {}", |
| 4485 "static *constructor() {}", | 4453 "static *constructor() {}", |
| 4486 NULL}; | 4454 NULL}; |
| 4487 | 4455 |
| 4488 static const ParserFlag always_flags[] = { | 4456 static const ParserFlag always_flags[] = { |
| 4489 kAllowHarmonyClasses, | 4457 kAllowHarmonyClasses, |
| 4490 kAllowHarmonyObjectLiterals, | |
| 4491 kAllowHarmonySloppy | 4458 kAllowHarmonySloppy |
| 4492 }; | 4459 }; |
| 4493 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, | 4460 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, |
| 4494 always_flags, arraysize(always_flags)); | 4461 always_flags, arraysize(always_flags)); |
| 4495 } | 4462 } |
| 4496 | 4463 |
| 4497 | 4464 |
| 4498 TEST(ClassMultipleConstructorErrors) { | 4465 TEST(ClassMultipleConstructorErrors) { |
| 4499 const char* context_data[][2] = {{"class C {", "}"}, | 4466 const char* context_data[][2] = {{"class C {", "}"}, |
| 4500 {"(class {", "});"}, | 4467 {"(class {", "});"}, |
| 4501 {NULL, NULL}}; | 4468 {NULL, NULL}}; |
| 4502 | 4469 |
| 4503 const char* class_body_data[] = { | 4470 const char* class_body_data[] = { |
| 4504 "constructor() {}; constructor() {}", | 4471 "constructor() {}; constructor() {}", |
| 4505 NULL}; | 4472 NULL}; |
| 4506 | 4473 |
| 4507 static const ParserFlag always_flags[] = { | 4474 static const ParserFlag always_flags[] = { |
| 4508 kAllowHarmonyClasses, | 4475 kAllowHarmonyClasses, |
| 4509 kAllowHarmonyObjectLiterals, | |
| 4510 kAllowHarmonySloppy | 4476 kAllowHarmonySloppy |
| 4511 }; | 4477 }; |
| 4512 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, | 4478 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, |
| 4513 always_flags, arraysize(always_flags)); | 4479 always_flags, arraysize(always_flags)); |
| 4514 } | 4480 } |
| 4515 | 4481 |
| 4516 | 4482 |
| 4517 TEST(ClassMultiplePropertyNamesNoErrors) { | 4483 TEST(ClassMultiplePropertyNamesNoErrors) { |
| 4518 const char* context_data[][2] = {{"class C {", "}"}, | 4484 const char* context_data[][2] = {{"class C {", "}"}, |
| 4519 {"(class {", "});"}, | 4485 {"(class {", "});"}, |
| 4520 {NULL, NULL}}; | 4486 {NULL, NULL}}; |
| 4521 | 4487 |
| 4522 const char* class_body_data[] = { | 4488 const char* class_body_data[] = { |
| 4523 "constructor() {}; static constructor() {}", | 4489 "constructor() {}; static constructor() {}", |
| 4524 "m() {}; static m() {}", | 4490 "m() {}; static m() {}", |
| 4525 "m() {}; m() {}", | 4491 "m() {}; m() {}", |
| 4526 "static m() {}; static m() {}", | 4492 "static m() {}; static m() {}", |
| 4527 "get m() {}; set m(_) {}; get m() {}; set m(_) {};", | 4493 "get m() {}; set m(_) {}; get m() {}; set m(_) {};", |
| 4528 NULL}; | 4494 NULL}; |
| 4529 | 4495 |
| 4530 static const ParserFlag always_flags[] = { | 4496 static const ParserFlag always_flags[] = { |
| 4531 kAllowHarmonyClasses, | 4497 kAllowHarmonyClasses, |
| 4532 kAllowHarmonyObjectLiterals, | |
| 4533 kAllowHarmonySloppy | 4498 kAllowHarmonySloppy |
| 4534 }; | 4499 }; |
| 4535 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, | 4500 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, |
| 4536 always_flags, arraysize(always_flags)); | 4501 always_flags, arraysize(always_flags)); |
| 4537 } | 4502 } |
| 4538 | 4503 |
| 4539 | 4504 |
| 4540 TEST(ClassesAreStrictErrors) { | 4505 TEST(ClassesAreStrictErrors) { |
| 4541 const char* context_data[][2] = {{"", ""}, | 4506 const char* context_data[][2] = {{"", ""}, |
| 4542 {"(", ");"}, | 4507 {"(", ");"}, |
| 4543 {NULL, NULL}}; | 4508 {NULL, NULL}}; |
| 4544 | 4509 |
| 4545 const char* class_body_data[] = { | 4510 const char* class_body_data[] = { |
| 4546 "class C { method() { with ({}) {} } }", | 4511 "class C { method() { with ({}) {} } }", |
| 4547 "class C extends function() { with ({}) {} } {}", | 4512 "class C extends function() { with ({}) {} } {}", |
| 4548 "class C { *method() { with ({}) {} } }", | 4513 "class C { *method() { with ({}) {} } }", |
| 4549 NULL}; | 4514 NULL}; |
| 4550 | 4515 |
| 4551 static const ParserFlag always_flags[] = { | 4516 static const ParserFlag always_flags[] = { |
| 4552 kAllowHarmonyClasses, | 4517 kAllowHarmonyClasses, |
| 4553 kAllowHarmonyObjectLiterals, | |
| 4554 kAllowHarmonySloppy | 4518 kAllowHarmonySloppy |
| 4555 }; | 4519 }; |
| 4556 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, | 4520 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, |
| 4557 always_flags, arraysize(always_flags)); | 4521 always_flags, arraysize(always_flags)); |
| 4558 } | 4522 } |
| 4559 | 4523 |
| 4560 | 4524 |
| 4561 TEST(ObjectLiteralPropertyShorthandKeywordsError) { | 4525 TEST(ObjectLiteralPropertyShorthandKeywordsError) { |
| 4562 const char* context_data[][2] = {{"({", "});"}, | 4526 const char* context_data[][2] = {{"({", "});"}, |
| 4563 {"'use strict'; ({", "});"}, | 4527 {"'use strict'; ({", "});"}, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4596 "true", | 4560 "true", |
| 4597 "try", | 4561 "try", |
| 4598 "typeof", | 4562 "typeof", |
| 4599 "var", | 4563 "var", |
| 4600 "void", | 4564 "void", |
| 4601 "while", | 4565 "while", |
| 4602 "with", | 4566 "with", |
| 4603 NULL | 4567 NULL |
| 4604 }; | 4568 }; |
| 4605 | 4569 |
| 4606 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4570 RunParserSyncTest(context_data, name_data, kError); |
| 4607 RunParserSyncTest(context_data, name_data, kError, NULL, 0, | |
| 4608 always_flags, arraysize(always_flags)); | |
| 4609 } | 4571 } |
| 4610 | 4572 |
| 4611 | 4573 |
| 4612 TEST(ObjectLiteralPropertyShorthandStrictKeywords) { | 4574 TEST(ObjectLiteralPropertyShorthandStrictKeywords) { |
| 4613 const char* context_data[][2] = {{"({", "});"}, | 4575 const char* context_data[][2] = {{"({", "});"}, |
| 4614 {NULL, NULL}}; | 4576 {NULL, NULL}}; |
| 4615 | 4577 |
| 4616 const char* name_data[] = { | 4578 const char* name_data[] = { |
| 4617 "implements", | 4579 "implements", |
| 4618 "interface", | 4580 "interface", |
| 4619 "let", | 4581 "let", |
| 4620 "package", | 4582 "package", |
| 4621 "private", | 4583 "private", |
| 4622 "protected", | 4584 "protected", |
| 4623 "public", | 4585 "public", |
| 4624 "static", | 4586 "static", |
| 4625 "yield", | 4587 "yield", |
| 4626 NULL | 4588 NULL |
| 4627 }; | 4589 }; |
| 4628 | 4590 |
| 4629 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4591 RunParserSyncTest(context_data, name_data, kSuccess); |
| 4630 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, | |
| 4631 always_flags, arraysize(always_flags)); | |
| 4632 | 4592 |
| 4633 const char* context_strict_data[][2] = {{"'use strict'; ({", "});"}, | 4593 const char* context_strict_data[][2] = {{"'use strict'; ({", "});"}, |
| 4634 {NULL, NULL}}; | 4594 {NULL, NULL}}; |
| 4635 RunParserSyncTest(context_strict_data, name_data, kError, NULL, 0, | 4595 RunParserSyncTest(context_strict_data, name_data, kError); |
| 4636 always_flags, arraysize(always_flags)); | |
| 4637 } | 4596 } |
| 4638 | 4597 |
| 4639 | 4598 |
| 4640 TEST(ObjectLiteralPropertyShorthandError) { | 4599 TEST(ObjectLiteralPropertyShorthandError) { |
| 4641 const char* context_data[][2] = {{"({", "});"}, | 4600 const char* context_data[][2] = {{"({", "});"}, |
| 4642 {"'use strict'; ({", "});"}, | 4601 {"'use strict'; ({", "});"}, |
| 4643 {NULL, NULL}}; | 4602 {NULL, NULL}}; |
| 4644 | 4603 |
| 4645 const char* name_data[] = { | 4604 const char* name_data[] = { |
| 4646 "1", | 4605 "1", |
| 4647 "1.2", | 4606 "1.2", |
| 4648 "0", | 4607 "0", |
| 4649 "0.1", | 4608 "0.1", |
| 4650 "1.0", | 4609 "1.0", |
| 4651 "1e1", | 4610 "1e1", |
| 4652 "0x1", | 4611 "0x1", |
| 4653 "\"s\"", | 4612 "\"s\"", |
| 4654 "'s'", | 4613 "'s'", |
| 4655 NULL | 4614 NULL |
| 4656 }; | 4615 }; |
| 4657 | 4616 |
| 4658 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4617 RunParserSyncTest(context_data, name_data, kError); |
| 4659 RunParserSyncTest(context_data, name_data, kError, NULL, 0, | |
| 4660 always_flags, arraysize(always_flags)); | |
| 4661 } | 4618 } |
| 4662 | 4619 |
| 4663 | 4620 |
| 4664 TEST(ObjectLiteralPropertyShorthandYieldInGeneratorError) { | 4621 TEST(ObjectLiteralPropertyShorthandYieldInGeneratorError) { |
| 4665 const char* context_data[][2] = {{"", ""}, | 4622 const char* context_data[][2] = {{"", ""}, |
| 4666 {NULL, NULL}}; | 4623 {NULL, NULL}}; |
| 4667 | 4624 |
| 4668 const char* name_data[] = { | 4625 const char* name_data[] = { |
| 4669 "function* g() { ({yield}); }", | 4626 "function* g() { ({yield}); }", |
| 4670 NULL | 4627 NULL |
| 4671 }; | 4628 }; |
| 4672 | 4629 |
| 4673 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; | 4630 RunParserSyncTest(context_data, name_data, kError); |
| 4674 RunParserSyncTest(context_data, name_data, kError, NULL, 0, | |
| 4675 always_flags, arraysize(always_flags)); | |
| 4676 } | 4631 } |
| 4677 | 4632 |
| 4678 | 4633 |
| 4679 TEST(ConstParsingInForIn) { | 4634 TEST(ConstParsingInForIn) { |
| 4680 const char* context_data[][2] = {{"'use strict';", ""}, | 4635 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4681 {"function foo(){ 'use strict';", "}"}, | 4636 {"function foo(){ 'use strict';", "}"}, |
| 4682 {NULL, NULL}}; | 4637 {NULL, NULL}}; |
| 4683 | 4638 |
| 4684 const char* data[] = { | 4639 const char* data[] = { |
| 4685 "for(const x = 1; ; ) {}", | 4640 "for(const x = 1; ; ) {}", |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5297 {"(class {*[", "]() {}});"}, | 5252 {"(class {*[", "]() {}});"}, |
| 5298 {NULL, NULL}}; | 5253 {NULL, NULL}}; |
| 5299 const char* error_data[] = { | 5254 const char* error_data[] = { |
| 5300 "1, 2", | 5255 "1, 2", |
| 5301 "var name", | 5256 "var name", |
| 5302 NULL}; | 5257 NULL}; |
| 5303 | 5258 |
| 5304 static const ParserFlag always_flags[] = { | 5259 static const ParserFlag always_flags[] = { |
| 5305 kAllowHarmonyClasses, | 5260 kAllowHarmonyClasses, |
| 5306 kAllowHarmonyComputedPropertyNames, | 5261 kAllowHarmonyComputedPropertyNames, |
| 5307 kAllowHarmonyObjectLiterals, | |
| 5308 kAllowHarmonySloppy, | 5262 kAllowHarmonySloppy, |
| 5309 }; | 5263 }; |
| 5310 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 5264 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 5311 always_flags, arraysize(always_flags)); | 5265 always_flags, arraysize(always_flags)); |
| 5312 | 5266 |
| 5313 const char* name_data[] = { | 5267 const char* name_data[] = { |
| 5314 "1", | 5268 "1", |
| 5315 "1 + 2", | 5269 "1 + 2", |
| 5316 "'name'", | 5270 "'name'", |
| 5317 "\"name\"", | 5271 "\"name\"", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5328 const char* context_data[][2] = {{"({", "});"}, | 5282 const char* context_data[][2] = {{"({", "});"}, |
| 5329 {NULL, NULL}}; | 5283 {NULL, NULL}}; |
| 5330 const char* error_data[] = { | 5284 const char* error_data[] = { |
| 5331 "a: 1, [2]", | 5285 "a: 1, [2]", |
| 5332 "[1], a: 1", | 5286 "[1], a: 1", |
| 5333 NULL}; | 5287 NULL}; |
| 5334 | 5288 |
| 5335 static const ParserFlag always_flags[] = { | 5289 static const ParserFlag always_flags[] = { |
| 5336 kAllowHarmonyClasses, | 5290 kAllowHarmonyClasses, |
| 5337 kAllowHarmonyComputedPropertyNames, | 5291 kAllowHarmonyComputedPropertyNames, |
| 5338 kAllowHarmonyObjectLiterals, | |
| 5339 kAllowHarmonySloppy, | 5292 kAllowHarmonySloppy, |
| 5340 }; | 5293 }; |
| 5341 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 5294 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 5342 always_flags, arraysize(always_flags)); | 5295 always_flags, arraysize(always_flags)); |
| 5343 } | 5296 } |
| 5344 | 5297 |
| 5345 | 5298 |
| 5346 TEST(BasicImportExportParsing) { | 5299 TEST(BasicImportExportParsing) { |
| 5347 const char* kSources[] = { | 5300 const char* kSources[] = { |
| 5348 "export let x = 0;", | 5301 "export let x = 0;", |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5626 "__proto__: {}, ['__proto__']: {}", | 5579 "__proto__: {}, ['__proto__']: {}", |
| 5627 "__proto__: {}, __proto__() {}", | 5580 "__proto__: {}, __proto__() {}", |
| 5628 "__proto__: {}, get __proto__() {}", | 5581 "__proto__: {}, get __proto__() {}", |
| 5629 "__proto__: {}, set __proto__(v) {}", | 5582 "__proto__: {}, set __proto__(v) {}", |
| 5630 "__proto__: {}, __proto__", | 5583 "__proto__: {}, __proto__", |
| 5631 NULL | 5584 NULL |
| 5632 }; | 5585 }; |
| 5633 | 5586 |
| 5634 static const ParserFlag always_flags[] = { | 5587 static const ParserFlag always_flags[] = { |
| 5635 kAllowHarmonyComputedPropertyNames, | 5588 kAllowHarmonyComputedPropertyNames, |
| 5636 kAllowHarmonyObjectLiterals, | |
| 5637 }; | 5589 }; |
| 5638 RunParserSyncTest(context_data, error_data, kSuccess, NULL, 0, | 5590 RunParserSyncTest(context_data, error_data, kSuccess, NULL, 0, |
| 5639 always_flags, arraysize(always_flags)); | 5591 always_flags, arraysize(always_flags)); |
| 5640 } | 5592 } |
| 5641 | 5593 |
| 5642 | 5594 |
| 5643 TEST(DeclarationsError) { | 5595 TEST(DeclarationsError) { |
| 5644 const char* context_data[][2] = {{"'use strict'; if (true)", ""}, | 5596 const char* context_data[][2] = {{"'use strict'; if (true)", ""}, |
| 5645 {"'use strict'; if (false) {} else", ""}, | 5597 {"'use strict'; if (false) {} else", ""}, |
| 5646 {"'use strict'; while (false)", ""}, | 5598 {"'use strict'; while (false)", ""}, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5739 "class C {static arguments() {}}", | 5691 "class C {static arguments() {}}", |
| 5740 "class C {static *eval() {}}", | 5692 "class C {static *eval() {}}", |
| 5741 "class C {static *arguments() {}}", | 5693 "class C {static *arguments() {}}", |
| 5742 "class C {static get eval() {}}", | 5694 "class C {static get eval() {}}", |
| 5743 "class C {static get arguments() {}}", | 5695 "class C {static get arguments() {}}", |
| 5744 "class C {static set eval(_) {}}", | 5696 "class C {static set eval(_) {}}", |
| 5745 "class C {static set arguments(_) {}}", | 5697 "class C {static set arguments(_) {}}", |
| 5746 | 5698 |
| 5747 NULL}; | 5699 NULL}; |
| 5748 | 5700 |
| 5749 static const ParserFlag always_flags[] = { | 5701 static const ParserFlag always_flags[] = {kAllowHarmonyClasses, |
| 5750 kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, kAllowStrongMode}; | 5702 kAllowStrongMode}; |
| 5751 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 5703 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
| 5752 always_flags, arraysize(always_flags)); | 5704 always_flags, arraysize(always_flags)); |
| 5753 } | 5705 } |
| 5754 | 5706 |
| 5755 | 5707 |
| 5756 TEST(FunctionLiteralDuplicateParameters) { | 5708 TEST(FunctionLiteralDuplicateParameters) { |
| 5757 const char* strict_context_data[][2] = | 5709 const char* strict_context_data[][2] = |
| 5758 {{"'use strict';(function(", "){})();"}, | 5710 {{"'use strict';(function(", "){})();"}, |
| 5759 {"(function(", ") { 'use strict'; })();"}, | 5711 {"(function(", ") { 'use strict'; })();"}, |
| 5760 {"'use strict'; function fn(", ") {}; fn();"}, | 5712 {"'use strict'; function fn(", ") {}; fn();"}, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5925 "class C { constructor() { this.a = {b: 1}; this.a.b = 0 } }", | 5877 "class C { constructor() { this.a = {b: 1}; this.a.b = 0 } }", |
| 5926 "class C { constructor() { this.a = function(){}; this.a() } }", | 5878 "class C { constructor() { this.a = function(){}; this.a() } }", |
| 5927 NULL}; | 5879 NULL}; |
| 5928 | 5880 |
| 5929 const char* success_data[] = { | 5881 const char* success_data[] = { |
| 5930 "class C { constructor() { this.a = 0; } }", | 5882 "class C { constructor() { this.a = 0; } }", |
| 5931 "class C { constructor() { label: 0; this.a = 0; this.b = 6; } }", | 5883 "class C { constructor() { label: 0; this.a = 0; this.b = 6; } }", |
| 5932 NULL}; | 5884 NULL}; |
| 5933 | 5885 |
| 5934 static const ParserFlag always_flags[] = { | 5886 static const ParserFlag always_flags[] = { |
| 5935 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, | 5887 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyArrowFunctions}; |
| 5936 kAllowHarmonyArrowFunctions | |
| 5937 }; | |
| 5938 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, | 5888 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| 5939 always_flags, arraysize(always_flags)); | 5889 always_flags, arraysize(always_flags)); |
| 5940 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, | 5890 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| 5941 always_flags, arraysize(always_flags)); | 5891 always_flags, arraysize(always_flags)); |
| 5942 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, | 5892 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| 5943 always_flags, arraysize(always_flags)); | 5893 always_flags, arraysize(always_flags)); |
| 5944 | 5894 |
| 5945 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, | 5895 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| 5946 always_flags, arraysize(always_flags)); | 5896 always_flags, arraysize(always_flags)); |
| 5947 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, | 5897 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5981 NULL}; | 5931 NULL}; |
| 5982 | 5932 |
| 5983 const char* success_data[] = { | 5933 const char* success_data[] = { |
| 5984 "class C extends Object { constructor() { super(); } }", | 5934 "class C extends Object { constructor() { super(); } }", |
| 5985 "class C extends Object { constructor() { label: 66; super(); } }", | 5935 "class C extends Object { constructor() { label: 66; super(); } }", |
| 5986 "class C extends Object { constructor() { super(3); this.x = 0; } }", | 5936 "class C extends Object { constructor() { super(3); this.x = 0; } }", |
| 5987 "class C extends Object { constructor() { 3; super(3); this.x = 0; } }", | 5937 "class C extends Object { constructor() { 3; super(3); this.x = 0; } }", |
| 5988 NULL}; | 5938 NULL}; |
| 5989 | 5939 |
| 5990 static const ParserFlag always_flags[] = { | 5940 static const ParserFlag always_flags[] = { |
| 5991 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, | 5941 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyArrowFunctions}; |
| 5992 kAllowHarmonyArrowFunctions | |
| 5993 }; | |
| 5994 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, | 5942 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| 5995 always_flags, arraysize(always_flags)); | 5943 always_flags, arraysize(always_flags)); |
| 5996 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, | 5944 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| 5997 always_flags, arraysize(always_flags)); | 5945 always_flags, arraysize(always_flags)); |
| 5998 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, | 5946 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| 5999 always_flags, arraysize(always_flags)); | 5947 always_flags, arraysize(always_flags)); |
| 6000 | 5948 |
| 6001 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, | 5949 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| 6002 always_flags, arraysize(always_flags)); | 5950 always_flags, arraysize(always_flags)); |
| 6003 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, | 5951 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6028 const char* success_data[] = { | 5976 const char* success_data[] = { |
| 6029 "class C extends Object { constructor() { super(); return; } }", | 5977 "class C extends Object { constructor() { super(); return; } }", |
| 6030 "class C extends Object { constructor() { super(); { return } } }", | 5978 "class C extends Object { constructor() { super(); { return } } }", |
| 6031 "class C extends Object { constructor() { super(); if (1) return; } }", | 5979 "class C extends Object { constructor() { super(); if (1) return; } }", |
| 6032 "class C { constructor() { this.a = 0; return; } }", | 5980 "class C { constructor() { this.a = 0; return; } }", |
| 6033 "class C { constructor() { this.a = 0; { return; } } }", | 5981 "class C { constructor() { this.a = 0; { return; } } }", |
| 6034 "class C { constructor() { this.a = 0; if (0) return; 65; } }", | 5982 "class C { constructor() { this.a = 0; if (0) return; 65; } }", |
| 6035 "class C extends Array { constructor() { super(); this.a = 9; return } }", | 5983 "class C extends Array { constructor() { super(); this.a = 9; return } }", |
| 6036 NULL}; | 5984 NULL}; |
| 6037 | 5985 |
| 6038 static const ParserFlag always_flags[] = { | 5986 static const ParserFlag always_flags[] = {kAllowStrongMode, |
| 6039 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals | 5987 kAllowHarmonyClasses}; |
| 6040 }; | |
| 6041 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, | 5988 RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| 6042 always_flags, arraysize(always_flags)); | 5989 always_flags, arraysize(always_flags)); |
| 6043 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, | 5990 RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| 6044 always_flags, arraysize(always_flags)); | 5991 always_flags, arraysize(always_flags)); |
| 6045 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, | 5992 RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| 6046 always_flags, arraysize(always_flags)); | 5993 always_flags, arraysize(always_flags)); |
| 6047 | 5994 |
| 6048 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, | 5995 RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| 6049 always_flags, arraysize(always_flags)); | 5996 always_flags, arraysize(always_flags)); |
| 6050 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, | 5997 RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6425 "{var: x = 42}", | 6372 "{var: x = 42}", |
| 6426 "{[x] : z}", | 6373 "{[x] : z}", |
| 6427 "{[1+1] : z}", | 6374 "{[1+1] : z}", |
| 6428 "{[foo()] : z}", | 6375 "{[foo()] : z}", |
| 6429 "{}", | 6376 "{}", |
| 6430 "[...rest]", | 6377 "[...rest]", |
| 6431 "[a,b,...rest]", | 6378 "[a,b,...rest]", |
| 6432 "[a,,...rest]", | 6379 "[a,,...rest]", |
| 6433 NULL}; | 6380 NULL}; |
| 6434 // clang-format on | 6381 // clang-format on |
| 6435 static const ParserFlag always_flags[] = { | 6382 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, |
| 6436 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6383 kAllowHarmonyArrowFunctions, |
| 6437 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | 6384 kAllowHarmonyDestructuring}; |
| 6438 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6385 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6439 arraysize(always_flags)); | 6386 arraysize(always_flags)); |
| 6440 } | 6387 } |
| 6441 | 6388 |
| 6442 | 6389 |
| 6443 TEST(DestructuringNegativeTests) { | 6390 TEST(DestructuringNegativeTests) { |
| 6444 i::FLAG_harmony_destructuring = true; | 6391 i::FLAG_harmony_destructuring = true; |
| 6445 i::FLAG_harmony_arrow_functions = true; | 6392 i::FLAG_harmony_arrow_functions = true; |
| 6446 i::FLAG_harmony_computed_property_names = true; | 6393 i::FLAG_harmony_computed_property_names = true; |
| 6447 static const ParserFlag always_flags[] = { | 6394 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, |
| 6448 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6395 kAllowHarmonyArrowFunctions, |
| 6449 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | 6396 kAllowHarmonyDestructuring}; |
| 6450 | 6397 |
| 6451 { // All modes. | 6398 { // All modes. |
| 6452 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6399 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6453 {"var ", " = {};"}, | 6400 {"var ", " = {};"}, |
| 6454 {"'use strict'; const ", " = {};"}, | 6401 {"'use strict'; const ", " = {};"}, |
| 6455 {"function f(", ") {}"}, | 6402 {"function f(", ") {}"}, |
| 6456 {"function f(argument1, ", ") {}"}, | 6403 {"function f(argument1, ", ") {}"}, |
| 6457 {"var f = (", ") => {};"}, | 6404 {"var f = (", ") => {};"}, |
| 6458 {"var f = ", " => {};"}, | 6405 {"var f = ", " => {};"}, |
| 6459 {"var f = (argument1,", ") => {};"}, | 6406 {"var f = (argument1,", ") => {};"}, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6581 } | 6528 } |
| 6582 | 6529 |
| 6583 | 6530 |
| 6584 TEST(DestructuringDisallowPatternsInForVarIn) { | 6531 TEST(DestructuringDisallowPatternsInForVarIn) { |
| 6585 i::FLAG_harmony_destructuring = true; | 6532 i::FLAG_harmony_destructuring = true; |
| 6586 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 6533 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
| 6587 const char* context_data[][2] = { | 6534 const char* context_data[][2] = { |
| 6588 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; | 6535 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; |
| 6589 // clang-format off | 6536 // clang-format off |
| 6590 const char* error_data[] = { | 6537 const char* error_data[] = { |
| 6591 "for (var {x} = {} in null);", | |
| 6592 "for (var {x} = {} of null);", | |
| 6593 "for (let x = {} in null);", | 6538 "for (let x = {} in null);", |
| 6594 "for (let x = {} of null);", | 6539 "for (let x = {} of null);", |
| 6595 NULL}; | 6540 NULL}; |
| 6596 // clang-format on | 6541 // clang-format on |
| 6597 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6542 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6598 arraysize(always_flags)); | 6543 arraysize(always_flags)); |
| 6599 | 6544 |
| 6600 // clang-format off | 6545 // clang-format off |
| 6601 const char* success_data[] = { | 6546 const char* success_data[] = { |
| 6602 "for (var x = {} in null);", | 6547 "for (var x = {} in null);", |
| 6603 NULL}; | 6548 NULL}; |
| 6604 // clang-format on | 6549 // clang-format on |
| 6605 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, | 6550 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, |
| 6606 arraysize(always_flags)); | 6551 arraysize(always_flags)); |
| 6607 } | 6552 } |
| 6608 | 6553 |
| 6609 | 6554 |
| 6610 TEST(DestructuringDuplicateParams) { | 6555 TEST(DestructuringDuplicateParams) { |
| 6611 i::FLAG_harmony_destructuring = true; | 6556 i::FLAG_harmony_destructuring = true; |
| 6612 i::FLAG_harmony_arrow_functions = true; | 6557 i::FLAG_harmony_arrow_functions = true; |
| 6613 i::FLAG_harmony_computed_property_names = true; | 6558 i::FLAG_harmony_computed_property_names = true; |
| 6614 static const ParserFlag always_flags[] = { | 6559 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, |
| 6615 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6560 kAllowHarmonyArrowFunctions, |
| 6616 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | 6561 kAllowHarmonyDestructuring}; |
| 6617 const char* context_data[][2] = {{"'use strict';", ""}, | 6562 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6618 {"function outer() { 'use strict';", "}"}, | 6563 {"function outer() { 'use strict';", "}"}, |
| 6619 {nullptr, nullptr}}; | 6564 {nullptr, nullptr}}; |
| 6620 | 6565 |
| 6621 | 6566 |
| 6622 // clang-format off | 6567 // clang-format off |
| 6623 const char* error_data[] = { | 6568 const char* error_data[] = { |
| 6624 "function f(x,x){}", | 6569 "function f(x,x){}", |
| 6625 "function f(x, {x : x}){}", | 6570 "function f(x, {x : x}){}", |
| 6626 "function f(x, {x}){}", | 6571 "function f(x, {x}){}", |
| 6627 "function f({x,x}) {}", | 6572 "function f({x,x}) {}", |
| 6628 "function f([x,x]) {}", | 6573 "function f([x,x]) {}", |
| 6629 "function f(x, [y,{z:x}]) {}", | 6574 "function f(x, [y,{z:x}]) {}", |
| 6630 "function f([x,{y:x}]) {}", | 6575 "function f([x,{y:x}]) {}", |
| 6631 // non-simple parameter list causes duplicates to be errors in sloppy mode. | 6576 // non-simple parameter list causes duplicates to be errors in sloppy mode. |
| 6632 "function f(x, x, {a}) {}", | 6577 "function f(x, x, {a}) {}", |
| 6633 nullptr}; | 6578 nullptr}; |
| 6634 // clang-format on | 6579 // clang-format on |
| 6635 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6580 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6636 arraysize(always_flags)); | 6581 arraysize(always_flags)); |
| 6637 } | 6582 } |
| 6638 | 6583 |
| 6639 | 6584 |
| 6640 TEST(DestructuringDuplicateParamsSloppy) { | 6585 TEST(DestructuringDuplicateParamsSloppy) { |
| 6641 i::FLAG_harmony_destructuring = true; | 6586 i::FLAG_harmony_destructuring = true; |
| 6642 i::FLAG_harmony_arrow_functions = true; | 6587 i::FLAG_harmony_arrow_functions = true; |
| 6643 i::FLAG_harmony_computed_property_names = true; | 6588 i::FLAG_harmony_computed_property_names = true; |
| 6644 static const ParserFlag always_flags[] = { | 6589 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, |
| 6645 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6590 kAllowHarmonyArrowFunctions, |
| 6646 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | 6591 kAllowHarmonyDestructuring}; |
| 6647 const char* context_data[][2] = { | 6592 const char* context_data[][2] = { |
| 6648 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; | 6593 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; |
| 6649 | 6594 |
| 6650 | 6595 |
| 6651 // clang-format off | 6596 // clang-format off |
| 6652 const char* error_data[] = { | 6597 const char* error_data[] = { |
| 6653 // non-simple parameter list causes duplicates to be errors in sloppy mode. | 6598 // non-simple parameter list causes duplicates to be errors in sloppy mode. |
| 6654 "function f(x, {x : x}){}", | 6599 "function f(x, {x : x}){}", |
| 6655 "function f(x, {x}){}", | 6600 "function f(x, {x}){}", |
| 6656 "function f({x,x}) {}", | 6601 "function f({x,x}) {}", |
| 6657 "function f(x, x, {a}) {}", | 6602 "function f(x, x, {a}) {}", |
| 6658 nullptr}; | 6603 nullptr}; |
| 6659 // clang-format on | 6604 // clang-format on |
| 6660 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6605 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6661 arraysize(always_flags)); | 6606 arraysize(always_flags)); |
| 6662 } | 6607 } |
| 6663 | 6608 |
| 6664 | 6609 |
| 6665 TEST(DestructuringDisallowPatternsInSingleParamArrows) { | 6610 TEST(DestructuringDisallowPatternsInSingleParamArrows) { |
| 6666 i::FLAG_harmony_destructuring = true; | 6611 i::FLAG_harmony_destructuring = true; |
| 6667 i::FLAG_harmony_arrow_functions = true; | 6612 i::FLAG_harmony_arrow_functions = true; |
| 6668 i::FLAG_harmony_computed_property_names = true; | 6613 i::FLAG_harmony_computed_property_names = true; |
| 6669 static const ParserFlag always_flags[] = { | 6614 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, |
| 6670 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6615 kAllowHarmonyArrowFunctions, |
| 6671 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | 6616 kAllowHarmonyDestructuring}; |
| 6672 const char* context_data[][2] = {{"'use strict';", ""}, | 6617 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6673 {"function outer() { 'use strict';", "}"}, | 6618 {"function outer() { 'use strict';", "}"}, |
| 6674 {"", ""}, | 6619 {"", ""}, |
| 6675 {"function outer() { ", "}"}, | 6620 {"function outer() { ", "}"}, |
| 6676 {nullptr, nullptr}}; | 6621 {nullptr, nullptr}}; |
| 6677 | 6622 |
| 6678 // clang-format off | 6623 // clang-format off |
| 6679 const char* error_data[] = { | 6624 const char* error_data[] = { |
| 6680 "var f = {x} => {};", | 6625 "var f = {x} => {};", |
| 6681 "var f = {x,y} => {};", | 6626 "var f = {x,y} => {};", |
| 6682 nullptr}; | 6627 nullptr}; |
| 6683 // clang-format on | 6628 // clang-format on |
| 6684 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6629 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6685 arraysize(always_flags)); | 6630 arraysize(always_flags)); |
| 6686 } | 6631 } |
| 6687 | 6632 |
| 6688 | 6633 |
| 6689 TEST(DestructuringDisallowPatternsInRestParams) { | 6634 TEST(DestructuringDisallowPatternsInRestParams) { |
| 6690 i::FLAG_harmony_destructuring = true; | 6635 i::FLAG_harmony_destructuring = true; |
| 6691 i::FLAG_harmony_arrow_functions = true; | 6636 i::FLAG_harmony_arrow_functions = true; |
| 6692 i::FLAG_harmony_rest_parameters = true; | 6637 i::FLAG_harmony_rest_parameters = true; |
| 6693 i::FLAG_harmony_computed_property_names = true; | 6638 i::FLAG_harmony_computed_property_names = true; |
| 6694 static const ParserFlag always_flags[] = { | 6639 static const ParserFlag always_flags[] = { |
| 6695 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | 6640 kAllowHarmonyComputedPropertyNames, kAllowHarmonyArrowFunctions, |
| 6696 kAllowHarmonyArrowFunctions, kAllowHarmonyRestParameters, | 6641 kAllowHarmonyRestParameters, kAllowHarmonyDestructuring}; |
| 6697 kAllowHarmonyDestructuring}; | |
| 6698 const char* context_data[][2] = {{"'use strict';", ""}, | 6642 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6699 {"function outer() { 'use strict';", "}"}, | 6643 {"function outer() { 'use strict';", "}"}, |
| 6700 {"", ""}, | 6644 {"", ""}, |
| 6701 {"function outer() { ", "}"}, | 6645 {"function outer() { ", "}"}, |
| 6702 {nullptr, nullptr}}; | 6646 {nullptr, nullptr}}; |
| 6703 | 6647 |
| 6704 // clang-format off | 6648 // clang-format off |
| 6705 const char* error_data[] = { | 6649 const char* error_data[] = { |
| 6706 "function(...{}) {}", | 6650 "function(...{}) {}", |
| 6707 "function(...{x}) {}", | 6651 "function(...{x}) {}", |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6799 "if (1) {} else { new.target }", | 6743 "if (1) {} else { new.target }", |
| 6800 "while (0) { new.target }", | 6744 "while (0) { new.target }", |
| 6801 "do { new.target } while (0)", | 6745 "do { new.target } while (0)", |
| 6802 NULL | 6746 NULL |
| 6803 }; | 6747 }; |
| 6804 | 6748 |
| 6805 static const ParserFlag always_flags[] = { | 6749 static const ParserFlag always_flags[] = { |
| 6806 kAllowHarmonyArrowFunctions, | 6750 kAllowHarmonyArrowFunctions, |
| 6807 kAllowHarmonyClasses, | 6751 kAllowHarmonyClasses, |
| 6808 kAllowHarmonyNewTarget, | 6752 kAllowHarmonyNewTarget, |
| 6809 kAllowHarmonyObjectLiterals, | |
| 6810 kAllowHarmonySloppy, | 6753 kAllowHarmonySloppy, |
| 6811 }; | 6754 }; |
| 6812 // clang-format on | 6755 // clang-format on |
| 6813 | 6756 |
| 6814 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, | 6757 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, |
| 6815 arraysize(always_flags)); | 6758 arraysize(always_flags)); |
| 6816 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, | 6759 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, |
| 6817 arraysize(always_flags)); | 6760 arraysize(always_flags)); |
| 6818 } | 6761 } |
| OLD | NEW |