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

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

Issue 1300103005: [parser] disallow language mode directive in body of function with non-simple parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: flag implications don't work in test suite? 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.cc ('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 1361bbcba78dc10dde5d2c5ef678068ef34482f7..1ea550caab1dc65b1fe0f320531bb250748c604d 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -6925,3 +6925,90 @@ TEST(LetSloppy) {
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
arraysize(always_flags));
}
+
+
+TEST(LanguageModeDirectivesNonSimpleParameterListErrors) {
+ // TC39 deemed "use strict" directives to be an error when occurring in the
+ // body of a function with non-simple parameter list, on 29/7/2015.
+ // https://goo.gl/ueA7Ln
+ //
+ // In V8, this also applies to "use strong " directives.
+ const char* context_data[][2] = {
+ {"function f(", ") { 'use strict'; }"},
+ {"function f(", ") { 'use strong'; }"},
+ {"function* g(", ") { 'use strict'; }"},
+ {"function* g(", ") { 'use strong'; }"},
+ {"class c { foo(", ") { 'use strict' }"},
+ {"class c { foo(", ") { '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'; class c { foo(", ") { 'use strict' }"},
+ {"'use strict'; class c { foo(", ") { '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'; class c { foo(", ") { 'use strict' }"},
+ {"'use strong'; class c { foo(", ") { '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
+ "{}",
+ "[]",
+ "[{}]",
+ "{a}",
+ "a, {b}",
+ "a, b, {c, d, e}",
+ "initializer = true",
+ "a, b, c = 1",
+ "...args",
+ "a, b, ...rest",
+ "[a, b, ...rest]",
+ "{ bindingPattern = {} }",
+ "{ initializedBindingPattern } = { initializedBindingPattern: true }",
+ NULL};
+
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters,
+ kAllowHarmonyDestructuring, kAllowHarmonyRestParameters,
+ kAllowHarmonySloppy, kAllowStrongMode
+ };
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
« no previous file with comments | « src/scopes.cc ('k') | test/mjsunit/harmony/arrow-rest-params.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698