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

Unified Diff: test/mjsunit/harmony/block-eval-var-over-let.js

Issue 1437003006: Fix harmony sloppy block scoping dynamic redeclaration check (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tighten test, fix bug in redeclaration check Created 5 years, 1 month 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
Index: test/mjsunit/harmony/block-eval-var-over-let.js
diff --git a/test/mjsunit/harmony/block-eval-var-over-let.js b/test/mjsunit/harmony/block-eval-var-over-let.js
index 292d073c81002e5239c525fdceb66a9e5245b392..c95123167c7f9713e0027c5f85341ec5d255bb9f 100644
--- a/test/mjsunit/harmony/block-eval-var-over-let.js
+++ b/test/mjsunit/harmony/block-eval-var-over-let.js
@@ -6,116 +6,68 @@
// Var-let conflict in a function throws, even if the var is in an eval
-let caught = false;
-
// Throws at the top level of a function
-try {
- (function() {
- let x = 1;
- eval('var x = 2');
- })()
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ let x = 1;
+ eval('var x');
Dan Ehrenberg 2015/11/12 23:41:57 How about leaving in the previous tests and adding
adamk 2015/11/12 23:45:17 What do you feel the initializer versions add to t
Dan Ehrenberg 2015/11/12 23:53:18 Well, my thinking is rather mechanical: 1. You fou
adamk 2015/11/13 07:06:01 All I was thinking was that we desugar "var x = 1"
adamk 2015/11/13 20:59:07 After more discussion offline, I convinced Dan tha
+}, TypeError);
// If the eval is in its own block scope, throws
-caught = false;
-try {
- (function() {
- let y = 1;
- { eval('var y = 2'); }
- })()
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ let y = 1;
+ { eval('var y'); }
+}, TypeError);
// If the let is in its own block scope, with the eval, throws
-caught = false
-try {
- (function() {
- {
- let x = 1;
- eval('var x = 2');
- }
- })();
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ {
+ let x = 1;
+ eval('var x');
+ }
+}, TypeError);
// Legal if the let is no longer visible
-caught = false
-try {
- (function() {
- {
- let x = 1;
- }
- eval('var x = 2');
- })();
-} catch (e) {
- caught = true;
-}
-assertFalse(caught);
+assertDoesNotThrow(function() {
+ {
+ let x = 1;
+ }
+ eval('var x');
+});
// All the same works for const:
// Throws at the top level of a function
-try {
- (function() {
- const x = 1;
- eval('var x = 2');
- })();
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ const x = 1;
+ eval('var x');
+}, TypeError);
// If the eval is in its own block scope, throws
-caught = false;
-try {
- (function() {
- const y = 1;
- { eval('var y = 2'); }
- })();
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ const y = 1;
+ { eval('var y'); }
+}, TypeError);
// If the const is in its own block scope, with the eval, throws
-caught = false
-try {
- (function() {
- {
- const x = 1;
- eval('var x = 2');
- }
- })();
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ {
+ const x = 1;
+ eval('var x');
+ }
+}, TypeError);
// Legal if the const is no longer visible
-caught = false
-try {
- (function() {
- {
- const x = 1;
- }
- eval('var x = 2');
- })();
-} catch (e) {
- caught = true;
-}
-assertFalse(caught);
+assertDoesNotThrow(function() {
+ {
+ const x = 1;
+ }
+ eval('var x');
+});
// In global scope
-caught = false;
+let caught = false;
try {
let z = 1;
- eval('var z = 2');
+ eval('var z');
} catch (e) {
caught = true;
}
@@ -138,7 +90,7 @@ caught = false;
try {
(function() {
with ({x: 1}) {
- eval("var x = 2;");
+ eval("var x");
}
})();
} catch (e) {
@@ -152,7 +104,7 @@ try {
(function() {
let x;
with ({x: 1}) {
- eval("var x = 2;");
+ eval("var x");
}
})();
} catch (e) {
« src/runtime/runtime-scopes.cc ('K') | « test/mjsunit/harmony/block-eval-var-over-legacy-const.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698