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

Side by Side Diff: test/mjsunit/bugs/harmony/debug-blockscopes.js

Issue 7616009: Parse harmony let declarations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated tests. Created 9 years, 4 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 | Annotate | Revision Log
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 // Skip property with empty name. 151 // Skip property with empty name.
152 if (!scope.scopeObject().property('').isUndefined()) { 152 if (!scope.scopeObject().property('').isUndefined()) {
153 scope_size--; 153 scope_size--;
154 } 154 }
155 // Also ignore synthetic variable from block scopes. 155 // Also ignore synthetic variable from block scopes.
156 if (!scope.scopeObject().property('.block').isUndefined()) { 156 if (!scope.scopeObject().property('.block').isUndefined()) {
157 scope_size--; 157 scope_size--;
158 } 158 }
159 159
160 // TODO(keuchel): print('count' + count + ' scopesize' + scope_size);
161 if (count != scope_size) { 160 if (count != scope_size) {
162 print('Names found in scope:'); 161 print('Names found in scope:');
163 var names = scope.scopeObject().propertyNames(); 162 var names = scope.scopeObject().propertyNames();
164 for (var i = 0; i < names.length; i++) { 163 for (var i = 0; i < names.length; i++) {
165 print(names[i]); 164 print(names[i]);
166 } 165 }
167 } 166 }
168 assertEquals(count, scope_size); 167 assertEquals(count, scope_size);
169 168
170 // Get the debug command processor. 169 // Get the debug command processor.
(...skipping 15 matching lines...) Expand all
186 assertTrue(response.body.object.ref >= 0); 185 assertTrue(response.body.object.ref >= 0);
187 } 186 }
188 var found = false; 187 var found = false;
189 for (var i = 0; i < response.refs.length && !found; i++) { 188 for (var i = 0; i < response.refs.length && !found; i++) {
190 found = response.refs[i].handle == response.body.object.ref; 189 found = response.refs[i].handle == response.body.object.ref;
191 } 190 }
192 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); 191 assertTrue(found, "Scope object " + response.body.object.ref + " not found");
193 } 192 }
194 193
195 194
196 // Simple empty block scope in local scope. 195 // Simple closure formed by returning an inner function referering to an outer
197 BeginTest("Local block 1"); 196 // block local variable and an outer function's parameter. Due to VM
197 // optimizations parts of the actual closure is missing from the debugger
198 // information.
199 BeginTest("Closure 1");
198 200
199 function local_block_1() { 201 function closure_1(a) {
200 { 202 var x = 2;
201 debugger; 203 let y = 3;
204 if (true) {
205 let z = 4;
206 function f() {
207 debugger;
208 return a + x + y + z;
209 };
210 return f;
202 } 211 }
203 } 212 }
204 213
205 listener_delegate = function(exec_state) { 214 listener_delegate = function(exec_state) {
206 CheckScopeChain([debug.ScopeType.Block, 215 CheckScopeChain([debug.ScopeType.Local,
207 debug.ScopeType.Local, 216 debug.ScopeType.Block,
217 debug.ScopeType.Closure,
208 debug.ScopeType.Global], exec_state); 218 debug.ScopeType.Global], exec_state);
209 CheckScopeContent({}, 0, exec_state); 219 CheckScopeContent({}, 0, exec_state);
210 CheckScopeContent({}, 1, exec_state); 220 CheckScopeContent({z:4}, 1, exec_state);
221 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state);
211 }; 222 };
212 local_block_1(); 223 closure_1(1)();
213 EndTest(); 224 EndTest();
214
215
216 // Local scope with a parameter.
217 BeginTest("Local 2");
218
219 function local_2(a) {
220 {
221 debugger;
222 }
223 }
224
225 listener_delegate = function(exec_state) {
226 CheckScopeChain([debug.ScopeType.Block,
227 debug.ScopeType.Local,
228 debug.ScopeType.Global], exec_state);
229 CheckScopeContent({a:1}, 1, exec_state);
230 };
231 local_2(1);
232 EndTest();
233
234
235 // Local scope with a parameter and a local variable.
236 BeginTest("Local 3");
237
238 function local_3(a) {
239 var x = 3;
240 debugger;
241 }
242
243 listener_delegate = function(exec_state) {
244 CheckScopeChain([debug.ScopeType.Local,
245 debug.ScopeType.Global], exec_state);
246 CheckScopeContent({a:1,x:3}, 0, exec_state);
247 };
248 local_3(1);
249 EndTest();
250
251
252 // Local scope with parameters and local variables.
253 BeginTest("Local 4");
254
255 function local_4(a, b) {
256 var x = 3;
257 var y = 4;
258 debugger;
259 }
260
261 listener_delegate = function(exec_state) {
262 CheckScopeChain([debug.ScopeType.Local,
263 debug.ScopeType.Global], exec_state);
264 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state);
265 };
266 local_4(1, 2);
267 EndTest();
268
269
270 // Single empty with block.
271 BeginTest("With block 1");
272
273 function with_block_1() {
274 with({}) {
275 debugger;
276 }
277 }
278
279 listener_delegate = function(exec_state) {
280 CheckScopeChain([debug.ScopeType.Block,
281 debug.ScopeType.With,
282 debug.ScopeType.Local,
283 debug.ScopeType.Global], exec_state);
284 CheckScopeContent({}, 0, exec_state);
285 CheckScopeContent({}, 1, exec_state);
286 };
287 with_block_1();
288 EndTest();
289
290
291 // Nested empty with blocks.
292 BeginTest("With block 2");
293
294 function with_block_2() {
295 with({}) {
296 with({}) {
297 debugger;
298 }
299 }
300 }
301
302 listener_delegate = function(exec_state) {
303 CheckScopeChain([debug.ScopeType.Block,
304 debug.ScopeType.With,
305 debug.ScopeType.Block,
306 debug.ScopeType.With,
307 debug.ScopeType.Local,
308 debug.ScopeType.Global], exec_state);
309 CheckScopeContent({}, 0, exec_state);
310 CheckScopeContent({}, 1, exec_state);
311 CheckScopeContent({}, 2, exec_state);
312 CheckScopeContent({}, 3, exec_state);
313 };
314 with_block_2();
315 EndTest();
316
317
318 // With block using an in-place object literal.
319 BeginTest("With block 3");
320
321 function with_block_3() {
322 with({a:1,b:2}) {
323 debugger;
324 }
325 }
326
327 listener_delegate = function(exec_state) {
328 CheckScopeChain([debug.ScopeType.Block,
329 debug.ScopeType.With,
330 debug.ScopeType.Local,
331 debug.ScopeType.Global], exec_state);
332 CheckScopeContent({}, 0, exec_state);
333 CheckScopeContent({a:1,b:2}, 1, exec_state);
334 };
335 with_block_3();
336 EndTest();
337
338
339 // Nested with blocks using in-place object literals.
340 BeginTest("With block 4");
341
342 function with_block_4() {
343 with({a:1,b:2}) {
344 with({a:2,b:1}) {
345 debugger;
346 }
347 }
348 }
349
350 listener_delegate = function(exec_state) {
351 CheckScopeChain([debug.ScopeType.Block,
352 debug.ScopeType.With,
353 debug.ScopeType.Block,
354 debug.ScopeType.With,
355 debug.ScopeType.Local,
356 debug.ScopeType.Global], exec_state);
357 CheckScopeContent({a:2,b:1}, 1, exec_state);
358 CheckScopeContent({a:1,b:2}, 3, exec_state);
359 };
360 with_block_4();
361 EndTest();
362
363
364 // TODO(keuchel):
365 // Simple closure formed by returning an inner function referering to an outer
366 // block local variable and an outer function's parameter.
367 // BeginTest("Closure 1");
368 //
369 // function closure_1(a) {
370 // {
371 // let x = 3;
372 // function f() {
373 // debugger;
374 // return a + x;
375 // };
376 // }
377 // return f;
378 // }
379 //
380 // listener_delegate = function(exec_state) {
381 // CheckScopeChain([debug.ScopeType.Local,
382 // debug.ScopeType.Closure,
383 // debug.ScopeType.Global], exec_state);
384 // // CheckScopeContent({}, 0, exec_state);
385 // // CheckScopeContent({}, 1, exec_state);
386 // // CheckScopeContent({a:1}, 2, exec_state);
387 // };
388 // closure_1(1)();
389 // EndTest();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698