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

Unified Diff: test/mjsunit/harmony/block-eval-var-over-legacy-const.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-legacy-const.js
diff --git a/test/mjsunit/harmony/block-eval-var-over-legacy-const.js b/test/mjsunit/harmony/block-eval-var-over-legacy-const.js
index 0eb84564333b43db99cfcd33b38b29317670c5ad..fc4d22fead4027f5e15390c24c01d314d54bec6e 100644
--- a/test/mjsunit/harmony/block-eval-var-over-legacy-const.js
+++ b/test/mjsunit/harmony/block-eval-var-over-legacy-const.js
@@ -6,61 +6,36 @@
// 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('const x = 2');
- })()
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ let x = 1;
+ eval('const x = 2');
+}, TypeError);
// If the eval is in its own block scope, throws
-caught = false;
-try {
- (function() {
- let y = 1;
- { eval('const y = 2'); }
- })()
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ let y = 1;
+ { eval('const y = 2'); }
+}, TypeError);
// If the let is in its own block scope, with the eval, throws
-caught = false
-try {
- (function() {
- {
- let x = 1;
- eval('const x = 2');
- }
- })();
-} catch (e) {
- caught = true;
-}
-assertTrue(caught);
+assertThrows(function() {
+ {
+ let x = 1;
+ eval('const x = 2');
+ }
+}, TypeError);
// Legal if the let is no longer visible
-caught = false
-try {
- (function() {
- {
- let x = 1;
- }
- eval('const x = 2');
- })();
-} catch (e) {
- caught = true;
-}
-assertFalse(caught);
+assertDoesNotThrow(function() {
+ {
+ let x = 1;
+ }
+ eval('const x = 2');
+});
// In global scope
-caught = false;
+let caught = false;
try {
let z = 1;
eval('const z = 2');

Powered by Google App Engine
This is Rietveld 408576698