OLD | NEW |
---|---|
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 // 'arguments' and might be exposed in the local and closure scope. Just | 137 // 'arguments' and might be exposed in the local and closure scope. Just |
138 // ignore this. | 138 // ignore this. |
139 var scope_size = scope.scopeObject().properties().length; | 139 var scope_size = scope.scopeObject().properties().length; |
140 if (!scope.scopeObject().property('arguments').isUndefined()) { | 140 if (!scope.scopeObject().property('arguments').isUndefined()) { |
141 scope_size--; | 141 scope_size--; |
142 } | 142 } |
143 // Also ignore synthetic variable from catch block. | 143 // Also ignore synthetic variable from catch block. |
144 if (!scope.scopeObject().property('.catch-var').isUndefined()) { | 144 if (!scope.scopeObject().property('.catch-var').isUndefined()) { |
145 scope_size--; | 145 scope_size--; |
146 } | 146 } |
147 // Skip property with empty name. | |
148 if (!scope.scopeObject().property('').isUndefined()) { | |
antonm
2011/04/06 16:41:49
just curious, what are those properties with empty
| |
149 scope_size--; | |
150 } | |
147 | 151 |
148 if (count != scope_size) { | 152 if (count != scope_size) { |
149 print('Names found in scope:'); | 153 print('Names found in scope:'); |
150 var names = scope.scopeObject().propertyNames(); | 154 var names = scope.scopeObject().propertyNames(); |
151 for (var i = 0; i < names.length; i++) { | 155 for (var i = 0; i < names.length; i++) { |
152 print(names[i]); | 156 print(names[i]); |
153 } | 157 } |
154 } | 158 } |
155 assertEquals(count, scope_size); | 159 assertEquals(count, scope_size); |
156 | 160 |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 debug.ScopeType.Closure, | 604 debug.ScopeType.Closure, |
601 debug.ScopeType.Global], exec_state); | 605 debug.ScopeType.Global], exec_state); |
602 CheckScopeContent({}, 0, exec_state); | 606 CheckScopeContent({}, 0, exec_state); |
603 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); | 607 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); |
604 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); | 608 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); |
605 } | 609 } |
606 closure_7(1, 2)() | 610 closure_7(1, 2)() |
607 EndTest(); | 611 EndTest(); |
608 | 612 |
609 | 613 |
614 // Closure that may be optimized out. | |
615 BeginTest("Closure 8"); | |
616 function closure_8() { | |
617 (function inner(x) { | |
618 debugger; | |
619 })(2); | |
620 } | |
621 | |
622 listener_delegate = function(exec_state) { | |
623 CheckScopeChain([debug.ScopeType.Local, | |
624 debug.ScopeType.Global], exec_state); | |
625 CheckScopeContent({x: 2}, 0, exec_state); | |
626 } | |
627 closure_8(); | |
628 EndTest(); | |
629 | |
630 | |
610 // Test a mixture of scopes. | 631 // Test a mixture of scopes. |
611 BeginTest("The full monty"); | 632 BeginTest("The full monty"); |
612 function the_full_monty(a, b) { | 633 function the_full_monty(a, b) { |
613 var x = 3; | 634 var x = 3; |
614 var y = 4; | 635 var y = 4; |
615 eval('var i = 5'); | 636 eval('var i = 5'); |
616 eval('var j = 6'); | 637 eval('var j = 6'); |
617 function f(a, b) { | 638 function f(a, b) { |
618 var x = 9; | 639 var x = 9; |
619 var y = 10; | 640 var y = 10; |
(...skipping 26 matching lines...) Expand all Loading... | |
646 CheckScopeContent({b:16}, 0, exec_state); | 667 CheckScopeContent({b:16}, 0, exec_state); |
647 CheckScopeContent({a:15}, 1, exec_state); | 668 CheckScopeContent({a:15}, 1, exec_state); |
648 CheckScopeContent({x:14}, 2, exec_state); | 669 CheckScopeContent({x:14}, 2, exec_state); |
649 CheckScopeContent({j:13}, 3, exec_state); | 670 CheckScopeContent({j:13}, 3, exec_state); |
650 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); | 671 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); |
651 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); | 672 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); |
652 } | 673 } |
653 the_full_monty(1, 2)() | 674 the_full_monty(1, 2)() |
654 EndTest(); | 675 EndTest(); |
655 | 676 |
677 | |
678 BeginTest("Closure inside With 1"); | |
679 function closure_in_with_1() { | |
680 with({x:1}) { | |
681 (function inner(x) { | |
682 debugger; | |
683 })(2); | |
684 } | |
685 } | |
686 | |
687 listener_delegate = function(exec_state) { | |
688 CheckScopeChain([debug.ScopeType.Local, | |
689 debug.ScopeType.With, | |
690 debug.ScopeType.Closure, | |
691 debug.ScopeType.Global], exec_state); | |
692 CheckScopeContent({x: 2}, 0, exec_state); | |
693 } | |
694 closure_in_with_1(); | |
695 EndTest(); | |
696 | |
697 | |
698 BeginTest("Closure inside With 2"); | |
699 function closure_in_with_2() { | |
700 with({x:1}) { | |
701 (function inner(x) { | |
702 with({z:3}) { | |
703 debugger; | |
704 } | |
705 })(2); | |
706 } | |
707 } | |
708 | |
709 listener_delegate = function(exec_state) { | |
710 try { | |
711 CheckScopeChain([debug.ScopeType.With, | |
712 debug.ScopeType.Local, | |
713 debug.ScopeType.With, | |
714 debug.ScopeType.Closure, | |
715 debug.ScopeType.Global], exec_state); | |
716 CheckScopeContent({z: 3}, 0, exec_state); | |
717 CheckScopeContent({x: 2}, 1, exec_state); | |
718 CheckScopeContent({x: 1}, 2, exec_state); | |
719 } catch (e) { | |
720 print(e); | |
721 } | |
722 } | |
723 closure_in_with_2(); | |
724 EndTest(); | |
725 | |
726 | |
656 // Test global scope. | 727 // Test global scope. |
657 BeginTest("Global"); | 728 BeginTest("Global"); |
658 listener_delegate = function(exec_state) { | 729 listener_delegate = function(exec_state) { |
659 CheckScopeChain([debug.ScopeType.Global], exec_state); | 730 CheckScopeChain([debug.ScopeType.Global], exec_state); |
660 } | 731 } |
661 debugger; | 732 debugger; |
662 EndTest(); | 733 EndTest(); |
663 | 734 |
664 | 735 |
665 BeginTest("Catch block 1"); | 736 BeginTest("Catch block 1"); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 CheckScopeContent({n:10}, 0, exec_state); | 823 CheckScopeContent({n:10}, 0, exec_state); |
753 CheckScopeContent({e:'Exception'}, 1, exec_state); | 824 CheckScopeContent({e:'Exception'}, 1, exec_state); |
754 CheckScopeContent({y:98}, 2, exec_state); | 825 CheckScopeContent({y:98}, 2, exec_state); |
755 } | 826 } |
756 catch_block_4() | 827 catch_block_4() |
757 EndTest(); | 828 EndTest(); |
758 | 829 |
759 | 830 |
760 assertEquals(begin_test_count, break_count, 'one or more tests did not enter the debugger'); | 831 assertEquals(begin_test_count, break_count, 'one or more tests did not enter the debugger'); |
761 assertEquals(begin_test_count, end_test_count, 'one or more tests did not have i ts result checked'); | 832 assertEquals(begin_test_count, end_test_count, 'one or more tests did not have i ts result checked'); |
OLD | NEW |