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

Unified Diff: test/mjsunit/harmony/rest-params.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/harmony/destructuring.js ('k') | test/mjsunit/harmony/spread-call-super-property.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/rest-params.js
diff --git a/test/mjsunit/harmony/rest-params.js b/test/mjsunit/harmony/rest-params.js
index fe7ee2adb81186076d1a32bee92642d1a2cdc430..49515f4f2c964678fb61e729ba0012a2edb112c0 100644
--- a/test/mjsunit/harmony/rest-params.js
+++ b/test/mjsunit/harmony/rest-params.js
@@ -16,18 +16,20 @@
return args.length; })(1,2,3,4,5));
})();
-function strictTest(a, b, ...c) {
+var strictTest = (function() {
"use strict";
- assertEquals(Array, c.constructor);
- assertTrue(Array.isArray(c));
+ return function strictTest(a, b, ...c) {
+ assertEquals(Array, c.constructor);
+ assertTrue(Array.isArray(c));
- var expectedLength = arguments.length >= 3 ? arguments.length - 2 : 0;
- assertEquals(expectedLength, c.length);
+ var expectedLength = arguments.length >= 3 ? arguments.length - 2 : 0;
+ assertEquals(expectedLength, c.length);
- for (var i = 2, j = 0; i < arguments.length; ++i) {
- assertEquals(c[j++], arguments[i]);
- }
-}
+ for (var i = 2, j = 0; i < arguments.length; ++i) {
+ assertEquals(c[j++], arguments[i]);
+ }
+ };
+})();
function sloppyTest(a, b, ...c) {
assertEquals(Array, c.constructor);
@@ -144,14 +146,15 @@ var O = {
(function testNoAliasArgumentsStrict() {
- function strictF(a, ...rest) {
+ ((function() {
"use strict";
- arguments[0] = 1;
- assertEquals(3, a);
- arguments[1] = 2;
- assertArrayEquals([4, 5], rest);
- }
- strictF(3, 4, 5);
+ return (function strictF(a, ...rest) {
+ arguments[0] = 1;
+ assertEquals(3, a);
+ arguments[1] = 2;
+ assertArrayEquals([4, 5], rest);
+ });
+ })())(3, 4, 5);
})();
@@ -212,3 +215,21 @@ var O = {
assertEquals([1, 2, 3], c.child);
assertEquals([1, 2, 3], c.base);
})();
+
+(function TestDirectiveThrows() {
+ "use strict";
+
+ assertThrows(
+ function(){ eval("function(...rest){'use strict';}") }, SyntaxError);
+ assertThrows(function(){ eval("(...rest) => {'use strict';}") }, SyntaxError);
+ assertThrows(
+ function(){ eval("(class{foo(...rest) {'use strict';}});") }, SyntaxError);
+
+ assertThrows(
+ function(){ eval("function(a, ...rest){'use strict';}") }, SyntaxError);
+ assertThrows(
+ function(){ eval("(a, ...rest) => {'use strict';}") }, SyntaxError);
+ assertThrows(
+ function(){ eval("(class{foo(a, ...rest) {'use strict';}});") },
+ SyntaxError);
+})();
« no previous file with comments | « test/mjsunit/harmony/destructuring.js ('k') | test/mjsunit/harmony/spread-call-super-property.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698