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

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

Issue 2352593002: Preparse inner functions (new try) (Closed)
Patch Set: add comment Created 4 years, 2 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/lazy-inner-functions.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(names[i], scope.details().name()) 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 scope contains at least minimum_content. For functions just
161 // that there is a function. 161 // check that there is a function.
162 function CheckScopeContent(content, number, exec_state) { 162 function CheckScopeContent(minimum_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 minimum_count = 0;
165 for (var p in content) { 165 for (var p in minimum_content) {
166 var property_mirror = scope.scopeObject().property(p); 166 var property_mirror = scope.scopeObject().property(p);
167 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); 167 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope');
168 if (typeof(content[p]) === 'function') { 168 if (typeof(minimum_content[p]) === 'function') {
169 assertTrue(property_mirror.value().isFunction()); 169 assertTrue(property_mirror.value().isFunction());
170 } else { 170 } else {
171 assertEquals(content[p], property_mirror.value().value(), 'property ' + p + ' has unexpected value'); 171 assertEquals(minimum_content[p], property_mirror.value().value(), 'propert y ' + p + ' has unexpected value');
172 } 172 }
173 count++; 173 minimum_count++;
174 } 174 }
175 175
176 // 'arguments' and might be exposed in the local and closure scope. Just 176 // 'arguments' and might be exposed in the local and closure scope. Just
177 // ignore this. 177 // ignore this.
178 var scope_size = scope.scopeObject().properties().length; 178 var scope_size = scope.scopeObject().properties().length;
179 if (!scope.scopeObject().property('arguments').isUndefined()) { 179 if (!scope.scopeObject().property('arguments').isUndefined()) {
180 scope_size--; 180 scope_size--;
181 } 181 }
182 // Ditto for 'this'. 182 // Ditto for 'this'.
183 if (!scope.scopeObject().property('this').isUndefined()) { 183 if (!scope.scopeObject().property('this').isUndefined()) {
184 scope_size--; 184 scope_size--;
185 } 185 }
186 // Temporary variables introduced by the parser have not been materialized. 186 // Temporary variables introduced by the parser have not been materialized.
187 assertTrue(scope.scopeObject().property('').isUndefined()); 187 assertTrue(scope.scopeObject().property('').isUndefined());
188 188
189 if (count != scope_size) { 189 if (scope_size < minimum_count) {
190 print('Names found in scope:'); 190 print('Names found in scope:');
191 var names = scope.scopeObject().propertyNames(); 191 var names = scope.scopeObject().propertyNames();
192 for (var i = 0; i < names.length; i++) { 192 for (var i = 0; i < names.length; i++) {
193 print(names[i]); 193 print(names[i]);
194 } 194 }
195 } 195 }
196 assertEquals(count, scope_size); 196 assertTrue(scope_size >= minimum_count);
197 197
198 // Get the debug command processor. 198 // Get the debug command processor.
199 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); 199 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
200 200
201 // Send a scope request for information on a single scope and check the 201 // Send a scope request for information on a single scope and check the
202 // result. 202 // result.
203 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{" number":'; 203 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{" number":';
204 request_json += scope.scopeIndex(); 204 request_json += scope.scopeIndex();
205 request_json += '}}'; 205 request_json += '}}';
206 var response_json = dcp.processDebugJSONRequest(request_json); 206 var response_json = dcp.processDebugJSONRequest(request_json);
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 debug.ScopeType.Global], exec_state); 1278 debug.ScopeType.Global], exec_state);
1279 CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}, {}, {} ], exec_state); 1279 CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}, {}, {} ], exec_state);
1280 } 1280 }
1281 eval(code8); 1281 eval(code8);
1282 EndTest(); 1282 EndTest();
1283 1283
1284 assertEquals(begin_test_count, break_count, 1284 assertEquals(begin_test_count, break_count,
1285 'one or more tests did not enter the debugger'); 1285 'one or more tests did not enter the debugger');
1286 assertEquals(begin_test_count, end_test_count, 1286 assertEquals(begin_test_count, end_test_count,
1287 'one or more tests did not have its result checked'); 1287 '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/lazy-inner-functions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698