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

Unified Diff: test/mjsunit/regress/regress-3926.js

Issue 1312613003: Ensure hole checks take place in switch statement scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename function and add sloppy mode tests 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-3926.js
diff --git a/test/mjsunit/regress/regress-3926.js b/test/mjsunit/regress/regress-3926.js
new file mode 100644
index 0000000000000000000000000000000000000000..4720c1b90807a914b7028139f9c7329ec3579131
--- /dev/null
+++ b/test/mjsunit/regress/regress-3926.js
@@ -0,0 +1,87 @@
+// Copyright 2015 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: --harmony-sloppy --harmony-sloppy-let
+
+// See: http://code.google.com/p/v8/issues/detail?id=3926
+
+// Switch statements should disable hole check elimination
+
+// Ensure that both reads and writes encounter the hole check
+// FullCodeGen had an issue on reads; TurboFan had an issue on writes
+function f(x) {
+ var z;
+ switch (x) {
+ case 1:
+ let y = 1;
+ case 2:
+ y = 2;
+ case 3:
+ z = y;
+ }
+ return z;
+}
+assertEquals(2, f(1));
+assertThrows(function() {f(2)}, ReferenceError);
+assertThrows(function() {f(3)}, ReferenceError);
+
+// Ensure that hole checks are done even in subordinate scopes
+assertThrows(function() {
+ switch (1) {
+ case 0:
+ let x = 2;
+ case 1:
+ { // this block, plus the let below, adds another linear lexical scope
+ let y = 3;
+ x;
+ }
+ }
+}, ReferenceError);
+
+// Ensure that inner functions and eval don't skip hole checks
+
+function g(x) {
+ switch (x) {
+ case 1:
+ let z;
+ case 2:
+ return function() { z = 1; }
+ case 3:
+ return function() { return z; }
+ case 4:
+ return eval("z = 1");
+ case 5:
+ return eval("z");
+ }
+}
+
+assertEquals(undefined, g(1)());
+assertThrows(g(2), ReferenceError);
+assertThrows(g(3), ReferenceError);
+assertThrows(function () {g(4)}, ReferenceError);
+assertThrows(function () {g(5)}, ReferenceError);
+
+// Ensure the same in strict mode, with different eval and function semantics
+
+function h(x) {
+ 'use strict'
+ switch (x) {
+ case 1:
+ let z;
+ case 2:
+ return function() { z = 1; }
+ case 3:
+ return function() { return z; }
+ case 4:
+ return eval("z = 1");
+ case 5:
+ return eval("z");
+ }
+}
+
+assertEquals(undefined, h(1)());
+assertThrows(h(2), ReferenceError);
+assertThrows(h(3), ReferenceError);
+assertThrows(function () {h(4)}, ReferenceError);
+assertThrows(function () {h(5)}, ReferenceError);
« no previous file with comments | « src/scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698