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

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

Issue 1376623002: Extend Annex B 3.3 sloppy-mode block-scoped hoisting to scripts, eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase 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/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let 5 // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
6 // Flags: --harmony-sloppy-function --harmony-destructuring 6 // Flags: --harmony-sloppy-function --harmony-destructuring
7 // Flags: --harmony-rest-parameters 7 // Flags: --harmony-rest-parameters
8 8
9 // Test Annex B 3.3 semantics for functions declared in blocks in sloppy mode. 9 // Test Annex B 3.3 semantics for functions declared in blocks in sloppy mode.
10 // http://www.ecma-international.org/ecma-262/6.0/#sec-block-level-function-decl arations-web-legacy-compatibility-semantics 10 // http://www.ecma-international.org/ecma-262/6.0/#sec-block-level-function-decl arations-web-legacy-compatibility-semantics
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 assertEquals(2, f()); 140 assertEquals(2, f());
141 L: { 141 L: {
142 assertEquals(3, f()); 142 assertEquals(3, f());
143 break L; 143 break L;
144 function f() { return 3; } 144 function f() { return 3; }
145 } 145 }
146 assertEquals(2, f()); 146 assertEquals(2, f());
147 })(); 147 })();
148 148
149 // Test that hoisting from blocks doesn't happen in global scope 149 // Test that hoisting from blocks does happen in global scope
adamk 2015/09/29 23:23:15 More tests, please: - Negative cases: does not ho
150 function globalUnhoisted() { return 0; } 150 function globalHoisted() { return 0; }
151 { 151 {
152 function globalUnhoisted() { return 1; } 152 function globalHoisted() { return 1; }
153 } 153 }
154 assertEquals(0, globalUnhoisted()); 154 assertEquals(1, globalHoisted());
155
156 // Test that hoisting from blocks does happen in an eval
157 eval(`
158 function evalHoisted() { return 0; }
159 {
160 function evalHoisted() { return 1; }
161 }
162 assertEquals(1, evalHoisted());
163 `);
155 164
156 // Test that shadowing arguments is fine 165 // Test that shadowing arguments is fine
157 (function shadowArguments(x) { 166 (function shadowArguments(x) {
158 assertArrayEquals([1], arguments); 167 assertArrayEquals([1], arguments);
159 { 168 {
160 assertEquals('function', typeof arguments); 169 assertEquals('function', typeof arguments);
161 function arguments() {} 170 function arguments() {}
162 assertEquals('function', typeof arguments); 171 assertEquals('function', typeof arguments);
163 } 172 }
164 assertEquals('function', typeof arguments); 173 assertEquals('function', typeof arguments);
(...skipping 29 matching lines...) Expand all
194 // assertEquals('function', typeof x); 203 // assertEquals('function', typeof x);
195 })(1); 204 })(1);
196 205
197 assertThrows(function notInDefaultScope(x = y) { 206 assertThrows(function notInDefaultScope(x = y) {
198 { 207 {
199 function y() {} 208 function y() {}
200 } 209 }
201 assertEquals('function', typeof y); 210 assertEquals('function', typeof y);
202 assertEquals(x, undefined); 211 assertEquals(x, undefined);
203 }, ReferenceError); 212 }, ReferenceError);
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698