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

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

Issue 1320673007: Disallow yield in default parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Rebase Created 5 years, 3 months 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.h ('k') | no next file » | 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 6734 matching lines...) Expand 10 before | Expand all | Expand 10 after
6745 "(...{}) => {}", 6745 "(...{}) => {}",
6746 "(...{x}) => {}", 6746 "(...{x}) => {}",
6747 "(...[x]) => {}", 6747 "(...[x]) => {}",
6748 nullptr}; 6748 nullptr};
6749 // clang-format on 6749 // clang-format on
6750 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 6750 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
6751 arraysize(always_flags)); 6751 arraysize(always_flags));
6752 } 6752 }
6753 6753
6754 6754
6755 TEST(DefaultParametersYieldInInitializers) {
6756 // clang-format off
6757 const char* sloppy_function_context_data[][2] = {
6758 {"(function f(", ") { });"},
6759 // TODO(wingo): Add arrow functions.
6760 {NULL, NULL}
6761 };
6762
6763 const char* strict_function_context_data[][2] = {
6764 {"'use strong'; (function f(", ") { });"},
6765 {"'use strict'; (function f(", ") { });"},
6766 // TODO(wingo,conradw): These should also signal early errors.
6767 // {"(function f(", ") {'use strong'; });"},
6768 // {"(function f(", ") {'use strict'; });"},
6769 // TODO(wingo): Add arrow functions.
6770 {NULL, NULL}
6771 };
6772
6773 const char* generator_context_data[][2] = {
6774 {"'use strong'; (function *g(", ") { });"},
6775 {"'use strict'; (function *g(", ") { });"},
6776 // TODO(wingo,conradw): These should also signal early errors.
6777 // {"(function *g(", ") {'use strong'; });"},
6778 // {"(function *g(", ") {'use strict'; });"},
6779 {"(function *g(", ") { });"},
6780 {NULL, NULL}
6781 };
6782
6783 const char* formal_parameter_data[] = {
6784 "x=yield",
6785 "x, y=yield",
6786 "{x=yield}",
6787 "[x=yield]",
6788 "{x}=yield",
6789 "[x]=yield",
6790
6791 "x=(yield)",
6792 "x, y=(yield)",
6793 "{x=(yield)}",
6794 "[x=(yield)]",
6795 "{x}=(yield)",
6796 "[x]=(yield)",
6797
6798 "x=f(yield)",
6799 "x, y=f(yield)",
6800 "{x=f(yield)}",
6801 "[x=f(yield)]",
6802 "{x}=f(yield)",
6803 "[x]=f(yield)",
6804 NULL
6805 };
6806
6807 // clang-format on
6808 static const ParserFlag always_flags[] = {
6809 kAllowHarmonyDestructuring, kAllowHarmonyDefaultParameters,
6810 kAllowHarmonyArrowFunctions, kAllowStrongMode};
6811 RunParserSyncTest(sloppy_function_context_data, formal_parameter_data,
6812 kSuccess, NULL, 0, always_flags, arraysize(always_flags));
6813 RunParserSyncTest(strict_function_context_data, formal_parameter_data, kError,
6814 NULL, 0, always_flags, arraysize(always_flags));
6815 RunParserSyncTest(generator_context_data, formal_parameter_data, kError, NULL,
6816 0, always_flags, arraysize(always_flags));
6817 }
6818
6819
6755 TEST(SpreadArray) { 6820 TEST(SpreadArray) {
6756 i::FLAG_harmony_spread_arrays = true; 6821 i::FLAG_harmony_spread_arrays = true;
6757 6822
6758 const char* context_data[][2] = { 6823 const char* context_data[][2] = {
6759 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; 6824 {"'use strict';", ""}, {"", ""}, {NULL, NULL}};
6760 6825
6761 // clang-format off 6826 // clang-format off
6762 const char* data[] = { 6827 const char* data[] = {
6763 "[...a]", 6828 "[...a]",
6764 "[a, ...b]", 6829 "[a, ...b]",
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 NULL}; 7070 NULL};
7006 7071
7007 static const ParserFlag always_flags[] = { 7072 static const ParserFlag always_flags[] = {
7008 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters, 7073 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters,
7009 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters, 7074 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters,
7010 kAllowHarmonySloppy, kAllowStrongMode 7075 kAllowHarmonySloppy, kAllowStrongMode
7011 }; 7076 };
7012 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 7077 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
7013 arraysize(always_flags)); 7078 arraysize(always_flags));
7014 } 7079 }
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698