OLD | NEW |
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 debug.ScopeType.With, | 408 debug.ScopeType.With, |
409 debug.ScopeType.Local, | 409 debug.ScopeType.Local, |
410 debug.ScopeType.Global], exec_state); | 410 debug.ScopeType.Global], exec_state); |
411 CheckScopeContent({a:2,b:1}, 0, exec_state); | 411 CheckScopeContent({a:2,b:1}, 0, exec_state); |
412 CheckScopeContent({a:1,b:2}, 1, exec_state); | 412 CheckScopeContent({a:1,b:2}, 1, exec_state); |
413 }; | 413 }; |
414 with_block_4(); | 414 with_block_4(); |
415 EndTest(); | 415 EndTest(); |
416 | 416 |
417 | 417 |
| 418 // With block and a block local variable. |
| 419 BeginTest("With block 5"); |
| 420 |
| 421 function with_block_5() { |
| 422 with({a:1}) { |
| 423 let a = 2; |
| 424 debugger; |
| 425 } |
| 426 } |
| 427 |
| 428 listener_delegate = function(exec_state) { |
| 429 CheckScopeChain([debug.ScopeType.Block, |
| 430 debug.ScopeType.With, |
| 431 debug.ScopeType.Local, |
| 432 debug.ScopeType.Global], exec_state); |
| 433 CheckScopeContent({a:2}, 0, exec_state); |
| 434 CheckScopeContent({a:1}, 1, exec_state); |
| 435 }; |
| 436 with_block_5(); |
| 437 EndTest(); |
| 438 |
| 439 |
418 // Simple closure formed by returning an inner function referering to an outer | 440 // Simple closure formed by returning an inner function referering to an outer |
419 // block local variable and an outer function's parameter. | 441 // block local variable and an outer function's parameter. |
420 BeginTest("Closure 1"); | 442 BeginTest("Closure 1"); |
421 | 443 |
422 function closure_1(a) { | 444 function closure_1(a) { |
423 var x = 2; | 445 var x = 2; |
424 let y = 3; | 446 let y = 3; |
425 if (true) { | 447 if (true) { |
426 let z = 4; | 448 let z = 4; |
427 function f() { | 449 function f() { |
428 debugger; | 450 debugger; |
429 return a + x + y + z; | 451 return a + x + y + z; |
430 }; | 452 }; |
431 return f; | 453 return f; |
432 } | 454 } |
433 } | 455 } |
434 | 456 |
435 listener_delegate = function(exec_state) { | 457 listener_delegate = function(exec_state) { |
436 CheckScopeChain([debug.ScopeType.Local, | 458 CheckScopeChain([debug.ScopeType.Local, |
437 debug.ScopeType.Block, | 459 debug.ScopeType.Block, |
438 debug.ScopeType.Closure, | 460 debug.ScopeType.Closure, |
439 debug.ScopeType.Global], exec_state); | 461 debug.ScopeType.Global], exec_state); |
440 CheckScopeContent({}, 0, exec_state); | 462 CheckScopeContent({}, 0, exec_state); |
441 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); | 463 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); |
442 }; | 464 }; |
443 closure_1(1)(); | 465 closure_1(1)(); |
444 EndTest(); | 466 EndTest(); |
OLD | NEW |