Chromium Code Reviews| 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 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 return result; | 1277 return result; |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 enum ParserFlag { | 1280 enum ParserFlag { |
| 1281 kAllowLazy, | 1281 kAllowLazy, |
| 1282 kAllowNatives, | 1282 kAllowNatives, |
| 1283 kAllowHarmonyFunctionSent, | 1283 kAllowHarmonyFunctionSent, |
| 1284 kAllowHarmonyRestrictiveGenerators, | 1284 kAllowHarmonyRestrictiveGenerators, |
| 1285 kAllowHarmonyTrailingCommas, | 1285 kAllowHarmonyTrailingCommas, |
| 1286 kAllowHarmonyClassFields, | 1286 kAllowHarmonyClassFields, |
| 1287 kAllowHarmonyObjectSpread, | 1287 kAllowHarmonyObjectRestSpread, |
| 1288 }; | 1288 }; |
| 1289 | 1289 |
| 1290 enum ParserSyncTestResult { | 1290 enum ParserSyncTestResult { |
| 1291 kSuccessOrError, | 1291 kSuccessOrError, |
| 1292 kSuccess, | 1292 kSuccess, |
| 1293 kError | 1293 kError |
| 1294 }; | 1294 }; |
| 1295 | 1295 |
| 1296 void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { | 1296 void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { |
| 1297 i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives); | 1297 i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives); |
| 1298 i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent); | 1298 i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent); |
| 1299 i::FLAG_harmony_restrictive_generators = | 1299 i::FLAG_harmony_restrictive_generators = |
| 1300 flags.Contains(kAllowHarmonyRestrictiveGenerators); | 1300 flags.Contains(kAllowHarmonyRestrictiveGenerators); |
| 1301 i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); | 1301 i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); |
| 1302 i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); | 1302 i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); |
| 1303 i::FLAG_harmony_object_spread = flags.Contains(kAllowHarmonyObjectSpread); | 1303 i::FLAG_harmony_object_rest_spread = |
| 1304 flags.Contains(kAllowHarmonyObjectRestSpread); | |
| 1304 } | 1305 } |
| 1305 | 1306 |
| 1306 void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { | 1307 void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
| 1307 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1308 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
| 1308 parser->set_allow_harmony_function_sent( | 1309 parser->set_allow_harmony_function_sent( |
| 1309 flags.Contains(kAllowHarmonyFunctionSent)); | 1310 flags.Contains(kAllowHarmonyFunctionSent)); |
| 1310 parser->set_allow_harmony_restrictive_generators( | 1311 parser->set_allow_harmony_restrictive_generators( |
| 1311 flags.Contains(kAllowHarmonyRestrictiveGenerators)); | 1312 flags.Contains(kAllowHarmonyRestrictiveGenerators)); |
| 1312 parser->set_allow_harmony_trailing_commas( | 1313 parser->set_allow_harmony_trailing_commas( |
| 1313 flags.Contains(kAllowHarmonyTrailingCommas)); | 1314 flags.Contains(kAllowHarmonyTrailingCommas)); |
| 1314 parser->set_allow_harmony_class_fields( | 1315 parser->set_allow_harmony_class_fields( |
| 1315 flags.Contains(kAllowHarmonyClassFields)); | 1316 flags.Contains(kAllowHarmonyClassFields)); |
| 1316 parser->set_allow_harmony_object_spread( | 1317 parser->set_allow_harmony_object_rest_spread( |
| 1317 flags.Contains(kAllowHarmonyObjectSpread)); | 1318 flags.Contains(kAllowHarmonyObjectRestSpread)); |
| 1318 } | 1319 } |
| 1319 | 1320 |
| 1320 void TestParserSyncWithFlags(i::Handle<i::String> source, | 1321 void TestParserSyncWithFlags(i::Handle<i::String> source, |
| 1321 i::EnumSet<ParserFlag> flags, | 1322 i::EnumSet<ParserFlag> flags, |
| 1322 ParserSyncTestResult result, | 1323 ParserSyncTestResult result, |
| 1323 bool is_module = false, | 1324 bool is_module = false, |
| 1324 bool test_preparser = true) { | 1325 bool test_preparser = true) { |
| 1325 i::Isolate* isolate = CcTest::i_isolate(); | 1326 i::Isolate* isolate = CcTest::i_isolate(); |
| 1326 i::Factory* factory = isolate->factory(); | 1327 i::Factory* factory = isolate->factory(); |
| 1327 | 1328 |
| (...skipping 5275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6603 "{ ...1}", | 6604 "{ ...1}", |
| 6604 "{ ...null}", | 6605 "{ ...null}", |
| 6605 "{ ...undefined}", | 6606 "{ ...undefined}", |
| 6606 "{ ...1 in {}}", | 6607 "{ ...1 in {}}", |
| 6607 "{ ...[]}", | 6608 "{ ...[]}", |
| 6608 "{ ...async function() { }}", | 6609 "{ ...async function() { }}", |
| 6609 "{ ...async () => { }}", | 6610 "{ ...async () => { }}", |
| 6610 "{ ...new Foo()}", | 6611 "{ ...new Foo()}", |
| 6611 NULL}; | 6612 NULL}; |
| 6612 | 6613 |
| 6613 static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; | 6614 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| 6614 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, | 6615 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| 6615 arraysize(flags)); | 6616 arraysize(flags)); |
| 6616 } | 6617 } |
| 6617 | 6618 |
| 6618 TEST(ObjectSpreadNegativeTests) { | 6619 TEST(ObjectSpreadNegativeTests) { |
| 6619 { | 6620 const char* context_data[][2] = {{"x = ", ""}, |
| 6620 const char* context_data[][2] = {{"x = ", ""}, | 6621 {"'use strict'; x = ", ""}, |
| 6621 {"'use strict'; x = ", ""}, | 6622 {NULL, NULL}}; |
| 6622 {NULL, NULL}}; | |
| 6623 | 6623 |
| 6624 // clang-format off | 6624 // clang-format off |
| 6625 const char* data[] = { | 6625 const char* data[] = { |
| 6626 "{ ...var z = y}", | 6626 "{ ...var z = y}", |
| 6627 "{ ...var}", | 6627 "{ ...var}", |
| 6628 "{ ...foo bar}", | 6628 "{ ...foo bar}", |
| 6629 NULL}; | 6629 NULL}; |
| 6630 | 6630 |
| 6631 static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; | 6631 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| 6632 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, | 6632 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| 6633 arraysize(flags)); | 6633 arraysize(flags)); |
| 6634 } | |
| 6635 | |
| 6636 // Destructuring tests | |
| 6637 { | |
| 6638 const char* context_data[][2] = { | |
| 6639 {"var ", " = {};"}, | |
| 6640 {"( ", " = {});"}, | |
| 6641 {"'use strict'; const ", " = {};"}, | |
| 6642 {"function f(", ") {}"}, | |
| 6643 {"function f(argument1, ", ") {}"}, | |
| 6644 {"var f = (", ") => {};"}, | |
| 6645 {"var f = (argument1,", ") => {};"}, | |
| 6646 {"try {} catch(", ") {}"}, | |
| 6647 {NULL, NULL}}; | |
| 6648 | |
| 6649 // clang-format off | |
| 6650 const char* data[] = { | |
| 6651 "{ ...y }", | |
| 6652 "{ a: 1, ...y }", | |
| 6653 "{ b: 1, ...y }", | |
| 6654 "{ y, ...y}", | |
| 6655 "{ ...z = y}", | |
| 6656 "{ ...y, y }", | |
| 6657 "{ ...y, ...y}", | |
| 6658 "{ a: 1, ...y, b: 1}", | |
| 6659 "{ ...y, b: 1}", | |
| 6660 "{ ...1}", | |
| 6661 "{ ...null}", | |
| 6662 "{ ...undefined}", | |
| 6663 "{ ...unknown}", | |
| 6664 "{ ...var z = y}", | |
| 6665 "({ ...z = {})", | |
| 6666 NULL}; | |
| 6667 | |
| 6668 static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; | |
| 6669 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, | |
| 6670 arraysize(flags)); | |
| 6671 } | |
| 6672 } | 6634 } |
| 6673 | 6635 |
| 6674 TEST(DestructuringPositiveTests) { | 6636 TEST(DestructuringPositiveTests) { |
| 6675 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6637 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6676 {"var ", " = {};"}, | 6638 {"var ", " = {};"}, |
| 6677 {"'use strict'; const ", " = {};"}, | 6639 {"'use strict'; const ", " = {};"}, |
| 6678 {"function f(", ") {}"}, | 6640 {"function f(", ") {}"}, |
| 6679 {"function f(argument1, ", ") {}"}, | 6641 {"function f(argument1, ", ") {}"}, |
| 6680 {"var f = (", ") => {};"}, | 6642 {"var f = (", ") => {};"}, |
| 6681 {"var f = (argument1,", ") => {};"}, | 6643 {"var f = (argument1,", ") => {};"}, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 6693 "[a = 1]", | 6655 "[a = 1]", |
| 6694 "[a,b,c]", | 6656 "[a,b,c]", |
| 6695 "[a, b = 42, c]", | 6657 "[a, b = 42, c]", |
| 6696 "{ x : x, y : y }", | 6658 "{ x : x, y : y }", |
| 6697 "{ x : x = 1, y : y }", | 6659 "{ x : x = 1, y : y }", |
| 6698 "{ x : x, y : y = 42 }", | 6660 "{ x : x, y : y = 42 }", |
| 6699 "[]", | 6661 "[]", |
| 6700 "{}", | 6662 "{}", |
| 6701 "[{x:x, y:y}, [a,b,c]]", | 6663 "[{x:x, y:y}, [a,b,c]]", |
| 6702 "[{x:x = 1, y:y = 2}, [a = 3, b = 4, c = 5]]", | 6664 "[{x:x = 1, y:y = 2}, [a = 3, b = 4, c = 5]]", |
| 6703 "{x}", | |
|
adamk
2017/01/17 19:56:33
Why did this get deleted?
gsathya
2017/01/17 21:59:23
Done.
| |
| 6704 "{x, y}", | 6665 "{x, y}", |
| 6705 "{x = 42, y = 15}", | 6666 "{x = 42, y = 15}", |
| 6706 "[a,,b]", | 6667 "[a,,b]", |
| 6707 "{42 : x}", | 6668 "{42 : x}", |
| 6708 "{42 : x = 42}", | 6669 "{42 : x = 42}", |
| 6709 "{42e-2 : x}", | 6670 "{42e-2 : x}", |
| 6710 "{42e-2 : x = 42}", | 6671 "{42e-2 : x = 42}", |
| 6711 "{x : y, x : z}", | 6672 "{x : y, x : z}", |
| 6712 "{'hi' : x}", | 6673 "{'hi' : x}", |
| 6713 "{'hi' : x = 42}", | 6674 "{'hi' : x = 42}", |
| 6714 "{var: x}", | 6675 "{var: x}", |
| 6715 "{var: x = 42}", | 6676 "{var: x = 42}", |
| 6716 "{[x] : z}", | 6677 "{[x] : z}", |
| 6717 "{[1+1] : z}", | 6678 "{[1+1] : z}", |
| 6718 "{[foo()] : z}", | 6679 "{[foo()] : z}", |
| 6719 "{}", | 6680 "{}", |
| 6720 "[...rest]", | 6681 "[...rest]", |
| 6721 "[a,b,...rest]", | 6682 "[a,b,...rest]", |
| 6722 "[a,,...rest]", | 6683 "[a,,...rest]", |
| 6723 "{ __proto__: x, __proto__: y}", | 6684 "{ __proto__: x, __proto__: y}", |
| 6724 "{arguments: x}", | 6685 "{arguments: x}", |
| 6725 "{eval: x}", | 6686 "{eval: x}", |
| 6726 NULL}; | 6687 NULL}; |
| 6688 | |
| 6689 const char* rest_data[] = { | |
| 6690 "{ x : y, ...z }", | |
| 6691 "{ x : y = 1, ...z }", | |
| 6692 "{ x : x, y : y, ...z }", | |
| 6693 "{ x : x = 1, y : y, ...z }", | |
| 6694 "{ x : x, y : y = 42, ...z }", | |
| 6695 "[{x:x, y:y, ...z}, [a,b,c]]", | |
| 6696 "[{x:x = 1, y:y = 2, ...z}, [a = 3, b = 4, c = 5]]", | |
| 6697 "{...x}", | |
| 6698 "{...{ x = 5} }", | |
| 6699 "{x, ...y}", | |
| 6700 "{x = 42, y = 15, ...z}", | |
| 6701 "{42 : x = 42, ...y}", | |
| 6702 "{'hi' : x, ...z}", | |
| 6703 "{'hi' : x = 42, ...z}", | |
| 6704 "{var: x = 42, ...z}", | |
| 6705 "{[x] : z, ...y}", | |
| 6706 "{[1+1] : z, ...x}", | |
| 6707 "{arguments: x, ...z}", | |
| 6708 "{ __proto__: x, __proto__: y, ...z}", | |
| 6709 NULL}; | |
| 6710 | |
| 6727 // clang-format on | 6711 // clang-format on |
| 6728 RunParserSyncTest(context_data, data, kSuccess); | 6712 RunParserSyncTest(context_data, data, kSuccess); |
| 6713 RunParserSyncTest(context_data, rest_data, kError); | |
| 6714 | |
| 6715 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; | |
| 6716 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, | |
| 6717 arraysize(flags)); | |
| 6718 RunParserSyncTest(context_data, rest_data, kSuccess, NULL, 0, flags, | |
| 6719 arraysize(flags)); | |
| 6729 | 6720 |
| 6730 // v8:5201 | 6721 // v8:5201 |
| 6731 { | 6722 { |
| 6732 // clang-format off | 6723 // clang-format off |
| 6733 const char* sloppy_context_data[][2] = { | 6724 const char* sloppy_context_data[][2] = { |
| 6734 {"var ", " = {};"}, | 6725 {"var ", " = {};"}, |
| 6735 {"function f(", ") {}"}, | 6726 {"function f(", ") {}"}, |
| 6736 {"function f(argument1, ", ") {}"}, | 6727 {"function f(argument1, ", ") {}"}, |
| 6737 {"var f = (", ") => {};"}, | 6728 {"var f = (", ") => {};"}, |
| 6738 {"var f = (argument1,", ") => {};"}, | 6729 {"var f = (argument1,", ") => {};"}, |
| 6739 {"try {} catch(", ") {}"}, | 6730 {"try {} catch(", ") {}"}, |
| 6740 {NULL, NULL} | 6731 {NULL, NULL} |
| 6741 }; | 6732 }; |
| 6733 | |
| 6734 const char* rest_data[] = { | |
| 6735 "{...arguments}", | |
| 6736 "{...eval}", | |
| 6737 NULL | |
| 6738 }; | |
| 6739 | |
| 6742 const char* data[] = { | 6740 const char* data[] = { |
| 6743 "{arguments}", | 6741 "{arguments}", |
| 6744 "{eval}", | 6742 "{eval}", |
| 6745 "{x: arguments}", | 6743 "{x: arguments}", |
| 6746 "{x: eval}", | 6744 "{x: eval}", |
| 6747 "{arguments = false}", | 6745 "{arguments = false}", |
| 6748 "{eval = false}", | 6746 "{eval = false}", |
| 6749 NULL | 6747 NULL |
| 6750 }; | 6748 }; |
| 6751 // clang-format on | 6749 // clang-format on |
| 6752 RunParserSyncTest(sloppy_context_data, data, kSuccess); | 6750 RunParserSyncTest(sloppy_context_data, data, kSuccess); |
| 6751 RunParserSyncTest(sloppy_context_data, rest_data, kError); | |
| 6752 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; | |
| 6753 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, flags, | |
| 6754 arraysize(flags)); | |
| 6755 RunParserSyncTest(sloppy_context_data, rest_data, kSuccess, NULL, 0, flags, | |
| 6756 arraysize(flags)); | |
| 6753 } | 6757 } |
| 6754 } | 6758 } |
| 6755 | 6759 |
| 6756 | 6760 |
| 6757 TEST(DestructuringNegativeTests) { | 6761 TEST(DestructuringNegativeTests) { |
| 6758 { // All modes. | 6762 { // All modes. |
| 6759 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6763 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6760 {"var ", " = {};"}, | 6764 {"var ", " = {};"}, |
| 6761 {"'use strict'; const ", " = {};"}, | 6765 {"'use strict'; const ", " = {};"}, |
| 6762 {"function f(", ") {}"}, | 6766 {"function f(", ") {}"}, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6831 "[...[z] = [1]]", | 6835 "[...[z] = [1]]", |
| 6832 "{ x : 3 }", | 6836 "{ x : 3 }", |
| 6833 "{ x : 'foo' }", | 6837 "{ x : 'foo' }", |
| 6834 "{ x : /foo/ }", | 6838 "{ x : /foo/ }", |
| 6835 "{ x : `foo` }", | 6839 "{ x : `foo` }", |
| 6836 "{ get a() {} }", | 6840 "{ get a() {} }", |
| 6837 "{ set a() {} }", | 6841 "{ set a() {} }", |
| 6838 "{ method() {} }", | 6842 "{ method() {} }", |
| 6839 "{ *method() {} }", | 6843 "{ *method() {} }", |
| 6840 NULL}; | 6844 NULL}; |
| 6845 | |
| 6846 const char* rest_data[] = { | |
| 6847 "...a++", | |
| 6848 "...++a", | |
| 6849 "...typeof a", | |
| 6850 "...[a++]", | |
| 6851 "...(x => y)", | |
| 6852 "{ ...x, }", | |
| 6853 "{ ...x, y }", | |
| 6854 "{ y, ...x, y }", | |
| 6855 "{ ...x, ...y }", | |
| 6856 "{ ...x, ...x }", | |
| 6857 "{ ...x, ...x = {} }", | |
| 6858 "{ ...x, ...x = ...x }", | |
| 6859 "{ ...x, ...x = ...{ x } }", | |
| 6860 "{ ,, ...x }", | |
| 6861 "{ ...get a() {} }", | |
| 6862 "{ ...set a() {} }", | |
| 6863 "{ ...method() {} }", | |
| 6864 "{ ...function() {} }", | |
| 6865 "{ ...*method() {} }", | |
| 6866 NULL | |
| 6867 }; | |
| 6868 | |
| 6841 // clang-format on | 6869 // clang-format on |
| 6842 RunParserSyncTest(context_data, data, kError); | 6870 RunParserSyncTest(context_data, data, kError); |
| 6871 RunParserSyncTest(context_data, rest_data, kError); | |
| 6872 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; | |
| 6873 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, | |
| 6874 arraysize(flags)); | |
| 6875 RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, | |
| 6876 arraysize(flags)); | |
| 6843 } | 6877 } |
| 6844 | 6878 |
| 6845 { // All modes. | 6879 { // All modes. |
| 6846 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6880 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6847 {"var ", " = {};"}, | 6881 {"var ", " = {};"}, |
| 6848 {"'use strict'; const ", " = {};"}, | 6882 {"'use strict'; const ", " = {};"}, |
| 6849 {"function f(", ") {}"}, | 6883 {"function f(", ") {}"}, |
| 6850 {"function f(argument1, ", ") {}"}, | 6884 {"function f(argument1, ", ") {}"}, |
| 6851 {"var f = (", ") => {};"}, | 6885 {"var f = (", ") => {};"}, |
| 6852 {"var f = (argument1,", ") => {};"}, | 6886 {"var f = (argument1,", ") => {};"}, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 6878 "{ a : eval }", | 6912 "{ a : eval }", |
| 6879 "[public]", | 6913 "[public]", |
| 6880 "{ x : private }", | 6914 "{ x : private }", |
| 6881 "{ x : arguments }", | 6915 "{ x : arguments }", |
| 6882 "{ x : eval }", | 6916 "{ x : eval }", |
| 6883 "{ arguments }", | 6917 "{ arguments }", |
| 6884 "{ eval }", | 6918 "{ eval }", |
| 6885 "{ arguments = false }" | 6919 "{ arguments = false }" |
| 6886 "{ eval = false }", | 6920 "{ eval = false }", |
| 6887 NULL}; | 6921 NULL}; |
| 6922 | |
| 6923 const char* rest_data[] = { | |
| 6924 "{ ...eval }", | |
| 6925 "{ ...arguments }", | |
| 6926 NULL}; | |
| 6927 | |
| 6888 // clang-format on | 6928 // clang-format on |
| 6889 RunParserSyncTest(context_data, data, kError); | 6929 RunParserSyncTest(context_data, data, kError); |
| 6930 RunParserSyncTest(context_data, rest_data, kError); | |
| 6931 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; | |
| 6932 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, | |
| 6933 arraysize(flags)); | |
| 6934 RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, | |
| 6935 arraysize(flags)); | |
| 6890 } | 6936 } |
| 6891 | 6937 |
| 6892 { // 'yield' in generators. | 6938 { // 'yield' in generators. |
| 6893 const char* context_data[][2] = { | 6939 const char* context_data[][2] = { |
| 6894 {"function*() { var ", " = {};"}, | 6940 {"function*() { var ", " = {};"}, |
| 6895 {"function*() { 'use strict'; let ", " = {};"}, | 6941 {"function*() { 'use strict'; let ", " = {};"}, |
| 6896 {"function*() { 'use strict'; const ", " = {};"}, | 6942 {"function*() { 'use strict'; const ", " = {};"}, |
| 6897 {NULL, NULL}}; | 6943 {NULL, NULL}}; |
| 6898 | 6944 |
| 6899 // clang-format off | 6945 // clang-format off |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 6919 {"for (var ", ";;) {}"}, | 6965 {"for (var ", ";;) {}"}, |
| 6920 {"for (let ", ";;) {}"}, | 6966 {"for (let ", ";;) {}"}, |
| 6921 {"for (const ", ";;) {}"}, | 6967 {"for (const ", ";;) {}"}, |
| 6922 {NULL, NULL}}; | 6968 {NULL, NULL}}; |
| 6923 | 6969 |
| 6924 // clang-format off | 6970 // clang-format off |
| 6925 const char* data[] = { | 6971 const char* data[] = { |
| 6926 "{ a }", | 6972 "{ a }", |
| 6927 "[ a ]", | 6973 "[ a ]", |
| 6928 NULL}; | 6974 NULL}; |
| 6975 const char* rest_data[] = { | |
| 6976 "{ ...a }", | |
| 6977 NULL}; | |
| 6929 // clang-format on | 6978 // clang-format on |
| 6930 RunParserSyncTest(context_data, data, kError); | 6979 RunParserSyncTest(context_data, data, kError); |
| 6980 RunParserSyncTest(context_data, rest_data, kError); | |
| 6981 static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; | |
| 6982 RunParserSyncTest(context_data, data, kError, NULL, 0, flags, | |
| 6983 arraysize(flags)); | |
| 6984 RunParserSyncTest(context_data, rest_data, kError, NULL, 0, flags, | |
| 6985 arraysize(flags)); | |
| 6931 } | 6986 } |
| 6932 } | 6987 } |
| 6933 | 6988 |
| 6934 | 6989 |
| 6935 TEST(DestructuringAssignmentPositiveTests) { | 6990 TEST(DestructuringAssignmentPositiveTests) { |
| 6936 const char* context_data[][2] = { | 6991 const char* context_data[][2] = { |
| 6937 {"'use strict'; let x, y, z; (", " = {});"}, | 6992 {"'use strict'; let x, y, z; (", " = {});"}, |
| 6938 {"var x, y, z; (", " = {});"}, | 6993 {"var x, y, z; (", " = {});"}, |
| 6939 {"'use strict'; let x, y, z; for (x in ", " = {});"}, | 6994 {"'use strict'; let x, y, z; for (x in ", " = {});"}, |
| 6940 {"'use strict'; let x, y, z; for (x of ", " = {});"}, | 6995 {"'use strict'; let x, y, z; for (x of ", " = {});"}, |
| (...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8885 DCHECK_NULL(scope->sibling()); | 8940 DCHECK_NULL(scope->sibling()); |
| 8886 DCHECK(scope->is_function_scope()); | 8941 DCHECK(scope->is_function_scope()); |
| 8887 const i::AstRawString* var_name = | 8942 const i::AstRawString* var_name = |
| 8888 info.ast_value_factory()->GetOneByteString("my_var"); | 8943 info.ast_value_factory()->GetOneByteString("my_var"); |
| 8889 i::Variable* var = scope->Lookup(var_name); | 8944 i::Variable* var = scope->Lookup(var_name); |
| 8890 CHECK_EQ(inners[i].ctxt_allocate, | 8945 CHECK_EQ(inners[i].ctxt_allocate, |
| 8891 i::ScopeTestHelper::MustAllocateInContext(var)); | 8946 i::ScopeTestHelper::MustAllocateInContext(var)); |
| 8892 } | 8947 } |
| 8893 } | 8948 } |
| 8894 } | 8949 } |
| OLD | NEW |