OLD | NEW |
| (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-default-parameters --harmony-destructuring-bind | |
6 | |
7 | |
8 (function TestSloppyEvalScoping() { | |
9 var x = 1; | |
10 | |
11 function f41({[eval("var x = 2; 'a'")]: w}, z = x) { return z; } | |
12 assertEquals(1, f41({})); | |
13 assertEquals(1, f41({a: 0})); | |
14 function f42({[eval("var x = 2; 'a'")]: w}, z = eval("x")) { return z; } | |
15 assertEquals(1, f42({})); | |
16 assertEquals(1, f42({a: 0})); | |
17 function f43({a: w = eval("var x = 2")}, z = x) { return z; } | |
18 assertEquals(1, f43({})); | |
19 assertEquals(1, f43({a: 0})); | |
20 function f44({a: w = eval("var x = 2")}, z = eval("x")) { return z; } | |
21 assertEquals(1, f44({})); | |
22 assertEquals(1, f44({a: 0})); | |
23 | |
24 function f5({a = eval("var x = 2"), b = x}) { return b; } | |
25 assertEquals(2, f5({})); | |
26 assertEquals(1, f5({a: 0})); | |
27 function f6({a = eval("var x = 2"), b = eval("x")}) { return b; } | |
28 assertEquals(2, f6({})); | |
29 assertEquals(1, f6({a: 0})); | |
30 function f71({[eval("var x = 2; 'a'")]: w, b = x}) { return b; } | |
31 assertEquals(2, f71({})); | |
32 assertEquals(2, f71({a: 0})); | |
33 function f72({[eval("var x = 2; 'a'")]: w, b = eval("x")}) { return b; } | |
34 assertEquals(2, f72({})); | |
35 assertEquals(2, f72({a: 0})); | |
36 function f73({a: w = eval("var x = 2"), b = x}) { return b; } | |
37 assertEquals(2, f73({})); | |
38 assertEquals(1, f73({a: 0})); | |
39 function f74({a: w = eval("var x = 2"), b = eval("x")}) { return b; } | |
40 assertEquals(2, f74({})); | |
41 assertEquals(1, f74({a: 0})); | |
42 | |
43 var g41 = ({[eval("var x = 2; 'a'")]: w}, z = x) => { return z; }; | |
44 assertEquals(1, g41({})); | |
45 assertEquals(1, g41({a: 0})); | |
46 var g42 = ({[eval("var x = 2; 'a'")]: w}, z = eval("x")) => { return z; }; | |
47 assertEquals(1, g42({})); | |
48 assertEquals(1, g42({a: 0})); | |
49 var g43 = ({a: w = eval("var x = 2")}, z = x) => { return z; }; | |
50 assertEquals(1, g43({})); | |
51 assertEquals(1, g43({a: 0})); | |
52 var g44 = ({a: w = eval("var x = 2")}, z = eval("x")) => { return z; }; | |
53 assertEquals(1, g44({})); | |
54 assertEquals(1, g44({a: 0})); | |
55 | |
56 var g5 = ({a = eval("var x = 2"), b = x}) => { return b; }; | |
57 assertEquals(2, g5({})); | |
58 assertEquals(1, g5({a: 0})); | |
59 var g6 = ({a = eval("var x = 2"), b = eval("x")}) => { return b; }; | |
60 assertEquals(2, g6({})); | |
61 assertEquals(1, g6({a: 0})); | |
62 var g71 = ({[eval("var x = 2; 'a'")]: w, b = x}) => { return b; }; | |
63 assertEquals(2, g71({})); | |
64 assertEquals(2, g71({a: 0})); | |
65 var g72 = ({[eval("var x = 2; 'a'")]: w, b = eval("x")}) => { return b; }; | |
66 assertEquals(2, g72({})); | |
67 assertEquals(2, g72({a: 0})); | |
68 var g73 = ({a: w = eval("var x = 2"), b = x}) => { return b; }; | |
69 assertEquals(2, g73({})); | |
70 assertEquals(1, g73({a: 0})); | |
71 var g74 = ({a: w = eval("var x = 2"), b = eval("x")}) => { return b; }; | |
72 assertEquals(2, g74({})); | |
73 assertEquals(1, g74({a: 0})); | |
74 })(); | |
75 | |
76 | |
77 (function TestStrictEvalScoping() { | |
78 'use strict'; | |
79 var x = 1; | |
80 | |
81 function f41({[eval("var x = 2; 'a'")]: w}, z = x) { return z; } | |
82 assertEquals(1, f41({})); | |
83 assertEquals(1, f41({a: 0})); | |
84 function f42({[eval("var x = 2; 'a'")]: w}, z = eval("x")) { return z; } | |
85 assertEquals(1, f42({})); | |
86 assertEquals(1, f42({a: 0})); | |
87 function f43({a: w = eval("var x = 2")}, z = x) { return z; } | |
88 assertEquals(1, f43({})); | |
89 assertEquals(1, f43({a: 0})); | |
90 function f44({a: w = eval("var x = 2")}, z = eval("x")) { return z; } | |
91 assertEquals(1, f44({})); | |
92 assertEquals(1, f44({a: 0})); | |
93 | |
94 function f5({a = eval("var x = 2"), b = x}) { return b; } | |
95 assertEquals(1, f5({})); | |
96 assertEquals(1, f5({a: 0})); | |
97 function f6({a = eval("var x = 2"), b = eval("x")}) { return b; } | |
98 assertEquals(1, f6({})); | |
99 assertEquals(1, f6({a: 0})); | |
100 function f71({[eval("var x = 2; 'a'")]: w, b = x}) { return b; } | |
101 assertEquals(1, f71({})); | |
102 assertEquals(1, f71({a: 0})); | |
103 function f72({[eval("var x = 2; 'a'")]: w, b = eval("x")}) { return b; } | |
104 assertEquals(1, f72({})); | |
105 assertEquals(1, f72({a: 0})); | |
106 function f73({a: w = eval("var x = 2"), b = x}) { return b; } | |
107 assertEquals(1, f73({})); | |
108 assertEquals(1, f73({a: 0})); | |
109 function f74({a: w = eval("var x = 2"), b = eval("x")}) { return b; } | |
110 assertEquals(1, f74({})); | |
111 assertEquals(1, f74({a: 0})); | |
112 })(); | |
OLD | NEW |