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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 BeginTest("For loop 1"); | 373 BeginTest("For loop 1"); |
374 | 374 |
375 function for_loop_1() { | 375 function for_loop_1() { |
376 for (let x in {y:undefined}) { | 376 for (let x in {y:undefined}) { |
377 debugger; | 377 debugger; |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 listener_delegate = function(exec_state) { | 381 listener_delegate = function(exec_state) { |
382 CheckScopeChain([debug.ScopeType.Block, | 382 CheckScopeChain([debug.ScopeType.Block, |
383 debug.ScopeType.Block, | |
384 debug.ScopeType.Local, | 383 debug.ScopeType.Local, |
385 debug.ScopeType.Script, | 384 debug.ScopeType.Script, |
386 debug.ScopeType.Global], exec_state); | 385 debug.ScopeType.Global], exec_state); |
387 CheckScopeContent({x:'y'}, 0, exec_state); | 386 CheckScopeContent({x:'y'}, 0, exec_state); |
388 // The function scope contains a temporary iteration variable, but it is | 387 // The function scope contains a temporary iteration variable, but it is |
389 // hidden to the debugger. | 388 // hidden to the debugger. |
390 // TODO(adamk): This variable is only used to provide a TDZ for the enumerable | |
391 // expression and should not be visible to the debugger. | |
392 CheckScopeContent({x:undefined}, 1, exec_state); | |
393 }; | 389 }; |
394 for_loop_1(); | 390 for_loop_1(); |
395 EndTest(); | 391 EndTest(); |
396 | 392 |
397 | 393 |
398 // For-in loop over the keys of an object with a block scoped let variable | 394 // For-in loop over the keys of an object with a block scoped let variable |
399 // shadowing the iteration variable. | 395 // shadowing the iteration variable. |
400 BeginTest("For loop 2"); | 396 BeginTest("For loop 2"); |
401 | 397 |
402 function for_loop_2() { | 398 function for_loop_2() { |
403 for (let x in {y:undefined}) { | 399 for (let x in {y:undefined}) { |
404 let x = 3; | 400 let x = 3; |
405 debugger; | 401 debugger; |
406 } | 402 } |
407 } | 403 } |
408 | 404 |
409 listener_delegate = function(exec_state) { | 405 listener_delegate = function(exec_state) { |
410 CheckScopeChain([debug.ScopeType.Block, | 406 CheckScopeChain([debug.ScopeType.Block, |
411 debug.ScopeType.Block, | 407 debug.ScopeType.Block, |
412 debug.ScopeType.Block, | |
413 debug.ScopeType.Local, | 408 debug.ScopeType.Local, |
414 debug.ScopeType.Script, | 409 debug.ScopeType.Script, |
415 debug.ScopeType.Global], exec_state); | 410 debug.ScopeType.Global], exec_state); |
416 CheckScopeContent({x:3}, 0, exec_state); | 411 CheckScopeContent({x:3}, 0, exec_state); |
417 CheckScopeContent({x:'y'}, 1, exec_state); | 412 CheckScopeContent({x:'y'}, 1, exec_state); |
418 // The function scope contains a temporary iteration variable, hidden to the | 413 // The function scope contains a temporary iteration variable, hidden to the |
419 // debugger. | 414 // debugger. |
420 // TODO(adamk): This variable is only used to provide a TDZ for the enumerable | |
421 // expression and should not be visible to the debugger. | |
422 CheckScopeContent({x:undefined}, 2, exec_state); | |
423 }; | 415 }; |
424 for_loop_2(); | 416 for_loop_2(); |
425 EndTest(); | 417 EndTest(); |
426 | 418 |
427 | 419 |
428 // Simple for loop. | 420 // Simple for loop. |
429 BeginTest("For loop 3"); | 421 BeginTest("For loop 3"); |
430 | 422 |
431 function for_loop_3() { | 423 function for_loop_3() { |
432 for (let x = 3; x < 4; ++x) { | 424 for (let x = 3; x < 4; ++x) { |
433 debugger; | 425 debugger; |
434 } | 426 } |
435 } | 427 } |
436 | 428 |
437 listener_delegate = function(exec_state) { | 429 listener_delegate = function(exec_state) { |
438 CheckScopeChain([debug.ScopeType.Block, | 430 CheckScopeChain([debug.ScopeType.Block, |
439 debug.ScopeType.Block, | |
440 debug.ScopeType.Local, | 431 debug.ScopeType.Local, |
441 debug.ScopeType.Script, | 432 debug.ScopeType.Script, |
442 debug.ScopeType.Global], exec_state); | 433 debug.ScopeType.Global], exec_state); |
443 CheckScopeContent({x:3}, 0, exec_state); | 434 CheckScopeContent({x:3}, 0, exec_state); |
444 CheckScopeContent({x:3}, 1, exec_state); | 435 CheckScopeContent({}, 1, exec_state); |
445 CheckScopeContent({}, 2, exec_state); | |
446 }; | 436 }; |
447 for_loop_3(); | 437 for_loop_3(); |
448 EndTest(); | 438 EndTest(); |
449 | 439 |
450 | 440 |
451 // For loop with a block scoped let variable shadowing the iteration variable. | 441 // For loop with a block scoped let variable shadowing the iteration variable. |
452 BeginTest("For loop 4"); | 442 BeginTest("For loop 4"); |
453 | 443 |
454 function for_loop_4() { | 444 function for_loop_4() { |
455 for (let x = 3; x < 4; ++x) { | 445 for (let x = 3; x < 4; ++x) { |
456 let x = 5; | 446 let x = 5; |
457 debugger; | 447 debugger; |
458 } | 448 } |
459 } | 449 } |
460 | 450 |
461 listener_delegate = function(exec_state) { | 451 listener_delegate = function(exec_state) { |
462 CheckScopeChain([debug.ScopeType.Block, | 452 CheckScopeChain([debug.ScopeType.Block, |
463 debug.ScopeType.Block, | 453 debug.ScopeType.Block, |
464 debug.ScopeType.Block, | |
465 debug.ScopeType.Local, | 454 debug.ScopeType.Local, |
466 debug.ScopeType.Script, | 455 debug.ScopeType.Script, |
467 debug.ScopeType.Global], exec_state); | 456 debug.ScopeType.Global], exec_state); |
468 CheckScopeContent({x:5}, 0, exec_state); | 457 CheckScopeContent({x:5}, 0, exec_state); |
469 CheckScopeContent({x:3}, 1, exec_state); | 458 CheckScopeContent({x:3}, 1, exec_state); |
470 CheckScopeContent({x:3}, 2, exec_state); | 459 CheckScopeContent({}, 2, exec_state); |
471 CheckScopeContent({}, 3, exec_state); | |
472 }; | 460 }; |
473 for_loop_4(); | 461 for_loop_4(); |
474 EndTest(); | 462 EndTest(); |
475 | 463 |
476 | 464 |
477 // For loop with two variable declarations. | 465 // For loop with two variable declarations. |
478 BeginTest("For loop 5"); | 466 BeginTest("For loop 5"); |
479 | 467 |
480 function for_loop_5() { | 468 function for_loop_5() { |
481 for (let x = 3, y = 5; x < 4; ++x) { | 469 for (let x = 3, y = 5; x < 4; ++x) { |
482 debugger; | 470 debugger; |
483 } | 471 } |
484 } | 472 } |
485 | 473 |
486 listener_delegate = function(exec_state) { | 474 listener_delegate = function(exec_state) { |
487 CheckScopeChain([debug.ScopeType.Block, | 475 CheckScopeChain([debug.ScopeType.Block, |
488 debug.ScopeType.Block, | |
489 debug.ScopeType.Local, | 476 debug.ScopeType.Local, |
490 debug.ScopeType.Script, | 477 debug.ScopeType.Script, |
491 debug.ScopeType.Global], exec_state); | 478 debug.ScopeType.Global], exec_state); |
492 CheckScopeContent({x:3,y:5}, 0, exec_state); | 479 CheckScopeContent({x:3,y:5}, 0, exec_state); |
493 CheckScopeContent({x:3,y:5}, 1, exec_state); | 480 CheckScopeContent({}, 1, exec_state); |
494 CheckScopeContent({}, 2, exec_state); | |
495 }; | 481 }; |
496 for_loop_5(); | 482 for_loop_5(); |
497 EndTest(); | 483 EndTest(); |
498 | 484 |
499 | 485 |
500 // Uninitialized variables | 486 // Uninitialized variables |
501 BeginTest("Uninitialized 1"); | 487 BeginTest("Uninitialized 1"); |
502 | 488 |
503 function uninitialized_1() { | 489 function uninitialized_1() { |
504 { | 490 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 debugger; | 531 debugger; |
546 } | 532 } |
547 } | 533 } |
548 | 534 |
549 listener_delegate = function (exec_state) { | 535 listener_delegate = function (exec_state) { |
550 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value()); | 536 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value()); |
551 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value()); | 537 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value()); |
552 } | 538 } |
553 shadowing_2(); | 539 shadowing_2(); |
554 EndTest(); | 540 EndTest(); |
OLD | NEW |