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

Side by Side Diff: runtime/observatory/tests/service/debugger_location_test.dart

Issue 1393523002: Support tab completion of line:col in the debugger. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix warnings and other issues Created 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 import 'package:observatory/service_io.dart'; 6 import 'package:observatory/service_io.dart';
7 import 'package:observatory/debugger.dart'; 7 import 'package:observatory/debugger.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return isolate.getStack().then((stack) { 48 return isolate.getStack().then((stack) {
49 return new TestDebugger(isolate, stack); 49 return new TestDebugger(isolate, stack);
50 }); 50 });
51 } 51 }
52 52
53 var tests = [ 53 var tests = [
54 54
55 hasStoppedAtBreakpoint, 55 hasStoppedAtBreakpoint,
56 56
57 // Parse '' => current position 57 // Parse '' => current position
58 (Isolate isolate) { 58 (Isolate isolate) async {
59 return initDebugger(isolate).then((debugger) { 59 var debugger = await initDebugger(isolate);
60 return DebuggerLocation.parse(debugger, '').then((DebuggerLocation loc) { 60 var loc = await DebuggerLocation.parse(debugger, '');
61 expect(loc.valid, isTrue); 61 expect(loc.valid, isTrue);
62 expect(loc.toString(), equals('debugger_location_test.dart:17:5')); 62 expect(loc.toString(), equals('debugger_location_test.dart:17:5'));
63 });
64 });
65 }, 63 },
66 64
67 // Parse line 65 // Parse line
68 (Isolate isolate) { 66 (Isolate isolate) async {
69 return initDebugger(isolate).then((debugger) { 67 var debugger = await initDebugger(isolate);
70 return DebuggerLocation.parse(debugger, '18').then((DebuggerLocation loc) { 68 var loc = await DebuggerLocation.parse(debugger, '18');
71 expect(loc.valid, isTrue); 69 expect(loc.valid, isTrue);
72 expect(loc.toString(), equals('debugger_location_test.dart:18')); 70 expect(loc.toString(), equals('debugger_location_test.dart:18'));
73 });
74 });
75 }, 71 },
76 72
77 // Parse line + col 73 // Parse line + col
78 (Isolate isolate) { 74 (Isolate isolate) async {
79 return initDebugger(isolate).then((debugger) { 75 var debugger = await initDebugger(isolate);
80 return DebuggerLocation.parse(debugger, '16:11').then((DebuggerLocation loc) { 76 var loc = await DebuggerLocation.parse(debugger, '16:11');
81 expect(loc.valid, isTrue); 77 expect(loc.valid, isTrue);
82 expect(loc.toString(), equals('debugger_location_test.dart:16:11')); 78 expect(loc.toString(), equals('debugger_location_test.dart:16:11'));
83 });
84 });
85 }, 79 },
86 80
87 // Parse script + line 81 // Parse script + line
88 (Isolate isolate) { 82 (Isolate isolate) async {
89 return initDebugger(isolate).then((debugger) { 83 var debugger = await initDebugger(isolate);
90 return DebuggerLocation.parse(debugger, 'unittest.dart:15') 84 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15');
91 .then((DebuggerLocation loc) { 85 expect(loc.valid, isTrue);
92 expect(loc.valid, isTrue); 86 expect(loc.toString(), equals('unittest.dart:15'));
93 expect(loc.toString(), equals('unittest.dart:15'));
94 });
95 });
96 }, 87 },
97 88
98 // Parse script + line + col 89 // Parse script + line + col
99 (Isolate isolate) { 90 (Isolate isolate) async {
100 return initDebugger(isolate).then((debugger) { 91 var debugger = await initDebugger(isolate);
101 return DebuggerLocation.parse(debugger, 'unittest.dart:15:10') 92 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15:10');
102 .then((DebuggerLocation loc) { 93 expect(loc.valid, isTrue);
103 expect(loc.valid, isTrue); 94 expect(loc.toString(), equals('unittest.dart:15:10'));
104 expect(loc.toString(), equals('unittest.dart:15:10'));
105 });
106 });
107 }, 95 },
108 96
109 // Parse bad script 97 // Parse bad script
110 (Isolate isolate) { 98 (Isolate isolate) async {
111 return initDebugger(isolate).then((debugger) { 99 var debugger = await initDebugger(isolate);
112 return DebuggerLocation.parse(debugger, 'bad.dart:15') 100 var loc = await DebuggerLocation.parse(debugger, 'bad.dart:15');
113 .then((DebuggerLocation loc) { 101 expect(loc.valid, isFalse);
114 expect(loc.valid, isFalse); 102 expect(loc.toString(), equals(
115 expect(loc.toString(), equals( 103 'invalid source location (Script \'bad.dart\' not found)'));
116 'invalid source location (Script \'bad.dart\' not found)'));
117 });
118 });
119 }, 104 },
120 105
121 // Parse function 106 // Parse function
122 (Isolate isolate) { 107 (Isolate isolate) async {
123 return initDebugger(isolate).then((debugger) { 108 var debugger = await initDebugger(isolate);
124 return DebuggerLocation.parse(debugger, 'testFunction') 109 var loc = await DebuggerLocation.parse(debugger, 'testFunction');
125 .then((DebuggerLocation loc) { 110 expect(loc.valid, isTrue);
126 expect(loc.valid, isTrue); 111 expect(loc.toString(), equals('testFunction'));
127 expect(loc.toString(), equals('testFunction'));
128 });
129 });
130 }, 112 },
131 113
132 // Parse bad function 114 // Parse bad function
133 (Isolate isolate) { 115 (Isolate isolate) async {
134 return initDebugger(isolate).then((debugger) { 116 var debugger = await initDebugger(isolate);
135 return DebuggerLocation.parse(debugger, 'doesNotReallyExit') 117 var loc = await DebuggerLocation.parse(debugger, 'doesNotReallyExist');
136 .then((DebuggerLocation loc) { 118 expect(loc.valid, isFalse);
137 expect(loc.valid, isFalse); 119 expect(loc.toString(), equals(
138 expect(loc.toString(), equals( 120 'invalid source location (Function \'doesNotReallyExist\' not found)'));
139 'invalid source location (Function \'doesNotReallyExit\' not found)' ));
140 });
141 });
142 }, 121 },
143 122
144 // Parse constructor 123 // Parse constructor
145 (Isolate isolate) { 124 (Isolate isolate) async {
146 return initDebugger(isolate).then((debugger) { 125 var debugger = await initDebugger(isolate);
147 return DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo') 126 var loc = await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo');
148 .then((DebuggerLocation loc) { 127 expect(loc.valid, isTrue);
149 expect(loc.valid, isTrue); 128 // TODO(turnidge): Printing a constructor currently adds
150 // TODO(turnidge): Printing a constructor currently adds 129 // another class qualifier at the front. Do we want to change
151 // another class qualifier at the front. Do we want to change 130 // this to be more consistent?
152 // this to be more consistent? 131 expect(loc.toString(), equals(
153 expect(loc.toString(), equals( 132 'DebuggerLocationTestFoo.DebuggerLocationTestFoo'));
154 'DebuggerLocationTestFoo.DebuggerLocationTestFoo'));
155 });
156 });
157 }, 133 },
158 134
159 // Parse named constructor 135 // Parse named constructor
160 (Isolate isolate) { 136 (Isolate isolate) async {
161 return initDebugger(isolate).then((debugger) { 137 var debugger = await initDebugger(isolate);
162 return DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named') 138 var loc =
163 .then((DebuggerLocation loc) { 139 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named');
164 expect(loc.valid, isTrue); 140 expect(loc.valid, isTrue);
165 // TODO(turnidge): Printing a constructor currently adds 141 // TODO(turnidge): Printing a constructor currently adds
166 // another class qualifier at the front. Do we want to change 142 // another class qualifier at the front. Do we want to change
167 // this to be more consistent? 143 // this to be more consistent?
168 expect(loc.toString(), equals( 144 expect(loc.toString(), equals(
169 'DebuggerLocationTestFoo.DebuggerLocationTestFoo.named')); 145 'DebuggerLocationTestFoo.DebuggerLocationTestFoo.named'));
170 });
171 });
172 }, 146 },
173 147
174 // Parse method 148 // Parse method
175 (Isolate isolate) { 149 (Isolate isolate) async {
176 return initDebugger(isolate).then((debugger) { 150 var debugger = await initDebugger(isolate);
177 return DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.method') 151 var loc =
178 .then((DebuggerLocation loc) { 152 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.method');
179 expect(loc.valid, isTrue); 153 expect(loc.valid, isTrue);
180 expect(loc.toString(), equals('DebuggerLocationTestFoo.method')); 154 expect(loc.toString(), equals('DebuggerLocationTestFoo.method'));
181 });
182 });
183 }, 155 },
184 156
185 // Parse method 157 // Parse method
186 (Isolate isolate) { 158 (Isolate isolate) async {
187 return initDebugger(isolate).then((debugger) { 159 var debugger = await initDebugger(isolate);
188 return DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.field=') 160 var loc =
189 .then((DebuggerLocation loc) { 161 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.field=');
190 expect(loc.valid, isTrue); 162 expect(loc.valid, isTrue);
191 expect(loc.toString(), equals('DebuggerLocationTestFoo.field=')); 163 expect(loc.toString(), equals('DebuggerLocationTestFoo.field='));
192 });
193 });
194 }, 164 },
195 165
196 // Parse bad method 166 // Parse bad method
197 (Isolate isolate) { 167 (Isolate isolate) async {
198 return initDebugger(isolate).then((debugger) { 168 var debugger = await initDebugger(isolate);
199 return DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.missing') 169 var loc =
200 .then((DebuggerLocation loc) { 170 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.missing');
201 expect(loc.valid, isFalse); 171 expect(loc.valid, isFalse);
202 expect(loc.toString(), equals( 172 expect(loc.toString(), equals(
203 'invalid source location ' 173 'invalid source location '
204 '(Function \'DebuggerLocationTestFoo.missing\' not found)')); 174 '(Function \'DebuggerLocationTestFoo.missing\' not found)'));
205 });
206 });
207 }, 175 },
208 176
209 // Complete function + script 177 // Complete function + script
210 (Isolate isolate) { 178 (Isolate isolate) async {
211 return initDebugger(isolate).then((debugger) { 179 var debugger = await initDebugger(isolate);
212 return DebuggerLocation.complete(debugger, 'debugger_loc') 180 var completions = await DebuggerLocation.complete(debugger, 'debugger_loc');
213 .then((List<String> completions) { 181 expect(completions.toString(), equals(
214 expect(completions.toString(), equals( 182 '[debugger_location_dummy_function,'
215 '[debugger_location_dummy_function, ' 183 ' debugger_location.dart:,'
216 'debugger_location.dart:, debugger_location_test.dart:]')); 184 ' debugger_location_test.dart:]'));
217 });
218 });
219 }, 185 },
220 186
221 // Complete class 187 // Complete class
222 (Isolate isolate) { 188 (Isolate isolate) async {
223 return initDebugger(isolate).then((debugger) { 189 var debugger = await initDebugger(isolate);
224 return DebuggerLocation.complete(debugger, 'DebuggerLocationTe') 190 var completions =
225 .then((List<String> completions) { 191 await DebuggerLocation.complete(debugger, 'DebuggerLocationTe');
226 expect(completions.toString(), equals( 192 expect(completions.toString(), equals(
227 '[DebuggerLocationTestBar, DebuggerLocationTestFoo]')); 193 '[DebuggerLocationTestBar,'
228 }); 194 ' DebuggerLocationTestFoo]'));
229 });
230 }, 195 },
231 196
232 // No completions: unqualified name 197 // No completions: unqualified name
233 (Isolate isolate) { 198 (Isolate isolate) async {
234 return initDebugger(isolate).then((debugger) { 199 var debugger = await initDebugger(isolate);
235 return DebuggerLocation.complete(debugger, 'debugger_locXYZZY') 200 var completions =
236 .then((List<String> completions) { 201 await DebuggerLocation.complete(debugger, 'debugger_locXYZZY');
237 expect(completions.toString(), equals('[]')); 202 expect(completions.toString(), equals('[]'));
238 });
239 });
240 }, 203 },
241 204
242 // Complete method 205 // Complete method
243 (Isolate isolate) { 206 (Isolate isolate) async {
244 return initDebugger(isolate).then((debugger) { 207 var debugger = await initDebugger(isolate);
245 return DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.m') 208 var completions =
246 .then((List<String> completions) { 209 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.m');
247 expect(completions.toString(), equals( 210 expect(completions.toString(), equals(
248 '[DebuggerLocationTestFoo.madness, DebuggerLocationTestFoo.method]')); 211 '[DebuggerLocationTestFoo.madness,'
249 }); 212 ' DebuggerLocationTestFoo.method]'));
250 });
251 }, 213 },
252 214
253 // No completions: qualified name 215 // No completions: qualified name
254 (Isolate isolate) { 216 (Isolate isolate) async {
255 return initDebugger(isolate).then((debugger) { 217 var debugger = await initDebugger(isolate);
256 return DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q') 218 var completions =
257 .then((List<String> completions) { 219 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q');
258 expect(completions.toString(), equals('[]')); 220 expect(completions.toString(), equals('[]'));
259 }); 221 },
260 }); 222
223 // Complete script
224 (Isolate isolate) async {
225 var debugger = await initDebugger(isolate);
226 var completions =
227 await DebuggerLocation.complete(debugger, 'debugger_location_te');
228 expect(completions.toString(), equals(
229 '[debugger_location_test.dart:]'));
230 },
231
232 // Complete script:line
233 (Isolate isolate) async {
234 var debugger = await initDebugger(isolate);
235 var completions =
236 await DebuggerLocation.complete(debugger,
237 'debugger_location_test.dart:11');
238 expect(completions.toString(), equals(
239 '[debugger_location_test.dart:11 ,'
240 ' debugger_location_test.dart:11:,'
241 ' debugger_location_test.dart:110 ,'
242 ' debugger_location_test.dart:110:,'
243 ' debugger_location_test.dart:111 ,'
244 ' debugger_location_test.dart:111:,'
245 ' debugger_location_test.dart:112 ,'
246 ' debugger_location_test.dart:112:,'
247 ' debugger_location_test.dart:115 ,'
248 ' debugger_location_test.dart:115:,'
249 ' debugger_location_test.dart:116 ,'
250 ' debugger_location_test.dart:116:,'
251 ' debugger_location_test.dart:117 ,'
252 ' debugger_location_test.dart:117:,'
253 ' debugger_location_test.dart:118 ,'
254 ' debugger_location_test.dart:118:,'
255 ' debugger_location_test.dart:119 ,'
256 ' debugger_location_test.dart:119:]'));
257 },
258
259 // Complete script:line:col
260 (Isolate isolate) async {
261 var debugger = await initDebugger(isolate);
262 var completions =
263 await DebuggerLocation.complete(debugger,
264 'debugger_location_test.dart:11:2');
265 expect(completions.toString(), equals(
266 '[debugger_location_test.dart:11:2 ,'
267 ' debugger_location_test.dart:11:20 ,'
268 ' debugger_location_test.dart:11:21 ,'
269 ' debugger_location_test.dart:11:22 ,'
270 ' debugger_location_test.dart:11:23 ,'
271 ' debugger_location_test.dart:11:24 ]'));
272 },
273
274 // Complete without the script name.
275 (Isolate isolate) async {
276 var debugger = await initDebugger(isolate);
277 var completions = await DebuggerLocation.complete(debugger, '11:2');
278 expect(completions.toString(), equals(
279 '[debugger_location_test.dart:11:2 ,'
280 ' debugger_location_test.dart:11:20 ,'
281 ' debugger_location_test.dart:11:21 ,'
282 ' debugger_location_test.dart:11:22 ,'
283 ' debugger_location_test.dart:11:23 ,'
284 ' debugger_location_test.dart:11:24 ]'));
261 }, 285 },
262 286
263 ]; 287 ];
264 288
265 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 289 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698