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

Unified Diff: test/cctest/test-parsing.cc

Issue 1281163002: [parser] partially revert "use-strict directives in function body affect init block" Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/arrow-rest-params.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index f9d210c7ae10f99f4b9daedbec694ba571c8e577..faa99b5e36f09766c01307c6b82f7a03c9873abe 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -6818,3 +6818,77 @@ TEST(LetSloppy) {
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
arraysize(always_flags));
}
+
+
+TEST(LanguageModeDirectivesNonSimpleParameterListErrors) {
+ // A block declaration scope as a child scope of a function scope
+ // indicates that a function has a non-simple parameter list.
+ // TC39 deemed "use strict" directives to be an error in this case,
+ // on 29/7/2015. https://goo.gl/ueA7Ln
+ //
+ // In V8, this also applies to "use strong " directives.
+ const char* context_data[][2] = {
+ /*
+ var a = ({ bindingPattern = {} }) => { 'use strict'; }
+ */
+
+ {"function f(", ") { 'use strict'; }"},
+ {"function f(", ") { 'use strong'; }"},
+ {"function* g(", ") { 'use strict'; }"},
+ {"function* g(", ") { 'use strong'; }"},
+ {"var a = (", ") => { 'use strict'; }"},
+ {"var a = (", ") => { 'use strong'; }"},
+ {"var o = { m(", ") { 'use strict'; }"},
+ {"var o = { m(", ") { 'use strong'; }"},
+ {"var o = { *gm(", ") { 'use strict'; }"},
+ {"var o = { *gm(", ") { 'use strong'; }"},
+ {"var c = { m(", ") { 'use strict'; }"},
+ {"var c = { m(", ") { 'use strong'; }"},
+ {"var c = { *gm(", ") { 'use strict'; }"},
+ {"var c = { *gm(", ") { 'use strong'; }"},
+
+ {"'use strict'; function f(", ") { 'use strict'; }"},
+ {"'use strict'; function f(", ") { 'use strong'; }"},
+ {"'use strict'; function* g(", ") { 'use strict'; }"},
+ {"'use strict'; function* g(", ") { 'use strong'; }"},
+ {"'use strict'; var a = (", ") => { 'use strict'; }"},
+ {"'use strict'; var a = (", ") => { 'use strong'; }"},
+ {"'use strict'; var o = { m(", ") { 'use strict'; }"},
+ {"'use strict'; var o = { m(", ") { 'use strong'; }"},
+ {"'use strict'; var o = { *gm(", ") { 'use strict'; }"},
+ {"'use strict'; var o = { *gm(", ") { 'use strong'; }"},
+ {"'use strict'; var c = { m(", ") { 'use strict'; }"},
+ {"'use strict'; var c = { m(", ") { 'use strong'; }"},
+ {"'use strict'; var c = { *gm(", ") { 'use strict'; }"},
+ {"'use strict'; var c = { *gm(", ") { 'use strong'; }"},
+
+ {"'use strong'; function f(", ") { 'use strict'; }"},
+ {"'use strong'; function f(", ") { 'use strong'; }"},
+ {"'use strong'; function* g(", ") { 'use strict'; }"},
+ {"'use strong'; function* g(", ") { 'use strong'; }"},
+ {"'use strong'; var a = (", ") => { 'use strict'; }"},
+ {"'use strong'; var a = (", ") => { 'use strong'; }"},
+ {"'use strong'; var o = { m(", ") { 'use strict'; }"},
+ {"'use strong'; var o = { m(", ") { 'use strong'; }"},
+ {"'use strong'; var o = { *gm(", ") { 'use strict'; }"},
+ {"'use strong'; var o = { *gm(", ") { 'use strong'; }"},
+ {"'use strong'; var c = { m(", ") { 'use strict'; }"},
+ {"'use strong'; var c = { m(", ") { 'use strong'; }"},
+ {"'use strong'; var c = { *gm(", ") { 'use strict'; }"},
+ {"'use strong'; var c = { *gm(", ") { 'use strong'; }"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ // TODO(@caitp): support formal parameter initializers
+ "initializer = true"
+ "...rest",
+ "{ bindingPattern = {} }",
+ "{ initializedBindingPattern } = { initializedBindingPattern = true }",
+ NULL};
+
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring,
+ kAllowHarmonyRestParameters, kAllowStrongMode};
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/arrow-rest-params.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698