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 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1497 |
1498 data.Dispose(); | 1498 data.Dispose(); |
1499 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); | 1499 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); |
1500 } | 1500 } |
1501 | 1501 |
1502 | 1502 |
1503 enum ParserFlag { | 1503 enum ParserFlag { |
1504 kAllowLazy, | 1504 kAllowLazy, |
1505 kAllowNatives, | 1505 kAllowNatives, |
1506 kAllowHarmonyDefaultParameters, | 1506 kAllowHarmonyDefaultParameters, |
1507 kAllowHarmonyRestParameters, | |
1508 kAllowHarmonySloppy, | 1507 kAllowHarmonySloppy, |
1509 kAllowHarmonySloppyLet, | 1508 kAllowHarmonySloppyLet, |
1510 kAllowHarmonyDestructuring, | 1509 kAllowHarmonyDestructuring, |
1511 kAllowHarmonyDestructuringAssignment, | 1510 kAllowHarmonyDestructuringAssignment, |
1512 kAllowHarmonyNewTarget, | 1511 kAllowHarmonyNewTarget, |
1513 kAllowStrongMode, | 1512 kAllowStrongMode, |
1514 kNoLegacyConst | 1513 kNoLegacyConst |
1515 }; | 1514 }; |
1516 | 1515 |
1517 | 1516 |
1518 enum ParserSyncTestResult { | 1517 enum ParserSyncTestResult { |
1519 kSuccessOrError, | 1518 kSuccessOrError, |
1520 kSuccess, | 1519 kSuccess, |
1521 kError | 1520 kError |
1522 }; | 1521 }; |
1523 | 1522 |
1524 template <typename Traits> | 1523 template <typename Traits> |
1525 void SetParserFlags(i::ParserBase<Traits>* parser, | 1524 void SetParserFlags(i::ParserBase<Traits>* parser, |
1526 i::EnumSet<ParserFlag> flags) { | 1525 i::EnumSet<ParserFlag> flags) { |
1527 parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 1526 parser->set_allow_lazy(flags.Contains(kAllowLazy)); |
1528 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1527 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
1529 parser->set_allow_harmony_default_parameters( | 1528 parser->set_allow_harmony_default_parameters( |
1530 flags.Contains(kAllowHarmonyDefaultParameters)); | 1529 flags.Contains(kAllowHarmonyDefaultParameters)); |
1531 parser->set_allow_harmony_rest_parameters( | |
1532 flags.Contains(kAllowHarmonyRestParameters)); | |
1533 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); | 1530 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); |
1534 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet)); | 1531 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet)); |
1535 parser->set_allow_harmony_destructuring_bind( | 1532 parser->set_allow_harmony_destructuring_bind( |
1536 flags.Contains(kAllowHarmonyDestructuring)); | 1533 flags.Contains(kAllowHarmonyDestructuring)); |
1537 parser->set_allow_harmony_destructuring_assignment( | 1534 parser->set_allow_harmony_destructuring_assignment( |
1538 flags.Contains(kAllowHarmonyDestructuringAssignment)); | 1535 flags.Contains(kAllowHarmonyDestructuringAssignment)); |
1539 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); | 1536 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); |
1540 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); | 1537 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); |
1541 } | 1538 } |
1542 | 1539 |
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 "c++", | 3677 "c++", |
3681 "`c`", | 3678 "`c`", |
3682 "`${c}`", | 3679 "`${c}`", |
3683 "`template-head${c}`", | 3680 "`template-head${c}`", |
3684 "`${c}template-tail`", | 3681 "`${c}template-tail`", |
3685 "`template-head${c}template-tail`", | 3682 "`template-head${c}template-tail`", |
3686 "`${c}template-tail`", | 3683 "`${c}template-tail`", |
3687 nullptr | 3684 nullptr |
3688 }; | 3685 }; |
3689 | 3686 |
3690 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | 3687 RunParserSyncTest(context_data, assignment_expression_suffix_data, kError); |
3691 RunParserSyncTest(context_data, assignment_expression_suffix_data, kError, | |
3692 NULL, 0, always_flags, arraysize(always_flags)); | |
3693 } | 3688 } |
3694 | 3689 |
3695 | 3690 |
3696 TEST(ErrorsArrowFunctions) { | 3691 TEST(ErrorsArrowFunctions) { |
3697 // Tests that parser and preparser generate the same kind of errors | 3692 // Tests that parser and preparser generate the same kind of errors |
3698 // on invalid arrow function syntax. | 3693 // on invalid arrow function syntax. |
3699 const char* context_data[][2] = { | 3694 const char* context_data[][2] = { |
3700 {"", ";"}, | 3695 {"", ";"}, |
3701 {"v = ", ";"}, | 3696 {"v = ", ";"}, |
3702 {"bar ? (", ") : baz;"}, | 3697 {"bar ? (", ") : baz;"}, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3874 "(x, y = 9, {b}, z = 8, ...a) => {}", | 3869 "(x, y = 9, {b}, z = 8, ...a) => {}", |
3875 // TODO(wingo, rossberg): This is not accepted right now. | 3870 // TODO(wingo, rossberg): This is not accepted right now. |
3876 // "({a} = {}) => {}", | 3871 // "({a} = {}) => {}", |
3877 // "([x] = []) => {}", | 3872 // "([x] = []) => {}", |
3878 "({a = 42}) => {}", | 3873 "({a = 42}) => {}", |
3879 "([x = 0]) => {}", | 3874 "([x = 0]) => {}", |
3880 NULL | 3875 NULL |
3881 }; | 3876 }; |
3882 | 3877 |
3883 static const ParserFlag always_flags[] = {kAllowHarmonyDefaultParameters, | 3878 static const ParserFlag always_flags[] = {kAllowHarmonyDefaultParameters, |
3884 kAllowHarmonyRestParameters, | |
3885 kAllowHarmonyDestructuring}; | 3879 kAllowHarmonyDestructuring}; |
3886 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3880 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
3887 always_flags, arraysize(always_flags)); | 3881 always_flags, arraysize(always_flags)); |
3888 | 3882 |
3889 static const ParserFlag flags[] = {kAllowLazy}; | 3883 static const ParserFlag flags[] = {kAllowLazy}; |
3890 // In a context where a concise arrow body is parsed with [~In] variant, | 3884 // In a context where a concise arrow body is parsed with [~In] variant, |
3891 // ensure that nested expressions can still use the 'in' operator, | 3885 // ensure that nested expressions can still use the 'in' operator, |
3892 const char* loop_context_data[][2] = {{"for (", "; 0;);"}, | 3886 const char* loop_context_data[][2] = {{"for (", "; 0;);"}, |
3893 {nullptr, nullptr}}; | 3887 {nullptr, nullptr}}; |
3894 const char* loop_expr_data[] = {"f => ('key' in {})", nullptr}; | 3888 const char* loop_expr_data[] = {"f => ('key' in {})", nullptr}; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3981 "(a, yield) => {}", | 3975 "(a, yield) => {}", |
3982 "(yield, a) => {}", | 3976 "(yield, a) => {}", |
3983 "(yield, ...a) => {}", | 3977 "(yield, ...a) => {}", |
3984 "(a, ...yield) => {}", | 3978 "(a, ...yield) => {}", |
3985 "({yield}) => {}", | 3979 "({yield}) => {}", |
3986 "([yield]) => {}", | 3980 "([yield]) => {}", |
3987 NULL | 3981 NULL |
3988 }; | 3982 }; |
3989 | 3983 |
3990 static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring, | 3984 static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring, |
3991 kAllowHarmonyRestParameters, | |
3992 kAllowStrongMode}; | 3985 kAllowStrongMode}; |
3993 RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess, NULL, 0, | 3986 RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess, NULL, 0, |
3994 always_flags, arraysize(always_flags)); | 3987 always_flags, arraysize(always_flags)); |
3995 RunParserSyncTest(strict_function_context_data, arrow_data, kError, NULL, 0, | 3988 RunParserSyncTest(strict_function_context_data, arrow_data, kError, NULL, 0, |
3996 always_flags, arraysize(always_flags)); | 3989 always_flags, arraysize(always_flags)); |
3997 RunParserSyncTest(generator_context_data, arrow_data, kError, NULL, 0, | 3990 RunParserSyncTest(generator_context_data, arrow_data, kError, NULL, 0, |
3998 always_flags, arraysize(always_flags)); | 3991 always_flags, arraysize(always_flags)); |
3999 } | 3992 } |
4000 | 3993 |
4001 | 3994 |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5308 "a, ... args", | 5301 "a, ... args", |
5309 "...\targs", | 5302 "...\targs", |
5310 "a, ...\targs", | 5303 "a, ...\targs", |
5311 "...\r\nargs", | 5304 "...\r\nargs", |
5312 "a, ...\r\nargs", | 5305 "a, ...\r\nargs", |
5313 "...\rargs", | 5306 "...\rargs", |
5314 "a, ...\rargs", | 5307 "a, ...\rargs", |
5315 "...\t\n\t\t\n args", | 5308 "...\t\n\t\t\n args", |
5316 "a, ... \n \n args", | 5309 "a, ... \n \n args", |
5317 NULL}; | 5310 NULL}; |
5318 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | 5311 RunParserSyncTest(context_data, data, kSuccess); |
5319 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | |
5320 arraysize(always_flags)); | |
5321 } | 5312 } |
5322 | 5313 |
5323 | 5314 |
5324 TEST(ParseRestParametersErrors) { | 5315 TEST(ParseRestParametersErrors) { |
5325 const char* context_data[][2] = {{"'use strict';(function(", | 5316 const char* context_data[][2] = {{"'use strict';(function(", |
5326 "){ return args;}(1, [], /regexp/, 'str'," | 5317 "){ return args;}(1, [], /regexp/, 'str'," |
5327 "function(){});"}, | 5318 "function(){});"}, |
5328 {"(function(", "){ return args;}(1, []," | 5319 {"(function(", "){ return args;}(1, []," |
5329 "/regexp/, 'str', function(){});"}, | 5320 "/regexp/, 'str', function(){});"}, |
5330 {NULL, NULL}}; | 5321 {NULL, NULL}}; |
5331 | 5322 |
5332 const char* data[] = { | 5323 const char* data[] = { |
5333 "...args, b", | 5324 "...args, b", |
5334 "a, ...args, b", | 5325 "a, ...args, b", |
5335 "...args, b", | 5326 "...args, b", |
5336 "a, ...args, b", | 5327 "a, ...args, b", |
5337 "...args,\tb", | 5328 "...args,\tb", |
5338 "a,...args\t,b", | 5329 "a,...args\t,b", |
5339 "...args\r\n, b", | 5330 "...args\r\n, b", |
5340 "a, ... args,\r\nb", | 5331 "a, ... args,\r\nb", |
5341 "...args\r,b", | 5332 "...args\r,b", |
5342 "a, ... args,\rb", | 5333 "a, ... args,\rb", |
5343 "...args\t\n\t\t\n, b", | 5334 "...args\t\n\t\t\n, b", |
5344 "a, ... args, \n \n b", | 5335 "a, ... args, \n \n b", |
5345 "a, a, ...args", | 5336 "a, a, ...args", |
5346 "a,\ta, ...args", | 5337 "a,\ta, ...args", |
5347 "a,\ra, ...args", | 5338 "a,\ra, ...args", |
5348 "a,\na, ...args", | 5339 "a,\na, ...args", |
5349 NULL}; | 5340 NULL}; |
5350 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | 5341 RunParserSyncTest(context_data, data, kError); |
5351 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | |
5352 arraysize(always_flags)); | |
5353 } | 5342 } |
5354 | 5343 |
5355 | 5344 |
5356 TEST(RestParameterInSetterMethodError) { | 5345 TEST(RestParameterInSetterMethodError) { |
5357 const char* context_data[][2] = { | 5346 const char* context_data[][2] = { |
5358 {"'use strict';({ set prop(", ") {} }).prop = 1;"}, | 5347 {"'use strict';({ set prop(", ") {} }).prop = 1;"}, |
5359 {"'use strict';(class { static set prop(", ") {} }).prop = 1;"}, | 5348 {"'use strict';(class { static set prop(", ") {} }).prop = 1;"}, |
5360 {"'use strict';(new (class { set prop(", ") {} })).prop = 1;"}, | 5349 {"'use strict';(new (class { set prop(", ") {} })).prop = 1;"}, |
5361 {"({ set prop(", ") {} }).prop = 1;"}, | 5350 {"({ set prop(", ") {} }).prop = 1;"}, |
5362 {"(class { static set prop(", ") {} }).prop = 1;"}, | 5351 {"(class { static set prop(", ") {} }).prop = 1;"}, |
5363 {"(new (class { set prop(", ") {} })).prop = 1;"}, | 5352 {"(new (class { set prop(", ") {} })).prop = 1;"}, |
5364 {nullptr, nullptr}}; | 5353 {nullptr, nullptr}}; |
5365 const char* data[] = {"...a", "...arguments", "...eval", nullptr}; | 5354 const char* data[] = {"...a", "...arguments", "...eval", nullptr}; |
5366 | 5355 |
5367 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters, | 5356 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
5368 kAllowHarmonySloppy}; | |
5369 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, | 5357 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
5370 arraysize(always_flags)); | 5358 arraysize(always_flags)); |
5371 } | 5359 } |
5372 | 5360 |
5373 | 5361 |
5374 TEST(RestParametersEvalArguments) { | 5362 TEST(RestParametersEvalArguments) { |
5375 const char* strict_context_data[][2] = | 5363 const char* strict_context_data[][2] = |
5376 {{"'use strict';(function(", | 5364 {{"'use strict';(function(", |
5377 "){ return;})(1, [], /regexp/, 'str',function(){});"}, | 5365 "){ return;})(1, [], /regexp/, 'str',function(){});"}, |
5378 {NULL, NULL}}; | 5366 {NULL, NULL}}; |
5379 const char* sloppy_context_data[][2] = | 5367 const char* sloppy_context_data[][2] = |
5380 {{"(function(", | 5368 {{"(function(", |
5381 "){ return;})(1, [],/regexp/, 'str', function(){});"}, | 5369 "){ return;})(1, [],/regexp/, 'str', function(){});"}, |
5382 {NULL, NULL}}; | 5370 {NULL, NULL}}; |
5383 | 5371 |
5384 const char* data[] = { | 5372 const char* data[] = { |
5385 "...eval", | 5373 "...eval", |
5386 "eval, ...args", | 5374 "eval, ...args", |
5387 "...arguments", | 5375 "...arguments", |
5388 "arguments, ...args", | 5376 "arguments, ...args", |
5389 NULL}; | 5377 NULL}; |
5390 | 5378 |
5391 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | |
5392 | |
5393 // Fail in strict mode | 5379 // Fail in strict mode |
5394 RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags, | 5380 RunParserSyncTest(strict_context_data, data, kError); |
5395 arraysize(always_flags)); | |
5396 | 5381 |
5397 // OK in sloppy mode | 5382 // OK in sloppy mode |
5398 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, | 5383 RunParserSyncTest(sloppy_context_data, data, kSuccess); |
5399 arraysize(always_flags)); | |
5400 } | 5384 } |
5401 | 5385 |
5402 | 5386 |
5403 TEST(RestParametersDuplicateEvalArguments) { | 5387 TEST(RestParametersDuplicateEvalArguments) { |
5404 const char* context_data[][2] = | 5388 const char* context_data[][2] = |
5405 {{"'use strict';(function(", | 5389 {{"'use strict';(function(", |
5406 "){ return;})(1, [], /regexp/, 'str',function(){});"}, | 5390 "){ return;})(1, [], /regexp/, 'str',function(){});"}, |
5407 {"(function(", | 5391 {"(function(", |
5408 "){ return;})(1, [],/regexp/, 'str', function(){});"}, | 5392 "){ return;})(1, [],/regexp/, 'str', function(){});"}, |
5409 {NULL, NULL}}; | 5393 {NULL, NULL}}; |
5410 | 5394 |
5411 const char* data[] = { | 5395 const char* data[] = { |
5412 "eval, ...eval", | 5396 "eval, ...eval", |
5413 "eval, eval, ...args", | 5397 "eval, eval, ...args", |
5414 "arguments, ...arguments", | 5398 "arguments, ...arguments", |
5415 "arguments, arguments, ...args", | 5399 "arguments, arguments, ...args", |
5416 NULL}; | 5400 NULL}; |
5417 | 5401 |
5418 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | |
5419 | |
5420 // In strict mode, the error is using "eval" or "arguments" as parameter names | 5402 // In strict mode, the error is using "eval" or "arguments" as parameter names |
5421 // In sloppy mode, the error is that eval / arguments are duplicated | 5403 // In sloppy mode, the error is that eval / arguments are duplicated |
5422 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 5404 RunParserSyncTest(context_data, data, kError); |
5423 arraysize(always_flags)); | |
5424 } | 5405 } |
5425 | 5406 |
5426 | 5407 |
5427 TEST(SpreadCall) { | 5408 TEST(SpreadCall) { |
5428 const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, | 5409 const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, |
5429 {"function fn() {} fn(", ");"}, | 5410 {"function fn() {} fn(", ");"}, |
5430 {NULL, NULL}}; | 5411 {NULL, NULL}}; |
5431 | 5412 |
5432 const char* data[] = { | 5413 const char* data[] = { |
5433 "...([1, 2, 3])", "...'123', ...'456'", "...new Set([1, 2, 3]), 4", | 5414 "...([1, 2, 3])", "...'123', ...'456'", "...new Set([1, 2, 3]), 4", |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6247 "constructor() { \"use strong\" }", | 6228 "constructor() { \"use strong\" }", |
6248 "constructor(...rest) { \"use strong\" }", | 6229 "constructor(...rest) { \"use strong\" }", |
6249 "foo() {} constructor() { \"use strong\" }", | 6230 "foo() {} constructor() { \"use strong\" }", |
6250 "foo(...rest) { \"use strict\" } constructor() { \"use strong\" }", NULL}; | 6231 "foo(...rest) { \"use strict\" } constructor() { \"use strong\" }", NULL}; |
6251 | 6232 |
6252 const char* success_data[] = { | 6233 const char* success_data[] = { |
6253 "constructor() { \"use strict\" }", "foo() { \"use strong\" }", | 6234 "constructor() { \"use strict\" }", "foo() { \"use strong\" }", |
6254 "foo() { \"use strong\" } constructor() {}", NULL}; | 6235 "foo() { \"use strong\" } constructor() {}", NULL}; |
6255 | 6236 |
6256 static const ParserFlag always_flags[] = { | 6237 static const ParserFlag always_flags[] = { |
6257 kAllowHarmonyRestParameters, kAllowHarmonySloppy, kAllowHarmonySloppyLet, | 6238 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowStrongMode}; |
6258 kAllowStrongMode}; | |
6259 | 6239 |
6260 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6240 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
6261 arraysize(always_flags)); | 6241 arraysize(always_flags)); |
6262 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, | 6242 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, |
6263 arraysize(always_flags)); | 6243 arraysize(always_flags)); |
6264 } | 6244 } |
6265 | 6245 |
6266 | 6246 |
6267 TEST(StrongUndefinedLocal) { | 6247 TEST(StrongUndefinedLocal) { |
6268 const char* context_data[][2] = {{"", ""}, {NULL}}; | 6248 const char* context_data[][2] = {{"", ""}, {NULL}}; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7180 "var f = {x,y} => {};", | 7160 "var f = {x,y} => {};", |
7181 nullptr}; | 7161 nullptr}; |
7182 // clang-format on | 7162 // clang-format on |
7183 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7163 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7184 arraysize(always_flags)); | 7164 arraysize(always_flags)); |
7185 } | 7165 } |
7186 | 7166 |
7187 | 7167 |
7188 TEST(DestructuringDisallowPatternsInRestParams) { | 7168 TEST(DestructuringDisallowPatternsInRestParams) { |
7189 i::FLAG_harmony_destructuring_bind = true; | 7169 i::FLAG_harmony_destructuring_bind = true; |
7190 i::FLAG_harmony_rest_parameters = true; | 7170 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
7191 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters, | |
7192 kAllowHarmonyDestructuring}; | |
7193 const char* context_data[][2] = {{"'use strict';", ""}, | 7171 const char* context_data[][2] = {{"'use strict';", ""}, |
7194 {"function outer() { 'use strict';", "}"}, | 7172 {"function outer() { 'use strict';", "}"}, |
7195 {"", ""}, | 7173 {"", ""}, |
7196 {"function outer() { ", "}"}, | 7174 {"function outer() { ", "}"}, |
7197 {nullptr, nullptr}}; | 7175 {nullptr, nullptr}}; |
7198 | 7176 |
7199 // clang-format off | 7177 // clang-format off |
7200 const char* error_data[] = { | 7178 const char* error_data[] = { |
7201 "function(...{}) {}", | 7179 "function(...{}) {}", |
7202 "function(...{x}) {}", | 7180 "function(...{x}) {}", |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7544 "a, b, c = 1", | 7522 "a, b, c = 1", |
7545 "...args", | 7523 "...args", |
7546 "a, b, ...rest", | 7524 "a, b, ...rest", |
7547 "[a, b, ...rest]", | 7525 "[a, b, ...rest]", |
7548 "{ bindingPattern = {} }", | 7526 "{ bindingPattern = {} }", |
7549 "{ initializedBindingPattern } = { initializedBindingPattern: true }", | 7527 "{ initializedBindingPattern } = { initializedBindingPattern: true }", |
7550 NULL}; | 7528 NULL}; |
7551 | 7529 |
7552 static const ParserFlag always_flags[] = { | 7530 static const ParserFlag always_flags[] = { |
7553 kAllowHarmonyDefaultParameters, kAllowHarmonyDestructuring, | 7531 kAllowHarmonyDefaultParameters, kAllowHarmonyDestructuring, |
7554 kAllowHarmonyRestParameters, kAllowHarmonySloppy, kAllowStrongMode}; | 7532 kAllowHarmonySloppy, kAllowStrongMode}; |
7555 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7533 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
7556 arraysize(always_flags)); | 7534 arraysize(always_flags)); |
7557 } | 7535 } |
7558 | 7536 |
7559 | 7537 |
7560 TEST(LetSloppyOnly) { | 7538 TEST(LetSloppyOnly) { |
7561 // clang-format off | 7539 // clang-format off |
7562 const char* context_data[][2] = { | 7540 const char* context_data[][2] = { |
7563 {"", ""}, | 7541 {"", ""}, |
7564 {"{", "}"}, | 7542 {"{", "}"}, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7773 } | 7751 } |
7774 | 7752 |
7775 | 7753 |
7776 TEST(MiscSyntaxErrors) { | 7754 TEST(MiscSyntaxErrors) { |
7777 const char* context_data[][2] = { | 7755 const char* context_data[][2] = { |
7778 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7756 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
7779 const char* error_data[] = {"for (();;) {}", NULL}; | 7757 const char* error_data[] = {"for (();;) {}", NULL}; |
7780 | 7758 |
7781 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7759 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
7782 } | 7760 } |
OLD | NEW |