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

Side by Side Diff: test/mjsunit/debug-scopes.js

Issue 6804015: Debugger: show local scope before with in scope chain for functions created inside with block (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « src/runtime.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 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
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()) {
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
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
631 BeginTest("Closure 9");
632 function closure_9() {
633 eval("var y = 1;");
634 eval("var z = 1;");
635 (function inner(x) {
636 y++;
637 z++;
638 debugger;
639 })(2);
640 }
641
642 listener_delegate = function(exec_state) {
643 CheckScopeChain([debug.ScopeType.Local,
644 debug.ScopeType.Closure,
645 debug.ScopeType.Global], exec_state);
646 }
647 closure_9();
648 EndTest();
649
650
610 // Test a mixture of scopes. 651 // Test a mixture of scopes.
611 BeginTest("The full monty"); 652 BeginTest("The full monty");
612 function the_full_monty(a, b) { 653 function the_full_monty(a, b) {
613 var x = 3; 654 var x = 3;
614 var y = 4; 655 var y = 4;
615 eval('var i = 5'); 656 eval('var i = 5');
616 eval('var j = 6'); 657 eval('var j = 6');
617 function f(a, b) { 658 function f(a, b) {
618 var x = 9; 659 var x = 9;
619 var y = 10; 660 var y = 10;
(...skipping 26 matching lines...) Expand all
646 CheckScopeContent({b:16}, 0, exec_state); 687 CheckScopeContent({b:16}, 0, exec_state);
647 CheckScopeContent({a:15}, 1, exec_state); 688 CheckScopeContent({a:15}, 1, exec_state);
648 CheckScopeContent({x:14}, 2, exec_state); 689 CheckScopeContent({x:14}, 2, exec_state);
649 CheckScopeContent({j:13}, 3, exec_state); 690 CheckScopeContent({j:13}, 3, exec_state);
650 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); 691 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); 692 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state);
652 } 693 }
653 the_full_monty(1, 2)() 694 the_full_monty(1, 2)()
654 EndTest(); 695 EndTest();
655 696
697
698 BeginTest("Closure inside With 1");
699 function closure_in_with_1() {
700 with({x:1}) {
701 (function inner(x) {
702 debugger;
703 })(2);
704 }
705 }
706
707 listener_delegate = function(exec_state) {
708 CheckScopeChain([debug.ScopeType.Local,
709 debug.ScopeType.With,
710 debug.ScopeType.Closure,
711 debug.ScopeType.Global], exec_state);
712 CheckScopeContent({x: 2}, 0, exec_state);
713 }
714 closure_in_with_1();
715 EndTest();
716
717
718 BeginTest("Closure inside With 2");
719 function closure_in_with_2() {
720 with({x:1}) {
721 (function inner(x) {
722 with({x:3}) {
723 debugger;
724 }
725 })(2);
726 }
727 }
728
729 listener_delegate = function(exec_state) {
730 CheckScopeChain([debug.ScopeType.With,
731 debug.ScopeType.Local,
732 debug.ScopeType.With,
733 debug.ScopeType.Closure,
734 debug.ScopeType.Global], exec_state);
735 CheckScopeContent({x: 3}, 0, exec_state);
736 CheckScopeContent({x: 2}, 1, exec_state);
737 CheckScopeContent({x: 1}, 2, exec_state);
738 }
739 closure_in_with_2();
740 EndTest();
741
742
743 BeginTest("Closure inside With 3");
744 function createClosure(a) {
745 var b = a + 1;
746 return function closure() {
747 var c = b;
748 (function inner(x) {
749 with({x:c}) {
750 debugger;
751 }
752 })(2);
753 }
754 }
755
756 function closure_in_with_3() {
757 var f = createClosure(0);
758 f();
759 }
760
761 listener_delegate = function(exec_state) {
762 CheckScopeChain([debug.ScopeType.With,
763 debug.ScopeType.Local,
764 debug.ScopeType.Closure,
765 debug.ScopeType.Closure,
766 debug.ScopeType.Global], exec_state);
767 }
768 closure_in_with_3();
769 EndTest();
770
771
656 // Test global scope. 772 // Test global scope.
657 BeginTest("Global"); 773 BeginTest("Global");
658 listener_delegate = function(exec_state) { 774 listener_delegate = function(exec_state) {
659 CheckScopeChain([debug.ScopeType.Global], exec_state); 775 CheckScopeChain([debug.ScopeType.Global], exec_state);
660 } 776 }
661 debugger; 777 debugger;
662 EndTest(); 778 EndTest();
663 779
664 780
665 BeginTest("Catch block 1"); 781 BeginTest("Catch block 1");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 CheckScopeContent({n:10}, 0, exec_state); 868 CheckScopeContent({n:10}, 0, exec_state);
753 CheckScopeContent({e:'Exception'}, 1, exec_state); 869 CheckScopeContent({e:'Exception'}, 1, exec_state);
754 CheckScopeContent({y:98}, 2, exec_state); 870 CheckScopeContent({y:98}, 2, exec_state);
755 } 871 }
756 catch_block_4() 872 catch_block_4()
757 EndTest(); 873 EndTest();
758 874
759 875
760 assertEquals(begin_test_count, break_count, 'one or more tests did not enter the debugger'); 876 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'); 877 assertEquals(begin_test_count, end_test_count, 'one or more tests did not have i ts result checked');
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698