Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 1450193002: Rename destructuring flag to "--harmony-destructuring-bind" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/preparser.cc ('k') | test/message/destructuring-decl-no-init-array.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 void SetParserFlags(i::ParserBase<Traits>* parser, 1516 void SetParserFlags(i::ParserBase<Traits>* parser,
1517 i::EnumSet<ParserFlag> flags) { 1517 i::EnumSet<ParserFlag> flags) {
1518 parser->set_allow_lazy(flags.Contains(kAllowLazy)); 1518 parser->set_allow_lazy(flags.Contains(kAllowLazy));
1519 parser->set_allow_natives(flags.Contains(kAllowNatives)); 1519 parser->set_allow_natives(flags.Contains(kAllowNatives));
1520 parser->set_allow_harmony_default_parameters( 1520 parser->set_allow_harmony_default_parameters(
1521 flags.Contains(kAllowHarmonyDefaultParameters)); 1521 flags.Contains(kAllowHarmonyDefaultParameters));
1522 parser->set_allow_harmony_rest_parameters( 1522 parser->set_allow_harmony_rest_parameters(
1523 flags.Contains(kAllowHarmonyRestParameters)); 1523 flags.Contains(kAllowHarmonyRestParameters));
1524 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); 1524 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
1525 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet)); 1525 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet));
1526 parser->set_allow_harmony_destructuring( 1526 parser->set_allow_harmony_destructuring_bind(
1527 flags.Contains(kAllowHarmonyDestructuring)); 1527 flags.Contains(kAllowHarmonyDestructuring));
1528 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); 1528 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
1529 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); 1529 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst));
1530 } 1530 }
1531 1531
1532 1532
1533 void TestParserSyncWithFlags(i::Handle<i::String> source, 1533 void TestParserSyncWithFlags(i::Handle<i::String> source,
1534 i::EnumSet<ParserFlag> flags, 1534 i::EnumSet<ParserFlag> flags,
1535 ParserSyncTestResult result) { 1535 ParserSyncTestResult result) {
1536 i::Isolate* isolate = CcTest::i_isolate(); 1536 i::Isolate* isolate = CcTest::i_isolate();
(...skipping 5002 matching lines...) Expand 10 before | Expand all | Expand 10 after
6539 CHECK_EQ(0, 6539 CHECK_EQ(0,
6540 strcmp( 6540 strcmp(
6541 "ReferenceError: In strong mode, using an undeclared global " 6541 "ReferenceError: In strong mode, using an undeclared global "
6542 "variable 'not_there3' is not allowed", 6542 "variable 'not_there3' is not allowed",
6543 *exception)); 6543 *exception));
6544 } 6544 }
6545 } 6545 }
6546 6546
6547 6547
6548 TEST(DestructuringPositiveTests) { 6548 TEST(DestructuringPositiveTests) {
6549 i::FLAG_harmony_destructuring = true; 6549 i::FLAG_harmony_destructuring_bind = true;
6550 6550
6551 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6551 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6552 {"var ", " = {};"}, 6552 {"var ", " = {};"},
6553 {"'use strict'; const ", " = {};"}, 6553 {"'use strict'; const ", " = {};"},
6554 {"function f(", ") {}"}, 6554 {"function f(", ") {}"},
6555 {"function f(argument1, ", ") {}"}, 6555 {"function f(argument1, ", ") {}"},
6556 {"var f = (", ") => {};"}, 6556 {"var f = (", ") => {};"},
6557 {"var f = (argument1,", ") => {};"}, 6557 {"var f = (argument1,", ") => {};"},
6558 {"try {} catch(", ") {}"}, 6558 {"try {} catch(", ") {}"},
6559 {NULL, NULL}}; 6559 {NULL, NULL}};
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6598 "[a,,...rest]", 6598 "[a,,...rest]",
6599 NULL}; 6599 NULL};
6600 // clang-format on 6600 // clang-format on
6601 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6601 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6602 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, 6602 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6603 arraysize(always_flags)); 6603 arraysize(always_flags));
6604 } 6604 }
6605 6605
6606 6606
6607 TEST(DestructuringNegativeTests) { 6607 TEST(DestructuringNegativeTests) {
6608 i::FLAG_harmony_destructuring = true; 6608 i::FLAG_harmony_destructuring_bind = true;
6609 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6609 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6610 6610
6611 { // All modes. 6611 { // All modes.
6612 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6612 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6613 {"var ", " = {};"}, 6613 {"var ", " = {};"},
6614 {"'use strict'; const ", " = {};"}, 6614 {"'use strict'; const ", " = {};"},
6615 {"function f(", ") {}"}, 6615 {"function f(", ") {}"},
6616 {"function f(argument1, ", ") {}"}, 6616 {"function f(argument1, ", ") {}"},
6617 {"var f = (", ") => {};"}, 6617 {"var f = (", ") => {};"},
6618 {"var f = ", " => {};"}, 6618 {"var f = ", " => {};"},
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
6769 // clang-format on 6769 // clang-format on
6770 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring, 6770 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring,
6771 kAllowHarmonySloppyLet}; 6771 kAllowHarmonySloppyLet};
6772 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6772 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6773 arraysize(always_flags)); 6773 arraysize(always_flags));
6774 } 6774 }
6775 } 6775 }
6776 6776
6777 6777
6778 TEST(DestructuringDisallowPatternsInForVarIn) { 6778 TEST(DestructuringDisallowPatternsInForVarIn) {
6779 i::FLAG_harmony_destructuring = true; 6779 i::FLAG_harmony_destructuring_bind = true;
6780 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6780 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6781 const char* context_data[][2] = { 6781 const char* context_data[][2] = {
6782 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; 6782 {"", ""}, {"function f() {", "}"}, {NULL, NULL}};
6783 // clang-format off 6783 // clang-format off
6784 const char* error_data[] = { 6784 const char* error_data[] = {
6785 "for (let x = {} in null);", 6785 "for (let x = {} in null);",
6786 "for (let x = {} of null);", 6786 "for (let x = {} of null);",
6787 NULL}; 6787 NULL};
6788 // clang-format on 6788 // clang-format on
6789 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 6789 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6790 arraysize(always_flags)); 6790 arraysize(always_flags));
6791 6791
6792 // clang-format off 6792 // clang-format off
6793 const char* success_data[] = { 6793 const char* success_data[] = {
6794 "for (var x = {} in null);", 6794 "for (var x = {} in null);",
6795 NULL}; 6795 NULL};
6796 // clang-format on 6796 // clang-format on
6797 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, 6797 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags,
6798 arraysize(always_flags)); 6798 arraysize(always_flags));
6799 } 6799 }
6800 6800
6801 6801
6802 TEST(DestructuringDuplicateParams) { 6802 TEST(DestructuringDuplicateParams) {
6803 i::FLAG_harmony_destructuring = true; 6803 i::FLAG_harmony_destructuring_bind = true;
6804 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6804 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6805 const char* context_data[][2] = {{"'use strict';", ""}, 6805 const char* context_data[][2] = {{"'use strict';", ""},
6806 {"function outer() { 'use strict';", "}"}, 6806 {"function outer() { 'use strict';", "}"},
6807 {nullptr, nullptr}}; 6807 {nullptr, nullptr}};
6808 6808
6809 6809
6810 // clang-format off 6810 // clang-format off
6811 const char* error_data[] = { 6811 const char* error_data[] = {
6812 "function f(x,x){}", 6812 "function f(x,x){}",
6813 "function f(x, {x : x}){}", 6813 "function f(x, {x : x}){}",
6814 "function f(x, {x}){}", 6814 "function f(x, {x}){}",
6815 "function f({x,x}) {}", 6815 "function f({x,x}) {}",
6816 "function f([x,x]) {}", 6816 "function f([x,x]) {}",
6817 "function f(x, [y,{z:x}]) {}", 6817 "function f(x, [y,{z:x}]) {}",
6818 "function f([x,{y:x}]) {}", 6818 "function f([x,{y:x}]) {}",
6819 // non-simple parameter list causes duplicates to be errors in sloppy mode. 6819 // non-simple parameter list causes duplicates to be errors in sloppy mode.
6820 "function f(x, x, {a}) {}", 6820 "function f(x, x, {a}) {}",
6821 nullptr}; 6821 nullptr};
6822 // clang-format on 6822 // clang-format on
6823 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 6823 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6824 arraysize(always_flags)); 6824 arraysize(always_flags));
6825 } 6825 }
6826 6826
6827 6827
6828 TEST(DestructuringDuplicateParamsSloppy) { 6828 TEST(DestructuringDuplicateParamsSloppy) {
6829 i::FLAG_harmony_destructuring = true; 6829 i::FLAG_harmony_destructuring_bind = true;
6830 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6830 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6831 const char* context_data[][2] = { 6831 const char* context_data[][2] = {
6832 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; 6832 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}};
6833 6833
6834 6834
6835 // clang-format off 6835 // clang-format off
6836 const char* error_data[] = { 6836 const char* error_data[] = {
6837 // non-simple parameter list causes duplicates to be errors in sloppy mode. 6837 // non-simple parameter list causes duplicates to be errors in sloppy mode.
6838 "function f(x, {x : x}){}", 6838 "function f(x, {x : x}){}",
6839 "function f(x, {x}){}", 6839 "function f(x, {x}){}",
6840 "function f({x,x}) {}", 6840 "function f({x,x}) {}",
6841 "function f(x, x, {a}) {}", 6841 "function f(x, x, {a}) {}",
6842 nullptr}; 6842 nullptr};
6843 // clang-format on 6843 // clang-format on
6844 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 6844 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6845 arraysize(always_flags)); 6845 arraysize(always_flags));
6846 } 6846 }
6847 6847
6848 6848
6849 TEST(DestructuringDisallowPatternsInSingleParamArrows) { 6849 TEST(DestructuringDisallowPatternsInSingleParamArrows) {
6850 i::FLAG_harmony_destructuring = true; 6850 i::FLAG_harmony_destructuring_bind = true;
6851 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6851 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6852 const char* context_data[][2] = {{"'use strict';", ""}, 6852 const char* context_data[][2] = {{"'use strict';", ""},
6853 {"function outer() { 'use strict';", "}"}, 6853 {"function outer() { 'use strict';", "}"},
6854 {"", ""}, 6854 {"", ""},
6855 {"function outer() { ", "}"}, 6855 {"function outer() { ", "}"},
6856 {nullptr, nullptr}}; 6856 {nullptr, nullptr}};
6857 6857
6858 // clang-format off 6858 // clang-format off
6859 const char* error_data[] = { 6859 const char* error_data[] = {
6860 "var f = {x} => {};", 6860 "var f = {x} => {};",
6861 "var f = {x,y} => {};", 6861 "var f = {x,y} => {};",
6862 nullptr}; 6862 nullptr};
6863 // clang-format on 6863 // clang-format on
6864 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 6864 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6865 arraysize(always_flags)); 6865 arraysize(always_flags));
6866 } 6866 }
6867 6867
6868 6868
6869 TEST(DestructuringDisallowPatternsInRestParams) { 6869 TEST(DestructuringDisallowPatternsInRestParams) {
6870 i::FLAG_harmony_destructuring = true; 6870 i::FLAG_harmony_destructuring_bind = true;
6871 i::FLAG_harmony_rest_parameters = true; 6871 i::FLAG_harmony_rest_parameters = true;
6872 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters, 6872 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters,
6873 kAllowHarmonyDestructuring}; 6873 kAllowHarmonyDestructuring};
6874 const char* context_data[][2] = {{"'use strict';", ""}, 6874 const char* context_data[][2] = {{"'use strict';", ""},
6875 {"function outer() { 'use strict';", "}"}, 6875 {"function outer() { 'use strict';", "}"},
6876 {"", ""}, 6876 {"", ""},
6877 {"function outer() { ", "}"}, 6877 {"function outer() { ", "}"},
6878 {nullptr, nullptr}}; 6878 {nullptr, nullptr}};
6879 6879
6880 // clang-format off 6880 // clang-format off
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
7298 NULL 7298 NULL
7299 }; 7299 };
7300 // clang-format on 7300 // clang-format on
7301 7301
7302 static const ParserFlag fail_flags[] = { 7302 static const ParserFlag fail_flags[] = {
7303 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst, 7303 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst,
7304 kAllowHarmonyDestructuring}; 7304 kAllowHarmonyDestructuring};
7305 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags, 7305 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags,
7306 arraysize(fail_flags)); 7306 arraysize(fail_flags));
7307 } 7307 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/message/destructuring-decl-no-init-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698