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

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

Issue 1804783002: Remove Scope::scope_contains_with_ bit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix scope names and GCC build Created 4 years, 9 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
« no previous file with comments | « test/mjsunit/debug-function-scopes.js ('k') | test/mjsunit/regress/regress-592353.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 147
148 // Check that the scope chain contains the expected names of scopes. 148 // Check that the scope chain contains the expected names of scopes.
149 function CheckScopeChainNames(names, exec_state) { 149 function CheckScopeChainNames(names, exec_state) {
150 var all_scopes = exec_state.frame().allScopes(); 150 var all_scopes = exec_state.frame().allScopes();
151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); 151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length");
152 for (var i = 0; i < names.length; i++) { 152 for (var i = 0; i < names.length; i++) {
153 var scope = exec_state.frame().scope(i); 153 var scope = exec_state.frame().scope(i);
154 assertTrue(scope.isScope()); 154 assertTrue(scope.isScope());
155 assertEquals(scope.details().name(), names[i]) 155 assertEquals(names[i], scope.details().name())
156 } 156 }
157 } 157 }
158 158
159 159
160 // Check that the content of the scope is as expected. For functions just check 160 // Check that the content of the scope is as expected. For functions just check
161 // that there is a function. 161 // that there is a function.
162 function CheckScopeContent(content, number, exec_state) { 162 function CheckScopeContent(content, number, exec_state) {
163 var scope = exec_state.frame().scope(number); 163 var scope = exec_state.frame().scope(number);
164 var count = 0; 164 var count = 0;
165 for (var p in content) { 165 for (var p in content) {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 }; 537 };
538 return f; 538 return f;
539 } 539 }
540 540
541 listener_delegate = function(exec_state) { 541 listener_delegate = function(exec_state) {
542 CheckScopeChain([debug.ScopeType.Local, 542 CheckScopeChain([debug.ScopeType.Local,
543 debug.ScopeType.Closure, 543 debug.ScopeType.Closure,
544 debug.ScopeType.Script, 544 debug.ScopeType.Script,
545 debug.ScopeType.Global], exec_state); 545 debug.ScopeType.Global], exec_state);
546 CheckScopeContent({a:1}, 1, exec_state); 546 CheckScopeContent({a:1}, 1, exec_state);
547 CheckScopeChainNames([undefined, "closure_1", undefined, undefined], exec_stat e) 547 CheckScopeChainNames(["f", "closure_1", undefined, undefined], exec_state)
548 }; 548 };
549 closure_1(1)(); 549 closure_1(1)();
550 EndTest(); 550 EndTest();
551 551
552 552
553 // Simple closure formed by returning an inner function referering the outer 553 // Simple closure formed by returning an inner function referering the outer
554 // functions arguments. Due to VM optimizations parts of the actual closure is 554 // functions arguments. Due to VM optimizations parts of the actual closure is
555 // missing from the debugger information. 555 // missing from the debugger information.
556 BeginTest("Closure 2"); 556 BeginTest("Closure 2");
557 557
558 function closure_2(a, b) { 558 function closure_2(a, b) {
559 var x = a + 2; 559 var x = a + 2;
560 var y = b + 2; 560 var y = b + 2;
561 function f() { 561 function f() {
562 debugger; 562 debugger;
563 return a + x; 563 return a + x;
564 }; 564 };
565 return f; 565 return f;
566 } 566 }
567 567
568 listener_delegate = function(exec_state) { 568 listener_delegate = function(exec_state) {
569 CheckScopeChain([debug.ScopeType.Local, 569 CheckScopeChain([debug.ScopeType.Local,
570 debug.ScopeType.Closure, 570 debug.ScopeType.Closure,
571 debug.ScopeType.Script, 571 debug.ScopeType.Script,
572 debug.ScopeType.Global], exec_state); 572 debug.ScopeType.Global], exec_state);
573 CheckScopeContent({a:1,x:3}, 1, exec_state); 573 CheckScopeContent({a:1,x:3}, 1, exec_state);
574 CheckScopeChainNames([undefined, "closure_2", undefined, undefined], exec_stat e) 574 CheckScopeChainNames(["f", "closure_2", undefined, undefined], exec_state)
575 }; 575 };
576 closure_2(1, 2)(); 576 closure_2(1, 2)();
577 EndTest(); 577 EndTest();
578 578
579 579
580 // Simple closure formed by returning an inner function referering the outer 580 // Simple closure formed by returning an inner function referering the outer
581 // functions arguments. Using all arguments and locals from the outer function 581 // functions arguments. Using all arguments and locals from the outer function
582 // in the inner function makes these part of the debugger information on the 582 // in the inner function makes these part of the debugger information on the
583 // closure. 583 // closure.
584 BeginTest("Closure 3"); 584 BeginTest("Closure 3");
585 585
586 function closure_3(a, b) { 586 function closure_3(a, b) {
587 var x = a + 2; 587 var x = a + 2;
588 var y = b + 2; 588 var y = b + 2;
589 function f() { 589 function f() {
590 debugger; 590 debugger;
591 return a + b + x + y; 591 return a + b + x + y;
592 }; 592 };
593 return f; 593 return f;
594 } 594 }
595 595
596 listener_delegate = function(exec_state) { 596 listener_delegate = function(exec_state) {
597 CheckScopeChain([debug.ScopeType.Local, 597 CheckScopeChain([debug.ScopeType.Local,
598 debug.ScopeType.Closure, 598 debug.ScopeType.Closure,
599 debug.ScopeType.Script, 599 debug.ScopeType.Script,
600 debug.ScopeType.Global], exec_state); 600 debug.ScopeType.Global], exec_state);
601 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); 601 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
602 CheckScopeChainNames([undefined, "closure_3", undefined, undefined], exec_stat e) 602 CheckScopeChainNames(["f", "closure_3", undefined, undefined], exec_state)
603 }; 603 };
604 closure_3(1, 2)(); 604 closure_3(1, 2)();
605 EndTest(); 605 EndTest();
606 606
607 607
608 608
609 // Simple closure formed by returning an inner function referering the outer 609 // Simple closure formed by returning an inner function referering the outer
610 // functions arguments. Using all arguments and locals from the outer function 610 // functions arguments. Using all arguments and locals from the outer function
611 // in the inner function makes these part of the debugger information on the 611 // in the inner function makes these part of the debugger information on the
612 // closure. Use the inner function as well... 612 // closure. Use the inner function as well...
(...skipping 10 matching lines...) Expand all
623 }; 623 };
624 return f; 624 return f;
625 } 625 }
626 626
627 listener_delegate = function(exec_state) { 627 listener_delegate = function(exec_state) {
628 CheckScopeChain([debug.ScopeType.Local, 628 CheckScopeChain([debug.ScopeType.Local,
629 debug.ScopeType.Closure, 629 debug.ScopeType.Closure,
630 debug.ScopeType.Script, 630 debug.ScopeType.Script,
631 debug.ScopeType.Global], exec_state); 631 debug.ScopeType.Global], exec_state);
632 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); 632 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
633 CheckScopeChainNames([undefined, "closure_4", undefined, undefined], exec_stat e) 633 CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state)
634 }; 634 };
635 closure_4(1, 2)(); 635 closure_4(1, 2)();
636 EndTest(); 636 EndTest();
637 637
638 638
639 639
640 // Simple closure formed by returning an inner function referering the outer 640 // Simple closure formed by returning an inner function referering the outer
641 // functions arguments. In the presence of eval all arguments and locals 641 // functions arguments. In the presence of eval all arguments and locals
642 // (including the inner function itself) from the outer function becomes part of 642 // (including the inner function itself) from the outer function becomes part of
643 // the debugger infformation on the closure. 643 // the debugger infformation on the closure.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 (function inner(x) { 741 (function inner(x) {
742 debugger; 742 debugger;
743 })(2); 743 })(2);
744 } 744 }
745 745
746 listener_delegate = function(exec_state) { 746 listener_delegate = function(exec_state) {
747 CheckScopeChain([debug.ScopeType.Local, 747 CheckScopeChain([debug.ScopeType.Local,
748 debug.ScopeType.Script, 748 debug.ScopeType.Script,
749 debug.ScopeType.Global], exec_state); 749 debug.ScopeType.Global], exec_state);
750 CheckScopeContent({x: 2}, 0, exec_state); 750 CheckScopeContent({x: 2}, 0, exec_state);
751 CheckScopeChainNames([undefined, undefined, undefined], exec_state) 751 CheckScopeChainNames(["inner", undefined, undefined], exec_state)
752 }; 752 };
753 closure_8(); 753 closure_8();
754 EndTest(); 754 EndTest();
755 755
756 756
757 BeginTest("Closure 9"); 757 BeginTest("Closure 9");
758 function closure_9() { 758 function closure_9() {
759 eval("var y = 1;"); 759 eval("var y = 1;");
760 eval("var z = 1;"); 760 eval("var z = 1;");
761 (function inner(x) { 761 (function inner(x) {
762 y++; 762 y++;
763 z++; 763 z++;
764 debugger; 764 debugger;
765 })(2); 765 })(2);
766 } 766 }
767 767
768 listener_delegate = function(exec_state) { 768 listener_delegate = function(exec_state) {
769 CheckScopeChain([debug.ScopeType.Local, 769 CheckScopeChain([debug.ScopeType.Local,
770 debug.ScopeType.Closure, 770 debug.ScopeType.Closure,
771 debug.ScopeType.Script, 771 debug.ScopeType.Script,
772 debug.ScopeType.Global], exec_state); 772 debug.ScopeType.Global], exec_state);
773 CheckScopeChainNames([undefined, "closure_9", undefined, undefined], exec_stat e) 773 CheckScopeChainNames(["inner", "closure_9", undefined, undefined], exec_state)
774 }; 774 };
775 closure_9(); 775 closure_9();
776 EndTest(); 776 EndTest();
777 777
778 778
779 // Test a mixture of scopes. 779 // Test a mixture of scopes.
780 BeginTest("The full monty"); 780 BeginTest("The full monty");
781 function the_full_monty(a, b) { 781 function the_full_monty(a, b) {
782 var x = 3; 782 var x = 3;
783 var y = 4; 783 var y = 4;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 with({x:1}) { 830 with({x:1}) {
831 (function inner(x) { 831 (function inner(x) {
832 debugger; 832 debugger;
833 })(2); 833 })(2);
834 } 834 }
835 } 835 }
836 836
837 listener_delegate = function(exec_state) { 837 listener_delegate = function(exec_state) {
838 CheckScopeChain([debug.ScopeType.Local, 838 CheckScopeChain([debug.ScopeType.Local,
839 debug.ScopeType.With, 839 debug.ScopeType.With,
840 debug.ScopeType.Closure,
841 debug.ScopeType.Script, 840 debug.ScopeType.Script,
842 debug.ScopeType.Global], exec_state); 841 debug.ScopeType.Global], exec_state);
843 CheckScopeContent({x: 2}, 0, exec_state); 842 CheckScopeContent({x: 2}, 0, exec_state);
843 CheckScopeContent({x: 1}, 1, exec_state);
844 }; 844 };
845 closure_in_with_1(); 845 closure_in_with_1();
846 EndTest(); 846 EndTest();
847 847
848 848
849 BeginTest("Closure inside With 2"); 849 BeginTest("Closure inside With 2");
850 function closure_in_with_2() { 850 function closure_in_with_2() {
851 with({x:1}) { 851 with({x:1}) {
852 (function inner(x) { 852 (function inner(x) {
853 with({x:3}) { 853 with({x:3}) {
854 debugger; 854 debugger;
855 } 855 }
856 })(2); 856 })(2);
857 } 857 }
858 } 858 }
859 859
860 listener_delegate = function(exec_state) { 860 listener_delegate = function(exec_state) {
861 CheckScopeChain([debug.ScopeType.With, 861 CheckScopeChain([debug.ScopeType.With,
862 debug.ScopeType.Local, 862 debug.ScopeType.Local,
863 debug.ScopeType.With, 863 debug.ScopeType.With,
864 debug.ScopeType.Closure,
865 debug.ScopeType.Script, 864 debug.ScopeType.Script,
866 debug.ScopeType.Global], exec_state); 865 debug.ScopeType.Global], exec_state);
867 CheckScopeContent({x: 3}, 0, exec_state); 866 CheckScopeContent({x: 3}, 0, exec_state);
868 CheckScopeContent({x: 2}, 1, exec_state); 867 CheckScopeContent({x: 2}, 1, exec_state);
869 CheckScopeContent({x: 1}, 2, exec_state); 868 CheckScopeContent({x: 1}, 2, exec_state);
870 CheckScopeChainNames(["inner", "inner", "closure_in_with_2", "closure_in_with_ 2", undefined, undefined], exec_state) 869 CheckScopeChainNames(["inner", "inner", "closure_in_with_2", undefined, undefi ned], exec_state)
871 }; 870 };
872 closure_in_with_2(); 871 closure_in_with_2();
873 EndTest(); 872 EndTest();
874 873
875 874
876 BeginTest("Closure inside With 3"); 875 BeginTest("Closure inside With 3");
877 function createClosure(a) { 876 function createClosure(a) {
878 var b = a + 1; 877 var b = a + 1;
879 return function closure() { 878 return function closure() {
880 var c = b; 879 var c = b;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } 941 }
943 }; 942 };
944 943
945 944
946 listener_delegate = function(exec_state) { 945 listener_delegate = function(exec_state) {
947 CheckScopeChain([debug.ScopeType.Catch, 946 CheckScopeChain([debug.ScopeType.Catch,
948 debug.ScopeType.Local, 947 debug.ScopeType.Local,
949 debug.ScopeType.Script, 948 debug.ScopeType.Script,
950 debug.ScopeType.Global], exec_state); 949 debug.ScopeType.Global], exec_state);
951 CheckScopeContent({e:'Exception'}, 0, exec_state); 950 CheckScopeContent({e:'Exception'}, 0, exec_state);
952 CheckScopeChainNames(["catch_block_1", undefined, undefined, undefined], exec_ state) 951 CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined], exec_state)
953 }; 952 };
954 catch_block_1(); 953 catch_block_1();
955 EndTest(); 954 EndTest();
956 955
957 956
958 BeginTest("Catch block 2"); 957 BeginTest("Catch block 2");
959 function catch_block_2() { 958 function catch_block_2() {
960 try { 959 try {
961 throw 'Exception'; 960 throw 'Exception';
962 } catch (e) { 961 } catch (e) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } 1087 }
1089 }; 1088 };
1090 1089
1091 1090
1092 listener_delegate = function(exec_state) { 1091 listener_delegate = function(exec_state) {
1093 CheckScopeChain([debug.ScopeType.Catch, 1092 CheckScopeChain([debug.ScopeType.Catch,
1094 debug.ScopeType.Local, 1093 debug.ScopeType.Local,
1095 debug.ScopeType.Script, 1094 debug.ScopeType.Script,
1096 debug.ScopeType.Global], exec_state); 1095 debug.ScopeType.Global], exec_state);
1097 CheckScopeContent({e:'Exception'}, 0, exec_state); 1096 CheckScopeContent({e:'Exception'}, 0, exec_state);
1098 CheckScopeChainNames(["catch_block_7", undefined, undefined, undefined], exec_ state) 1097 CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined], exec_state)
1099 }; 1098 };
1100 catch_block_7(); 1099 catch_block_7();
1101 EndTest(); 1100 EndTest();
1102 1101
1103 1102
1104 BeginTest("Classes and methods 1"); 1103 BeginTest("Classes and methods 1");
1105 1104
1106 listener_delegate = function(exec_state) { 1105 listener_delegate = function(exec_state) {
1107 "use strict" 1106 "use strict"
1108 CheckScopeChain([debug.ScopeType.Local, 1107 CheckScopeChain([debug.ScopeType.Local,
1109 debug.ScopeType.Script, 1108 debug.ScopeType.Script,
1110 debug.ScopeType.Global], exec_state); 1109 debug.ScopeType.Global], exec_state);
1111 CheckScopeContent({}, 1, exec_state); 1110 CheckScopeContent({}, 1, exec_state);
1112 CheckScopeChainNames([undefined, undefined, undefined], exec_state) 1111 CheckScopeChainNames(["m", undefined, undefined], exec_state)
1113 }; 1112 };
1114 1113
1115 (function() { 1114 (function() {
1116 "use strict"; 1115 "use strict";
1117 class C1 { 1116 class C1 {
1118 m() { 1117 m() {
1119 debugger; 1118 debugger;
1120 } 1119 }
1121 } 1120 }
1122 new C1().m(); 1121 new C1().m();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 debug.ScopeType.Global], exec_state); 1185 debug.ScopeType.Global], exec_state);
1187 CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start : 22, end: 145}, {}, {}], exec_state); 1186 CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start : 22, end: 145}, {}, {}], exec_state);
1188 } 1187 }
1189 eval(code3); 1188 eval(code3);
1190 EndTest(); 1189 EndTest();
1191 1190
1192 assertEquals(begin_test_count, break_count, 1191 assertEquals(begin_test_count, break_count,
1193 'one or more tests did not enter the debugger'); 1192 'one or more tests did not enter the debugger');
1194 assertEquals(begin_test_count, end_test_count, 1193 assertEquals(begin_test_count, end_test_count,
1195 'one or more tests did not have its result checked'); 1194 'one or more tests did not have its result checked');
OLDNEW
« no previous file with comments | « test/mjsunit/debug-function-scopes.js ('k') | test/mjsunit/regress/regress-592353.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698