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

Side by Side Diff: test/mjsunit/harmony/block-let-semantics-sloppy.js

Issue 1214733013: [es6] Enforce TDZ checks for let/const in StoreLookupSlot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 TestAll('f(); let x; function f() { x++; }'); 78 TestAll('f(); let x; function f() { x++; }');
79 TestAll('f(); const x = 1; function f() { return x; }'); 79 TestAll('f(); const x = 1; function f() { return x; }');
80 80
81 TestAll('f()(); let x; function f() { return function() { return x + 1; } }'); 81 TestAll('f()(); let x; function f() { return function() { return x + 1; } }');
82 TestAll('f()(); let x; function f() { return function() { x = 1; } }'); 82 TestAll('f()(); let x; function f() { return function() { x = 1; } }');
83 TestAll('f()(); let x; function f() { return function() { x += 1; } }'); 83 TestAll('f()(); let x; function f() { return function() { x += 1; } }');
84 TestAll('f()(); let x; function f() { return function() { ++x; } }'); 84 TestAll('f()(); let x; function f() { return function() { ++x; } }');
85 TestAll('f()(); let x; function f() { return function() { x++; } }'); 85 TestAll('f()(); let x; function f() { return function() { x++; } }');
86 TestAll('f()(); const x = 1; function f() { return function() { return x; } }'); 86 TestAll('f()(); const x = 1; function f() { return function() { return x; } }');
87 87
88 // Use before initialization with a dynamic lookup. 88 for (var kw of ['let', 'const']) {
89 TestAll('eval("x + 1;"); let x;'); 89 // Use before initialization with a dynamic lookup.
90 TestAll('eval("x = 1;"); let x;'); 90 TestAll(`eval("x"); ${kw} x = 2;`);
91 TestAll('eval("x += 1;"); let x;'); 91 TestAll(`eval("x + 1;"); ${kw} x = 2;`);
92 TestAll('eval("++x;"); let x;'); 92 TestAll(`eval("x = 1;"); ${kw} x = 2;`);
93 TestAll('eval("x++;"); let x;'); 93 TestAll(`eval("x += 1;"); ${kw} x = 2;`);
94 TestAll('eval("x"); const x = 1;'); 94 TestAll(`eval("++x;"); ${kw} x = 2;`);
95 TestAll(`eval("x++;"); ${kw} x = 2;`);
95 96
96 // Use before initialization with check for eval-shadowed bindings. 97 // Use before initialization with check for eval-shadowed bindings.
97 TestAll('function f() { eval("var y = 2;"); x + 1; }; f(); let x;'); 98 TestAll(`function f() { eval("var y = 2;"); x + 1; }; f(); ${kw} x = 2;`);
98 // TODO(arv): https://code.google.com/p/v8/issues/detail?id=4284 99 TestAll(`function f() { eval("var y = 2;"); x = 1; }; f(); ${kw} x = 2;`);
99 // TestAll('function f() { eval("var y = 2;"); x = 1; }; f(); let x;'); 100 TestAll(`function f() { eval("var y = 2;"); x += 1; }; f(); ${kw} x = 2;`);
100 TestAll('function f() { eval("var y = 2;"); x += 1; }; f(); let x;'); 101 TestAll(`function f() { eval("var y = 2;"); ++x; }; f(); ${kw} x = 2;`);
101 TestAll('function f() { eval("var y = 2;"); ++x; }; f(); let x;'); 102 TestAll(`function f() { eval("var y = 2;"); x++; }; f(); ${kw} x = 2;`);
102 TestAll('function f() { eval("var y = 2;"); x++; }; f(); let x;'); 103 }
103 104
104 // Test that variables introduced by function declarations are created and 105 // Test that variables introduced by function declarations are created and
105 // initialized upon entering a function / block scope. 106 // initialized upon entering a function / block scope.
106 function f() { 107 function f() {
107 { 108 {
108 assertEquals(2, g1()); 109 assertEquals(2, g1());
109 assertEquals(2, eval("g1()")); 110 assertEquals(2, eval("g1()"));
110 111
111 // block scoped function declaration 112 // block scoped function declaration
112 function g1() { 113 function g1() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 180 }
180 eval("1 + 1"); 181 eval("1 + 1");
181 return x + inner(); 182 return x + inner();
182 } 183 }
183 184
184 let x = 1; 185 let x = 1;
185 return middle(); 186 return middle();
186 } 187 }
187 188
188 assertEquals(2, outer()); 189 assertEquals(2, outer());
OLDNEW
« src/runtime/runtime-scopes.cc ('K') | « test/mjsunit/es6/block-let-semantics.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698