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

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

Issue 726643002: harmony-scoping: Implement debugger support for script scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nit + rebased Created 6 years, 1 month 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-evaluate-locals-optimized-double.js ('k') | test/mjsunit/debug-scopes.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 30 matching lines...) Expand all
41 assertEquals(expected, actual); 41 assertEquals(expected, actual);
42 } 42 }
43 } 43 }
44 44
45 // A copy of the scope types from mirror-debugger.js. 45 // A copy of the scope types from mirror-debugger.js.
46 var ScopeType = { Global: 0, 46 var ScopeType = { Global: 0,
47 Local: 1, 47 Local: 1,
48 With: 2, 48 With: 2,
49 Closure: 3, 49 Closure: 3,
50 Catch: 4, 50 Catch: 4,
51 Block: 5 }; 51 Block: 5,
52 Script: 6};
52 53
53 var f1 = (function F1(x) { 54 var f1 = (function F1(x) {
54 function F2(y) { 55 function F2(y) {
55 var z = x + y; 56 var z = x + y;
56 with ({w: 5, v: "Capybara"}) { 57 with ({w: 5, v: "Capybara"}) {
57 var F3 = function(a, b) { 58 var F3 = function(a, b) {
58 function F4(p) { 59 function F4(p) {
59 return p + a + b + z + w + v.length; 60 return p + a + b + z + w + v.length;
60 } 61 }
61 return F4; 62 return F4;
62 } 63 }
63 return F3(4, 5); 64 return F3(4, 5);
64 } 65 }
65 } 66 }
66 return F2(17); 67 return F2(17);
67 })(5); 68 })(5);
68 69
69 var mirror = Debug.MakeMirror(f1); 70 var mirror = Debug.MakeMirror(f1);
70 71
71 assertEquals(5, mirror.scopeCount()); 72 assertEquals(6, mirror.scopeCount());
72 73
73 CheckScope(mirror.scope(0), { a: 4, b: 5 }, ScopeType.Closure); 74 CheckScope(mirror.scope(0), { a: 4, b: 5 }, ScopeType.Closure);
74 CheckScope(mirror.scope(1), { w: 5, v: "Capybara" }, ScopeType.With); 75 CheckScope(mirror.scope(1), { w: 5, v: "Capybara" }, ScopeType.With);
75 CheckScope(mirror.scope(2), { y: 17, z: 22 }, ScopeType.Closure); 76 CheckScope(mirror.scope(2), { y: 17, z: 22 }, ScopeType.Closure);
76 CheckScope(mirror.scope(3), { x: 5 }, ScopeType.Closure); 77 CheckScope(mirror.scope(3), { x: 5 }, ScopeType.Closure);
77 CheckScope(mirror.scope(4), {}, ScopeType.Global); 78 CheckScope(mirror.scope(4), {}, ScopeType.Script);
79 CheckScope(mirror.scope(5), {}, ScopeType.Global);
78 80
79 var f2 = function() { return 5; } 81 var f2 = function() { return 5; }
80 82
81 var mirror = Debug.MakeMirror(f2); 83 var mirror = Debug.MakeMirror(f2);
82 84
83 assertEquals(1, mirror.scopeCount()); 85 assertEquals(2, mirror.scopeCount());
84 86
85 CheckScope(mirror.scope(0), {}, ScopeType.Global); 87 CheckScope(mirror.scope(0), {}, ScopeType.Script);
88 CheckScope(mirror.scope(1), {}, ScopeType.Global);
86 89
87 var f3 = (function F1(invisible_parameter) { 90 var f3 = (function F1(invisible_parameter) {
88 var invisible1 = 1; 91 var invisible1 = 1;
89 var visible1 = 10; 92 var visible1 = 10;
90 return (function F2() { 93 return (function F2() {
91 var invisible2 = 2; 94 var invisible2 = 2;
92 return (function F3() { 95 return (function F3() {
93 var visible2 = 20; 96 var visible2 = 20;
94 var invisible2 = 3; 97 var invisible2 = 3;
95 return (function () {return visible1 + visible2 + visible1a;}); 98 return (function () {return visible1 + visible2 + visible1a;});
96 })(); 99 })();
97 })(); 100 })();
98 })(5); 101 })(5);
99 102
100 var mirror = Debug.MakeMirror(f3); 103 var mirror = Debug.MakeMirror(f3);
101 104
102 assertEquals(3, mirror.scopeCount()); 105 assertEquals(4, mirror.scopeCount());
103 106
104 CheckScope(mirror.scope(0), { visible2: 20 }, ScopeType.Closure); 107 CheckScope(mirror.scope(0), { visible2: 20 }, ScopeType.Closure);
105 CheckScope(mirror.scope(1), { visible1: 10 }, ScopeType.Closure); 108 CheckScope(mirror.scope(1), { visible1: 10 }, ScopeType.Closure);
106 CheckScope(mirror.scope(2), {}, ScopeType.Global); 109 CheckScope(mirror.scope(2), {}, ScopeType.Script);
110 CheckScope(mirror.scope(3), {}, ScopeType.Global);
107 111
108 112
109 var f4 = (function One() { 113 var f4 = (function One() {
110 try { 114 try {
111 throw "I'm error 1"; 115 throw "I'm error 1";
112 } catch (e1) { 116 } catch (e1) {
113 try { 117 try {
114 throw "I'm error 2"; 118 throw "I'm error 2";
115 } catch (e2) { 119 } catch (e2) {
116 return function GetError() { 120 return function GetError() {
117 return e1 + e2; 121 return e1 + e2;
118 }; 122 };
119 } 123 }
120 } 124 }
121 })(); 125 })();
122 126
123 var mirror = Debug.MakeMirror(f4); 127 var mirror = Debug.MakeMirror(f4);
124 128
125 assertEquals(3, mirror.scopeCount()); 129 assertEquals(4, mirror.scopeCount());
126 130
127 CheckScope(mirror.scope(0), { e2: "I'm error 2" }, ScopeType.Catch); 131 CheckScope(mirror.scope(0), { e2: "I'm error 2" }, ScopeType.Catch);
128 CheckScope(mirror.scope(1), { e1: "I'm error 1" }, ScopeType.Catch); 132 CheckScope(mirror.scope(1), { e1: "I'm error 1" }, ScopeType.Catch);
129 CheckScope(mirror.scope(2), {}, ScopeType.Global); 133 CheckScope(mirror.scope(2), {}, ScopeType.Script);
134 CheckScope(mirror.scope(3), {}, ScopeType.Global);
130 135
131 136
132 var f5 = (function Raz(p1, p2) { 137 var f5 = (function Raz(p1, p2) {
133 var p3 = p1 + p2; 138 var p3 = p1 + p2;
134 return (function() { 139 return (function() {
135 var p4 = 20; 140 var p4 = 20;
136 var p5 = 21; 141 var p5 = 21;
137 var p6 = 22; 142 var p6 = 22;
138 return eval("(function(p7){return p1 + p4 + p6 + p7})"); 143 return eval("(function(p7){return p1 + p4 + p6 + p7})");
139 })(); 144 })();
140 })(1,2); 145 })(1,2);
141 146
142 var mirror = Debug.MakeMirror(f5); 147 var mirror = Debug.MakeMirror(f5);
143 148
144 assertEquals(3, mirror.scopeCount()); 149 assertEquals(4, mirror.scopeCount());
145 150
146 CheckScope(mirror.scope(0), { p4: 20, p6: 22 }, ScopeType.Closure); 151 CheckScope(mirror.scope(0), { p4: 20, p6: 22 }, ScopeType.Closure);
147 CheckScope(mirror.scope(1), { p1: 1 }, ScopeType.Closure); 152 CheckScope(mirror.scope(1), { p1: 1 }, ScopeType.Closure);
148 CheckScope(mirror.scope(2), {}, ScopeType.Global); 153 CheckScope(mirror.scope(2), {}, ScopeType.Script);
154 CheckScope(mirror.scope(3), {}, ScopeType.Global);
149 155
150 156
151 function CheckNoScopeVisible(f) { 157 function CheckNoScopeVisible(f) {
152 var mirror = Debug.MakeMirror(f); 158 var mirror = Debug.MakeMirror(f);
153 assertEquals(0, mirror.scopeCount()); 159 assertEquals(0, mirror.scopeCount());
154 } 160 }
155 161
156 CheckNoScopeVisible(Number); 162 CheckNoScopeVisible(Number);
157 163
158 CheckNoScopeVisible(Function.toString); 164 CheckNoScopeVisible(Function.toString);
159 165
160 // This getter is known to be implemented as closure. 166 // This getter is known to be implemented as closure.
161 CheckNoScopeVisible(new Error().__lookupGetter__("stack")); 167 CheckNoScopeVisible(new Error().__lookupGetter__("stack"));
OLDNEW
« no previous file with comments | « test/mjsunit/debug-evaluate-locals-optimized-double.js ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698