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

Unified Diff: test/mjsunit/strong/undefined-arrow.js

Issue 1060883004: [strong] Implement static restrictions on binding 'undefined' in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix a merge mistake and formatting Created 5 years, 8 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
« src/preparser.h ('K') | « test/mjsunit/strong/undefined.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/undefined-arrow.js
diff --git a/test/mjsunit/strong/undefined-arrow.js b/test/mjsunit/strong/undefined-arrow.js
new file mode 100644
index 0000000000000000000000000000000000000000..1ff26ac39a65b0fa2a457e3aebe0acf44fcc0794
--- /dev/null
+++ b/test/mjsunit/strong/undefined-arrow.js
@@ -0,0 +1,40 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --strong-mode --harmony-sloppy --harmony-arrow-functions
+"use strict";
+
+function CheckStrongMode(code) {
+ let strictContexts = [
+ ["'use strict';", ""],
+ ["function outer() { 'use strict';", "}"],
+ ["function outer() { 'use strict'; function inner() {", "}}"],
+ ["class C { m() {", "} }"]
+ ]
+ let strongContexts = [
+ ["'use strong';", ""],
+ ["function outer() { 'use strong';", "}"],
+ ["function outer() { 'use strong'; function inner() {", "}}"],
+ ["class C { m() { 'use strong';", "} }"]
+ ]
+
+ for (let context of strictContexts) {
+ assertDoesNotThrow(context[0] + code + context[1]);
+ }
+ for (let context of strongContexts) {
+ assertThrows(context[0] + code + context[1], SyntaxError);
+ }
+}
+
+CheckStrongMode("(undefined => {return});");
+assertThrows("(undefined => {'use strong';});");
+
+CheckStrongMode("((undefined, b, c) => {return});");
+assertThrows("((undefined, b, c) => {'use strong';});");
+
+CheckStrongMode("((a, undefined, c) => {return});");
+assertThrows("((a, undefined, c) => {'use strong';});");
+
+CheckStrongMode("((a, b, undefined) => {return})");
+assertThrows("((a, b, undefined) => {'use strong';});");
« src/preparser.h ('K') | « test/mjsunit/strong/undefined.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698