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

Side by Side Diff: test/mjsunit/harmony/block-eval-var-over-legacy-const.js

Issue 1382513003: Test for var declarations in eval which conflict with let (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mask out eval bit Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/variables.cc ('k') | test/mjsunit/harmony/block-eval-var-over-let.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-sloppy --harmony-sloppy-let --harmony-sloppy-function
6
7 // Var-let conflict in a function throws, even if the var is in an eval
8
9 let caught = false;
10
11 // Throws at the top level of a function
12 try {
13 (function() {
14 let x = 1;
15 eval('const x = 2');
16 })()
17 } catch (e) {
18 caught = true;
19 }
20 assertTrue(caught);
21
22 // If the eval is in its own block scope, throws
23 caught = false;
24 try {
25 (function() {
26 let y = 1;
27 { eval('const y = 2'); }
28 })()
29 } catch (e) {
30 caught = true;
31 }
32 assertTrue(caught);
33
34 // If the let is in its own block scope, with the eval, throws
35 caught = false
36 try {
37 (function() {
38 {
39 let x = 1;
40 eval('const x = 2');
41 }
42 })();
43 } catch (e) {
44 caught = true;
45 }
46 assertTrue(caught);
47
48 // Legal if the let is no longer visible
49 caught = false
50 try {
51 (function() {
52 {
53 let x = 1;
54 }
55 eval('const x = 2');
56 })();
57 } catch (e) {
58 caught = true;
59 }
60 assertFalse(caught);
61
62 // In global scope
63 caught = false;
64 try {
65 let z = 1;
66 eval('const z = 2');
67 } catch (e) {
68 caught = true;
69 }
70 assertTrue(caught);
71
72 // Let declarations beyond a function boundary don't conflict
73 caught = false;
74 try {
75 let a = 1;
76 (function() {
77 eval('const a');
78 })();
79 } catch (e) {
80 caught = true;
81 }
82 assertFalse(caught);
83
84 // var across with doesn't conflict
85 caught = false;
86 try {
87 (function() {
88 with ({x: 1}) {
89 eval("const x = 2;");
90 }
91 })();
92 } catch (e) {
93 caught = true;
94 }
95 assertFalse(caught);
96
97 // var can still conflict with let across a with
98 caught = false;
99 try {
100 (function() {
101 let x;
102 with ({x: 1}) {
103 eval("const x = 2;");
104 }
105 })();
106 } catch (e) {
107 caught = true;
108 }
109 assertTrue(caught);
OLDNEW
« no previous file with comments | « src/variables.cc ('k') | test/mjsunit/harmony/block-eval-var-over-let.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698