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

Unified Diff: test/mjsunit/strong/function-arity.js

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 | « test/mjsunit/strong/destructuring.js ('k') | test/mjsunit/strong/literals.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/function-arity.js
diff --git a/test/mjsunit/strong/function-arity.js b/test/mjsunit/strong/function-arity.js
index 4d8833564cc3dbe3d0de6968acd497959ed8d22c..8eddc5e4a73bc916790d6d7162601e9746dfea38 100644
--- a/test/mjsunit/strong/function-arity.js
+++ b/test/mjsunit/strong/function-arity.js
@@ -21,7 +21,7 @@ function generateArguments(n, prefix) {
}
-function generateParams(n) {
+function generateParams(n, directive_in_body) {
let a = [];
for (let i = 0; i < n; i++) {
a[i] = `p${i}`;
@@ -29,13 +29,17 @@ function generateParams(n) {
return a.join(', ');
}
-function generateParamsWithRest(n) {
+function generateParamsWithRest(n, directive_in_body) {
let a = [];
let i = 0;
for (; i < n; i++) {
a[i] = `p${i}`;
}
- a.push(`...p${i}`)
+ if (!directive_in_body) {
+ // If language mode directive occurs in body, rest parameters will trigger
+ // an early error regardless of language mode.
+ a.push(`...p${i}`);
+ }
return a.join(', ');
}
@@ -76,6 +80,7 @@ function generateSpread(n) {
for (let call of calls) {
let code = `'use strict'; ${def}; ${call};`;
if (argumentCount < parameterCount) {
+ print(code);
assertThrows(code, TypeError);
} else {
assertDoesNotThrow(code);
@@ -106,13 +111,13 @@ function generateSpread(n) {
for (let parameterCount = 0; parameterCount < 3; parameterCount++) {
let defs = [
`let o = new class {
- m(${genParams(parameterCount)}) { 'use strong'; }
+ m(${genParams(parameterCount, true)}) { 'use strong'; }
}`,
`let o = new class {
- *m(${genParams(parameterCount)}) { 'use strong'; }
+ *m(${genParams(parameterCount, true)}) { 'use strong'; }
}`,
- `let o = { m(${genParams(parameterCount)}) { 'use strong'; } }`,
- `let o = { *m(${genParams(parameterCount)}) { 'use strong'; } }`,
+ `let o = { m(${genParams(parameterCount, true)}) { 'use strong'; } }`,
+ `let o = { *m(${genParams(parameterCount, true)}) { 'use strong'; } }`,
`'use strong';
let o = new class { m(${genParams(parameterCount)}) {} }`,
`'use strong';
@@ -173,7 +178,7 @@ function generateSpread(n) {
class C { constructor(${genParams(parameterCount)}) {} }`,
`'use strict';
class C {
- constructor(${genParams(parameterCount)}) { 'use strong'; }
+ constructor(${genParams(parameterCount, true)}) { 'use strong'; }
}`,
];
for (let def of defs) {
@@ -214,7 +219,7 @@ function generateSpread(n) {
}`,
`'use strict';
class B {
- constructor(${genParams(parameterCount)}) { 'use strong'; }
+ constructor(${genParams(parameterCount, true)}) { 'use strong'; }
}
class C extends B {
constructor() {
@@ -250,7 +255,7 @@ function generateSpread(n) {
class C extends B {}`,
`'use strict';
class B {
- constructor(${genParams(parameterCount)}) { 'use strong'; }
+ constructor(${genParams(parameterCount, true)}) { 'use strong'; }
}
class C extends B {}`,
];
« no previous file with comments | « test/mjsunit/strong/destructuring.js ('k') | test/mjsunit/strong/literals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698