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

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

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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 | « test/mjsunit/debug-return-value.js ('k') | test/mjsunit/debug-script.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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 460
461 // Simple closure formed by returning an inner function referering the outer 461 // Simple closure formed by returning an inner function referering the outer
462 // functions arguments. 462 // functions arguments.
463 BeginTest("Closure 1"); 463 BeginTest("Closure 1");
464 464
465 function closure_1(a) { 465 function closure_1(a) {
466 function f() { 466 function f() {
467 debugger; 467 debugger;
468 return a; 468 return a;
469 }; 469 }
470 return f; 470 return f;
471 } 471 }
472 472
473 listener_delegate = function(exec_state) { 473 listener_delegate = function(exec_state) {
474 CheckScopeChain([debug.ScopeType.Local, 474 CheckScopeChain([debug.ScopeType.Local,
475 debug.ScopeType.Closure, 475 debug.ScopeType.Closure,
476 debug.ScopeType.Global], exec_state); 476 debug.ScopeType.Global], exec_state);
477 CheckScopeContent({a:1}, 1, exec_state); 477 CheckScopeContent({a:1}, 1, exec_state);
478 }; 478 };
479 closure_1(1)(); 479 closure_1(1)();
480 EndTest(); 480 EndTest();
481 481
482 482
483 // Simple closure formed by returning an inner function referering the outer 483 // Simple closure formed by returning an inner function referering the outer
484 // functions arguments. Due to VM optimizations parts of the actual closure is 484 // functions arguments. Due to VM optimizations parts of the actual closure is
485 // missing from the debugger information. 485 // missing from the debugger information.
486 BeginTest("Closure 2"); 486 BeginTest("Closure 2");
487 487
488 function closure_2(a, b) { 488 function closure_2(a, b) {
489 var x = a + 2; 489 var x = a + 2;
490 var y = b + 2; 490 var y = b + 2;
491 function f() { 491 function f() {
492 debugger; 492 debugger;
493 return a + x; 493 return a + x;
494 }; 494 }
495 return f; 495 return f;
496 } 496 }
497 497
498 listener_delegate = function(exec_state) { 498 listener_delegate = function(exec_state) {
499 CheckScopeChain([debug.ScopeType.Local, 499 CheckScopeChain([debug.ScopeType.Local,
500 debug.ScopeType.Closure, 500 debug.ScopeType.Closure,
501 debug.ScopeType.Global], exec_state); 501 debug.ScopeType.Global], exec_state);
502 CheckScopeContent({a:1,x:3}, 1, exec_state); 502 CheckScopeContent({a:1,x:3}, 1, exec_state);
503 }; 503 };
504 closure_2(1, 2)(); 504 closure_2(1, 2)();
505 EndTest(); 505 EndTest();
506 506
507 507
508 // Simple closure formed by returning an inner function referering the outer 508 // Simple closure formed by returning an inner function referering the outer
509 // functions arguments. Using all arguments and locals from the outer function 509 // functions arguments. Using all arguments and locals from the outer function
510 // in the inner function makes these part of the debugger information on the 510 // in the inner function makes these part of the debugger information on the
511 // closure. 511 // closure.
512 BeginTest("Closure 3"); 512 BeginTest("Closure 3");
513 513
514 function closure_3(a, b) { 514 function closure_3(a, b) {
515 var x = a + 2; 515 var x = a + 2;
516 var y = b + 2; 516 var y = b + 2;
517 function f() { 517 function f() {
518 debugger; 518 debugger;
519 return a + b + x + y; 519 return a + b + x + y;
520 }; 520 }
521 return f; 521 return f;
522 } 522 }
523 523
524 listener_delegate = function(exec_state) { 524 listener_delegate = function(exec_state) {
525 CheckScopeChain([debug.ScopeType.Local, 525 CheckScopeChain([debug.ScopeType.Local,
526 debug.ScopeType.Closure, 526 debug.ScopeType.Closure,
527 debug.ScopeType.Global], exec_state); 527 debug.ScopeType.Global], exec_state);
528 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); 528 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
529 }; 529 };
530 closure_3(1, 2)(); 530 closure_3(1, 2)();
531 EndTest(); 531 EndTest();
532 532
533 533
534 534
535 // Simple closure formed by returning an inner function referering the outer 535 // Simple closure formed by returning an inner function referering the outer
536 // functions arguments. Using all arguments and locals from the outer function 536 // functions arguments. Using all arguments and locals from the outer function
537 // in the inner function makes these part of the debugger information on the 537 // in the inner function makes these part of the debugger information on the
538 // closure. Use the inner function as well... 538 // closure. Use the inner function as well...
539 BeginTest("Closure 4"); 539 BeginTest("Closure 4");
540 540
541 function closure_4(a, b) { 541 function closure_4(a, b) {
542 var x = a + 2; 542 var x = a + 2;
543 var y = b + 2; 543 var y = b + 2;
544 function f() { 544 function f() {
545 debugger; 545 debugger;
546 if (f) { 546 if (f) {
547 return a + b + x + y; 547 return a + b + x + y;
548 } 548 }
549 }; 549 }
550 return f; 550 return f;
551 } 551 }
552 552
553 listener_delegate = function(exec_state) { 553 listener_delegate = function(exec_state) {
554 CheckScopeChain([debug.ScopeType.Local, 554 CheckScopeChain([debug.ScopeType.Local,
555 debug.ScopeType.Closure, 555 debug.ScopeType.Closure,
556 debug.ScopeType.Global], exec_state); 556 debug.ScopeType.Global], exec_state);
557 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); 557 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
558 }; 558 };
559 closure_4(1, 2)(); 559 closure_4(1, 2)();
560 EndTest(); 560 EndTest();
561 561
562 562
563 563
564 // Simple closure formed by returning an inner function referering the outer 564 // Simple closure formed by returning an inner function referering the outer
565 // functions arguments. In the presence of eval all arguments and locals 565 // functions arguments. In the presence of eval all arguments and locals
566 // (including the inner function itself) from the outer function becomes part of 566 // (including the inner function itself) from the outer function becomes part of
567 // the debugger infformation on the closure. 567 // the debugger infformation on the closure.
568 BeginTest("Closure 5"); 568 BeginTest("Closure 5");
569 569
570 function closure_5(a, b) { 570 function closure_5(a, b) {
571 var x = 3; 571 var x = 3;
572 var y = 4; 572 var y = 4;
573 function f() { 573 function f() {
574 eval(''); 574 eval('');
575 debugger; 575 debugger;
576 return 1; 576 return 1;
577 }; 577 }
578 return f; 578 return f;
579 } 579 }
580 580
581 listener_delegate = function(exec_state) { 581 listener_delegate = function(exec_state) {
582 CheckScopeChain([debug.ScopeType.Local, 582 CheckScopeChain([debug.ScopeType.Local,
583 debug.ScopeType.Closure, 583 debug.ScopeType.Closure,
584 debug.ScopeType.Global], exec_state); 584 debug.ScopeType.Global], exec_state);
585 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); 585 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
586 }; 586 };
587 closure_5(1, 2)(); 587 closure_5(1, 2)();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 var f = createClosure(0); 799 var f = createClosure(0);
800 f(); 800 f();
801 } 801 }
802 802
803 listener_delegate = function(exec_state) { 803 listener_delegate = function(exec_state) {
804 CheckScopeChain([debug.ScopeType.With, 804 CheckScopeChain([debug.ScopeType.With,
805 debug.ScopeType.Local, 805 debug.ScopeType.Local,
806 debug.ScopeType.Closure, 806 debug.ScopeType.Closure,
807 debug.ScopeType.Closure, 807 debug.ScopeType.Closure,
808 debug.ScopeType.Global], exec_state); 808 debug.ScopeType.Global], exec_state);
809 } 809 };
810 closure_in_with_3(); 810 closure_in_with_3();
811 EndTest(); 811 EndTest();
812 812
813 813
814 BeginTest("Closure inside With 4"); 814 BeginTest("Closure inside With 4");
815 listener_delegate = function(exec_state) { 815 listener_delegate = function(exec_state) {
816 CheckScopeChain([debug.ScopeType.Local, 816 CheckScopeChain([debug.ScopeType.Local,
817 debug.ScopeType.With, 817 debug.ScopeType.With,
818 debug.ScopeType.Global], exec_state); 818 debug.ScopeType.Global], exec_state);
819 CheckScopeContent({x: 2}, 0, exec_state); 819 CheckScopeContent({x: 2}, 0, exec_state);
(...skipping 17 matching lines...) Expand all
837 EndTest(); 837 EndTest();
838 838
839 839
840 BeginTest("Catch block 1"); 840 BeginTest("Catch block 1");
841 function catch_block_1() { 841 function catch_block_1() {
842 try { 842 try {
843 throw 'Exception'; 843 throw 'Exception';
844 } catch (e) { 844 } catch (e) {
845 debugger; 845 debugger;
846 } 846 }
847 }; 847 }
848 848
849 849
850 listener_delegate = function(exec_state) { 850 listener_delegate = function(exec_state) {
851 CheckScopeChain([debug.ScopeType.Catch, 851 CheckScopeChain([debug.ScopeType.Catch,
852 debug.ScopeType.Local, 852 debug.ScopeType.Local,
853 debug.ScopeType.Global], exec_state); 853 debug.ScopeType.Global], exec_state);
854 CheckScopeContent({e:'Exception'}, 0, exec_state); 854 CheckScopeContent({e:'Exception'}, 0, exec_state);
855 }; 855 };
856 catch_block_1(); 856 catch_block_1();
857 EndTest(); 857 EndTest();
858 858
859 859
860 BeginTest("Catch block 2"); 860 BeginTest("Catch block 2");
861 function catch_block_2() { 861 function catch_block_2() {
862 try { 862 try {
863 throw 'Exception'; 863 throw 'Exception';
864 } catch (e) { 864 } catch (e) {
865 with({n:10}) { 865 with({n:10}) {
866 debugger; 866 debugger;
867 } 867 }
868 } 868 }
869 }; 869 }
870 870
871 871
872 listener_delegate = function(exec_state) { 872 listener_delegate = function(exec_state) {
873 CheckScopeChain([debug.ScopeType.With, 873 CheckScopeChain([debug.ScopeType.With,
874 debug.ScopeType.Catch, 874 debug.ScopeType.Catch,
875 debug.ScopeType.Local, 875 debug.ScopeType.Local,
876 debug.ScopeType.Global], exec_state); 876 debug.ScopeType.Global], exec_state);
877 CheckScopeContent({n:10}, 0, exec_state); 877 CheckScopeContent({n:10}, 0, exec_state);
878 CheckScopeContent({e:'Exception'}, 1, exec_state); 878 CheckScopeContent({e:'Exception'}, 1, exec_state);
879 }; 879 };
880 catch_block_2(); 880 catch_block_2();
881 EndTest(); 881 EndTest();
882 882
883 883
884 BeginTest("Catch block 3"); 884 BeginTest("Catch block 3");
885 function catch_block_3() { 885 function catch_block_3() {
886 // Do eval to dynamically declare a local variable so that the context's 886 // Do eval to dynamically declare a local variable so that the context's
887 // extension slot is initialized with JSContextExtensionObject. 887 // extension slot is initialized with JSContextExtensionObject.
888 eval("var y = 78;"); 888 eval("var y = 78;");
889 try { 889 try {
890 throw 'Exception'; 890 throw 'Exception';
891 } catch (e) { 891 } catch (e) {
892 debugger; 892 debugger;
893 } 893 }
894 }; 894 }
895 895
896 896
897 listener_delegate = function(exec_state) { 897 listener_delegate = function(exec_state) {
898 CheckScopeChain([debug.ScopeType.Catch, 898 CheckScopeChain([debug.ScopeType.Catch,
899 debug.ScopeType.Local, 899 debug.ScopeType.Local,
900 debug.ScopeType.Global], exec_state); 900 debug.ScopeType.Global], exec_state);
901 CheckScopeContent({e:'Exception'}, 0, exec_state); 901 CheckScopeContent({e:'Exception'}, 0, exec_state);
902 CheckScopeContent({y:78}, 1, exec_state); 902 CheckScopeContent({y:78}, 1, exec_state);
903 }; 903 };
904 catch_block_3(); 904 catch_block_3();
905 EndTest(); 905 EndTest();
906 906
907 907
908 BeginTest("Catch block 4"); 908 BeginTest("Catch block 4");
909 function catch_block_4() { 909 function catch_block_4() {
910 // Do eval to dynamically declare a local variable so that the context's 910 // Do eval to dynamically declare a local variable so that the context's
911 // extension slot is initialized with JSContextExtensionObject. 911 // extension slot is initialized with JSContextExtensionObject.
912 eval("var y = 98;"); 912 eval("var y = 98;");
913 try { 913 try {
914 throw 'Exception'; 914 throw 'Exception';
915 } catch (e) { 915 } catch (e) {
916 with({n:10}) { 916 with({n:10}) {
917 debugger; 917 debugger;
918 } 918 }
919 } 919 }
920 }; 920 }
921 921
922 listener_delegate = function(exec_state) { 922 listener_delegate = function(exec_state) {
923 CheckScopeChain([debug.ScopeType.With, 923 CheckScopeChain([debug.ScopeType.With,
924 debug.ScopeType.Catch, 924 debug.ScopeType.Catch,
925 debug.ScopeType.Local, 925 debug.ScopeType.Local,
926 debug.ScopeType.Global], exec_state); 926 debug.ScopeType.Global], exec_state);
927 CheckScopeContent({n:10}, 0, exec_state); 927 CheckScopeContent({n:10}, 0, exec_state);
928 CheckScopeContent({e:'Exception'}, 1, exec_state); 928 CheckScopeContent({e:'Exception'}, 1, exec_state);
929 CheckScopeContent({y:98}, 2, exec_state); 929 CheckScopeContent({y:98}, 2, exec_state);
930 }; 930 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 971
972 // Catch block in function that is marked for optimization while being executed. 972 // Catch block in function that is marked for optimization while being executed.
973 BeginTest("Catch block 7"); 973 BeginTest("Catch block 7");
974 function catch_block_7() { 974 function catch_block_7() {
975 %OptimizeFunctionOnNextCall(catch_block_7); 975 %OptimizeFunctionOnNextCall(catch_block_7);
976 try { 976 try {
977 throw 'Exception'; 977 throw 'Exception';
978 } catch (e) { 978 } catch (e) {
979 debugger; 979 debugger;
980 } 980 }
981 }; 981 }
982 982
983 983
984 listener_delegate = function(exec_state) { 984 listener_delegate = function(exec_state) {
985 CheckScopeChain([debug.ScopeType.Catch, 985 CheckScopeChain([debug.ScopeType.Catch,
986 debug.ScopeType.Local, 986 debug.ScopeType.Local,
987 debug.ScopeType.Global], exec_state); 987 debug.ScopeType.Global], exec_state);
988 CheckScopeContent({e:'Exception'}, 0, exec_state); 988 CheckScopeContent({e:'Exception'}, 0, exec_state);
989 }; 989 };
990 catch_block_7(); 990 catch_block_7();
991 EndTest(); 991 EndTest();
992 992
993 993
994 assertEquals(begin_test_count, break_count, 994 assertEquals(begin_test_count, break_count,
995 'one or more tests did not enter the debugger'); 995 'one or more tests did not enter the debugger');
996 assertEquals(begin_test_count, end_test_count, 996 assertEquals(begin_test_count, end_test_count,
997 'one or more tests did not have its result checked'); 997 'one or more tests did not have its result checked');
OLDNEW
« no previous file with comments | « test/mjsunit/debug-return-value.js ('k') | test/mjsunit/debug-script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698