OLD | NEW |
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 'service_test_common.dart'; | 9 import 'service_test_common.dart'; |
10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 var loc = | 143 var loc = |
144 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named'); | 144 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named'); |
145 expect(loc.valid, isTrue); | 145 expect(loc.valid, isTrue); |
146 // TODO(turnidge): Printing a constructor currently adds | 146 // TODO(turnidge): Printing a constructor currently adds |
147 // another class qualifier at the front. Do we want to change | 147 // another class qualifier at the front. Do we want to change |
148 // this to be more consistent? | 148 // this to be more consistent? |
149 expect(loc.toString(), equals( | 149 expect(loc.toString(), equals( |
150 'DebuggerLocationTestFoo.DebuggerLocationTestFoo.named')); | 150 'DebuggerLocationTestFoo.DebuggerLocationTestFoo.named')); |
151 }, | 151 }, |
152 | 152 |
153 // Parse method | |
154 (Isolate isolate) async { | |
155 var debugger = await initDebugger(isolate); | |
156 var loc = | |
157 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.method'); | |
158 expect(loc.valid, isTrue); | |
159 expect(loc.toString(), equals('DebuggerLocationTestFoo.method')); | |
160 }, | |
161 | |
162 // Parse method | |
163 (Isolate isolate) async { | |
164 var debugger = await initDebugger(isolate); | |
165 var loc = | |
166 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.field='); | |
167 expect(loc.valid, isTrue); | |
168 expect(loc.toString(), equals('DebuggerLocationTestFoo.field=')); | |
169 }, | |
170 | |
171 // Parse bad method | |
172 (Isolate isolate) async { | |
173 var debugger = await initDebugger(isolate); | |
174 var loc = | |
175 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.missing'); | |
176 expect(loc.valid, isFalse); | |
177 expect(loc.toString(), equals( | |
178 'invalid source location ' | |
179 '(Function \'DebuggerLocationTestFoo.missing\' not found)')); | |
180 }, | |
181 | |
182 // Complete function + script | |
183 (Isolate isolate) async { | |
184 var debugger = await initDebugger(isolate); | |
185 var completions = await DebuggerLocation.complete(debugger, 'debugger_loc'); | |
186 expect(completions.toString(), equals( | |
187 '[debugger_location_dummy_function,' | |
188 ' debugger_location.dart:,' | |
189 ' debugger_location_test.dart:]')); | |
190 }, | |
191 | |
192 // Complete class | |
193 (Isolate isolate) async { | |
194 var debugger = await initDebugger(isolate); | |
195 var completions = | |
196 await DebuggerLocation.complete(debugger, 'DebuggerLocationTe'); | |
197 expect(completions.toString(), equals( | |
198 '[DebuggerLocationTestBar,' | |
199 ' DebuggerLocationTestFoo]')); | |
200 }, | |
201 | |
202 // No completions: unqualified name | |
203 (Isolate isolate) async { | |
204 var debugger = await initDebugger(isolate); | |
205 var completions = | |
206 await DebuggerLocation.complete(debugger, 'debugger_locXYZZY'); | |
207 expect(completions.toString(), equals('[]')); | |
208 }, | |
209 | |
210 // Complete method | |
211 (Isolate isolate) async { | |
212 var debugger = await initDebugger(isolate); | |
213 var completions = | |
214 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.m'); | |
215 expect(completions.toString(), equals( | |
216 '[DebuggerLocationTestFoo.madness,' | |
217 ' DebuggerLocationTestFoo.method]')); | |
218 }, | |
219 | |
220 // No completions: qualified name | |
221 (Isolate isolate) async { | |
222 var debugger = await initDebugger(isolate); | |
223 var completions = | |
224 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q'); | |
225 expect(completions.toString(), equals('[]')); | |
226 }, | |
227 | |
228 // Complete script | |
229 (Isolate isolate) async { | |
230 var debugger = await initDebugger(isolate); | |
231 var completions = | |
232 await DebuggerLocation.complete(debugger, 'debugger_location_te'); | |
233 expect(completions.toString(), equals( | |
234 '[debugger_location_test.dart:]')); | |
235 }, | |
236 | |
237 // Complete script:line | |
238 (Isolate isolate) async { | |
239 var debugger = await initDebugger(isolate); | |
240 var completions = | |
241 await DebuggerLocation.complete(debugger, | |
242 'debugger_location_test.dart:11'); | |
243 expect(completions.toString(), equals( | |
244 '[debugger_location_test.dart:${LINE_B + 0} ,' | |
245 ' debugger_location_test.dart:${LINE_B + 0}:,' | |
246 ' debugger_location_test.dart:${LINE_B + 1} ,' | |
247 ' debugger_location_test.dart:${LINE_B + 1}:,' | |
248 ' debugger_location_test.dart:${LINE_B + 2} ,' | |
249 ' debugger_location_test.dart:${LINE_B + 2}:,' | |
250 ' debugger_location_test.dart:${LINE_B + 3} ,' | |
251 ' debugger_location_test.dart:${LINE_B + 3}:,' | |
252 ' debugger_location_test.dart:${LINE_B + 4} ,' | |
253 ' debugger_location_test.dart:${LINE_B + 4}:,' | |
254 ' debugger_location_test.dart:${LINE_B + 5} ,' | |
255 ' debugger_location_test.dart:${LINE_B + 5}:]')); | |
256 }, | |
257 | |
258 // Complete script:line:col | |
259 (Isolate isolate) async { | |
260 var debugger = await initDebugger(isolate); | |
261 var completions = | |
262 await DebuggerLocation.complete(debugger, | |
263 'debugger_location_test.dart:$LINE_C:2'); | |
264 expect(completions.toString(), equals( | |
265 '[debugger_location_test.dart:$LINE_C:2 ,' | |
266 ' debugger_location_test.dart:$LINE_C:20 ,' | |
267 ' debugger_location_test.dart:$LINE_C:21 ,' | |
268 ' debugger_location_test.dart:$LINE_C:22 ,' | |
269 ' debugger_location_test.dart:$LINE_C:23 ,' | |
270 ' debugger_location_test.dart:$LINE_C:24 ]')); | |
271 }, | |
272 | |
273 // Complete without the script name. | |
274 (Isolate isolate) async { | |
275 var debugger = await initDebugger(isolate); | |
276 var completions = await DebuggerLocation.complete(debugger, '$LINE_C:2'); | |
277 expect(completions.toString(), equals( | |
278 '[debugger_location_test.dart:$LINE_C:2 ,' | |
279 ' debugger_location_test.dart:$LINE_C:20 ,' | |
280 ' debugger_location_test.dart:$LINE_C:21 ,' | |
281 ' debugger_location_test.dart:$LINE_C:22 ,' | |
282 ' debugger_location_test.dart:$LINE_C:23 ,' | |
283 ' debugger_location_test.dart:$LINE_C:24 ]')); | |
284 }, | |
285 | |
286 ]; | 153 ]; |
287 | 154 |
288 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 155 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
OLD | NEW |