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 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 | 1550 |
1551 data.Dispose(); | 1551 data.Dispose(); |
1552 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); | 1552 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); |
1553 } | 1553 } |
1554 | 1554 |
1555 enum ParserFlag { | 1555 enum ParserFlag { |
1556 kAllowLazy, | 1556 kAllowLazy, |
1557 kAllowNatives, | 1557 kAllowNatives, |
1558 kAllowHarmonyFunctionSent, | 1558 kAllowHarmonyFunctionSent, |
1559 kAllowHarmonyRestrictiveDeclarations, | 1559 kAllowHarmonyRestrictiveDeclarations, |
1560 kAllowHarmonyExponentiationOperator, | |
1561 kAllowHarmonyForIn, | 1560 kAllowHarmonyForIn, |
1562 kAllowHarmonyAsyncAwait, | 1561 kAllowHarmonyAsyncAwait, |
1563 kAllowHarmonyRestrictiveGenerators, | 1562 kAllowHarmonyRestrictiveGenerators, |
1564 kAllowHarmonyTrailingCommas, | 1563 kAllowHarmonyTrailingCommas, |
1565 }; | 1564 }; |
1566 | 1565 |
1567 enum ParserSyncTestResult { | 1566 enum ParserSyncTestResult { |
1568 kSuccessOrError, | 1567 kSuccessOrError, |
1569 kSuccess, | 1568 kSuccess, |
1570 kError | 1569 kError |
1571 }; | 1570 }; |
1572 | 1571 |
1573 template <typename Traits> | 1572 template <typename Traits> |
1574 void SetParserFlags(i::ParserBase<Traits>* parser, | 1573 void SetParserFlags(i::ParserBase<Traits>* parser, |
1575 i::EnumSet<ParserFlag> flags) { | 1574 i::EnumSet<ParserFlag> flags) { |
1576 parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 1575 parser->set_allow_lazy(flags.Contains(kAllowLazy)); |
1577 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1576 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
1578 parser->set_allow_harmony_function_sent( | 1577 parser->set_allow_harmony_function_sent( |
1579 flags.Contains(kAllowHarmonyFunctionSent)); | 1578 flags.Contains(kAllowHarmonyFunctionSent)); |
1580 parser->set_allow_harmony_restrictive_declarations( | 1579 parser->set_allow_harmony_restrictive_declarations( |
1581 flags.Contains(kAllowHarmonyRestrictiveDeclarations)); | 1580 flags.Contains(kAllowHarmonyRestrictiveDeclarations)); |
1582 parser->set_allow_harmony_exponentiation_operator( | |
1583 flags.Contains(kAllowHarmonyExponentiationOperator)); | |
1584 parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn)); | 1581 parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn)); |
1585 parser->set_allow_harmony_async_await( | 1582 parser->set_allow_harmony_async_await( |
1586 flags.Contains(kAllowHarmonyAsyncAwait)); | 1583 flags.Contains(kAllowHarmonyAsyncAwait)); |
1587 parser->set_allow_harmony_restrictive_generators( | 1584 parser->set_allow_harmony_restrictive_generators( |
1588 flags.Contains(kAllowHarmonyRestrictiveGenerators)); | 1585 flags.Contains(kAllowHarmonyRestrictiveGenerators)); |
1589 parser->set_allow_harmony_trailing_commas( | 1586 parser->set_allow_harmony_trailing_commas( |
1590 flags.Contains(kAllowHarmonyTrailingCommas)); | 1587 flags.Contains(kAllowHarmonyTrailingCommas)); |
1591 } | 1588 } |
1592 | 1589 |
1593 | 1590 |
(...skipping 5869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7463 "--O.p ** 10", | 7460 "--O.p ** 10", |
7464 "--x ** 10", | 7461 "--x ** 10", |
7465 "O.p++ ** 10", | 7462 "O.p++ ** 10", |
7466 "x++ ** 10", | 7463 "x++ ** 10", |
7467 "O.p-- ** 10", | 7464 "O.p-- ** 10", |
7468 "x-- ** 10", | 7465 "x-- ** 10", |
7469 NULL | 7466 NULL |
7470 }; | 7467 }; |
7471 // clang-format on | 7468 // clang-format on |
7472 | 7469 |
7473 static const ParserFlag always_flags[] = { | 7470 RunParserSyncTest(context_data, data, kSuccess); |
7474 kAllowHarmonyExponentiationOperator}; | |
7475 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | |
7476 arraysize(always_flags)); | |
7477 } | 7471 } |
7478 | 7472 |
7479 TEST(ExponentiationOperatorErrors) { | 7473 TEST(ExponentiationOperatorErrors) { |
7480 // clang-format off | 7474 // clang-format off |
7481 const char* context_data[][2] = { | 7475 const char* context_data[][2] = { |
7482 { "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" }, | 7476 { "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" }, |
7483 { "var O = { p: 1 }, x = 10; ; (", ")" }, | 7477 { "var O = { p: 1 }, x = 10; ; (", ")" }, |
7484 { "var O = { p: 1 }, x = 10; foo(", ")" }, | 7478 { "var O = { p: 1 }, x = 10; foo(", ")" }, |
7485 { NULL, NULL } | 7479 { NULL, NULL } |
7486 }; | 7480 }; |
(...skipping 26 matching lines...) Expand all Loading... |
7513 "[ x ] **= [ 2 ]", | 7507 "[ x ] **= [ 2 ]", |
7514 "[ x **= 2 ] = [ 2 ]", | 7508 "[ x **= 2 ] = [ 2 ]", |
7515 "{ x } **= { x: 2 }", | 7509 "{ x } **= { x: 2 }", |
7516 "{ x: x **= 2 ] = { x: 2 }", | 7510 "{ x: x **= 2 ] = { x: 2 }", |
7517 // TODO(caitp): a Call expression as LHS should be an early ReferenceError! | 7511 // TODO(caitp): a Call expression as LHS should be an early ReferenceError! |
7518 // "Array() **= 10", | 7512 // "Array() **= 10", |
7519 NULL | 7513 NULL |
7520 }; | 7514 }; |
7521 // clang-format on | 7515 // clang-format on |
7522 | 7516 |
7523 static const ParserFlag always_flags[] = { | 7517 RunParserSyncTest(context_data, error_data, kError); |
7524 kAllowHarmonyExponentiationOperator}; | |
7525 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | |
7526 arraysize(always_flags)); | |
7527 } | 7518 } |
7528 | 7519 |
7529 TEST(AsyncAwait) { | 7520 TEST(AsyncAwait) { |
7530 // clang-format off | 7521 // clang-format off |
7531 const char* context_data[][2] = { | 7522 const char* context_data[][2] = { |
7532 { "'use strict';", "" }, | 7523 { "'use strict';", "" }, |
7533 { "", "" }, | 7524 { "", "" }, |
7534 { NULL, NULL } | 7525 { NULL, NULL } |
7535 }; | 7526 }; |
7536 | 7527 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7986 "(a,);", | 7977 "(a,);", |
7987 "(a,b,c,);", | 7978 "(a,b,c,);", |
7988 NULL | 7979 NULL |
7989 }; | 7980 }; |
7990 // clang-format on | 7981 // clang-format on |
7991 | 7982 |
7992 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 7983 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
7993 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7984 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
7994 arraysize(always_flags)); | 7985 arraysize(always_flags)); |
7995 } | 7986 } |
OLD | NEW |