| 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 'test_helper.dart'; | 10 import 'test_helper.dart'; |
| 10 import 'dart:async'; | 11 import 'dart:async'; |
| 11 import 'dart:developer'; | 12 import 'dart:developer'; |
| 12 | 13 |
| 14 const int LINE_A = 22; |
| 15 const int LINE_B = 112; |
| 16 const int LINE_C = 12; |
| 17 |
| 13 void testFunction() { | 18 void testFunction() { |
| 14 int i = 0; | 19 int i = 0; |
| 15 while (i == 0) { | 20 while (i == 0) { |
| 16 debugger(); | 21 debugger(); |
| 17 print('loop'); | 22 print('loop'); // Line A. |
| 18 print('loop'); | 23 print('loop'); |
| 19 } | 24 } |
| 20 } | 25 } |
| 21 | 26 |
| 22 class TestDebugger extends Debugger { | 27 class TestDebugger extends Debugger { |
| 23 TestDebugger(this.isolate, this.stack); | 28 TestDebugger(this.isolate, this.stack); |
| 24 | 29 |
| 25 VM get vm => isolate.vm; | 30 VM get vm => isolate.vm; |
| 26 Isolate isolate; | 31 Isolate isolate; |
| 27 ServiceMap stack; | 32 ServiceMap stack; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 52 | 57 |
| 53 var tests = [ | 58 var tests = [ |
| 54 | 59 |
| 55 hasStoppedAtBreakpoint, | 60 hasStoppedAtBreakpoint, |
| 56 | 61 |
| 57 // Parse '' => current position | 62 // Parse '' => current position |
| 58 (Isolate isolate) async { | 63 (Isolate isolate) async { |
| 59 var debugger = await initDebugger(isolate); | 64 var debugger = await initDebugger(isolate); |
| 60 var loc = await DebuggerLocation.parse(debugger, ''); | 65 var loc = await DebuggerLocation.parse(debugger, ''); |
| 61 expect(loc.valid, isTrue); | 66 expect(loc.valid, isTrue); |
| 62 expect(loc.toString(), equals('debugger_location_test.dart:17:5')); | 67 expect(loc.toString(), equals('debugger_location_test.dart:$LINE_A:5')); |
| 63 }, | 68 }, |
| 64 | 69 |
| 65 // Parse line | 70 // Parse line |
| 66 (Isolate isolate) async { | 71 (Isolate isolate) async { |
| 67 var debugger = await initDebugger(isolate); | 72 var debugger = await initDebugger(isolate); |
| 68 var loc = await DebuggerLocation.parse(debugger, '18'); | 73 var loc = await DebuggerLocation.parse(debugger, '18'); |
| 69 expect(loc.valid, isTrue); | 74 expect(loc.valid, isTrue); |
| 70 expect(loc.toString(), equals('debugger_location_test.dart:18')); | 75 expect(loc.toString(), equals('debugger_location_test.dart:18')); |
| 71 }, | 76 }, |
| 72 | 77 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 '[debugger_location_test.dart:]')); | 234 '[debugger_location_test.dart:]')); |
| 230 }, | 235 }, |
| 231 | 236 |
| 232 // Complete script:line | 237 // Complete script:line |
| 233 (Isolate isolate) async { | 238 (Isolate isolate) async { |
| 234 var debugger = await initDebugger(isolate); | 239 var debugger = await initDebugger(isolate); |
| 235 var completions = | 240 var completions = |
| 236 await DebuggerLocation.complete(debugger, | 241 await DebuggerLocation.complete(debugger, |
| 237 'debugger_location_test.dart:11'); | 242 'debugger_location_test.dart:11'); |
| 238 expect(completions.toString(), equals( | 243 expect(completions.toString(), equals( |
| 239 '[debugger_location_test.dart:110 ,' | 244 '[debugger_location_test.dart:${LINE_B + 0} ,' |
| 240 ' debugger_location_test.dart:110:,' | 245 ' debugger_location_test.dart:${LINE_B + 0}:,' |
| 241 ' debugger_location_test.dart:111 ,' | 246 ' debugger_location_test.dart:${LINE_B + 1} ,' |
| 242 ' debugger_location_test.dart:111:,' | 247 ' debugger_location_test.dart:${LINE_B + 1}:,' |
| 243 ' debugger_location_test.dart:112 ,' | 248 ' debugger_location_test.dart:${LINE_B + 2} ,' |
| 244 ' debugger_location_test.dart:112:,' | 249 ' debugger_location_test.dart:${LINE_B + 2}:,' |
| 245 ' debugger_location_test.dart:115 ,' | 250 ' debugger_location_test.dart:${LINE_B + 3} ,' |
| 246 ' debugger_location_test.dart:115:,' | 251 ' debugger_location_test.dart:${LINE_B + 3}:,' |
| 247 ' debugger_location_test.dart:116 ,' | 252 ' debugger_location_test.dart:${LINE_B + 4} ,' |
| 248 ' debugger_location_test.dart:116:,' | 253 ' debugger_location_test.dart:${LINE_B + 4}:,' |
| 249 ' debugger_location_test.dart:117 ,' | 254 ' debugger_location_test.dart:${LINE_B + 5} ,' |
| 250 ' debugger_location_test.dart:117:,' | 255 ' debugger_location_test.dart:${LINE_B + 5}:]')); |
| 251 ' debugger_location_test.dart:118 ,' | |
| 252 ' debugger_location_test.dart:118:,' | |
| 253 ' debugger_location_test.dart:119 ,' | |
| 254 ' debugger_location_test.dart:119:]')); | |
| 255 }, | 256 }, |
| 256 | 257 |
| 257 // Complete script:line:col | 258 // Complete script:line:col |
| 258 (Isolate isolate) async { | 259 (Isolate isolate) async { |
| 259 var debugger = await initDebugger(isolate); | 260 var debugger = await initDebugger(isolate); |
| 260 var completions = | 261 var completions = |
| 261 await DebuggerLocation.complete(debugger, | 262 await DebuggerLocation.complete(debugger, |
| 262 'debugger_location_test.dart:11:2'); | 263 'debugger_location_test.dart:$LINE_C:2'); |
| 263 expect(completions.toString(), equals( | 264 expect(completions.toString(), equals( |
| 264 '[debugger_location_test.dart:11:2 ,' | 265 '[debugger_location_test.dart:$LINE_C:2 ,' |
| 265 ' debugger_location_test.dart:11:20 ,' | 266 ' debugger_location_test.dart:$LINE_C:20 ,' |
| 266 ' debugger_location_test.dart:11:21 ,' | 267 ' debugger_location_test.dart:$LINE_C:21 ,' |
| 267 ' debugger_location_test.dart:11:22 ,' | 268 ' debugger_location_test.dart:$LINE_C:22 ,' |
| 268 ' debugger_location_test.dart:11:23 ,' | 269 ' debugger_location_test.dart:$LINE_C:23 ,' |
| 269 ' debugger_location_test.dart:11:24 ]')); | 270 ' debugger_location_test.dart:$LINE_C:24 ]')); |
| 270 }, | 271 }, |
| 271 | 272 |
| 272 // Complete without the script name. | 273 // Complete without the script name. |
| 273 (Isolate isolate) async { | 274 (Isolate isolate) async { |
| 274 var debugger = await initDebugger(isolate); | 275 var debugger = await initDebugger(isolate); |
| 275 var completions = await DebuggerLocation.complete(debugger, '11:2'); | 276 var completions = await DebuggerLocation.complete(debugger, '$LINE_C:2'); |
| 276 expect(completions.toString(), equals( | 277 expect(completions.toString(), equals( |
| 277 '[debugger_location_test.dart:11:2 ,' | 278 '[debugger_location_test.dart:$LINE_C:2 ,' |
| 278 ' debugger_location_test.dart:11:20 ,' | 279 ' debugger_location_test.dart:$LINE_C:20 ,' |
| 279 ' debugger_location_test.dart:11:21 ,' | 280 ' debugger_location_test.dart:$LINE_C:21 ,' |
| 280 ' debugger_location_test.dart:11:22 ,' | 281 ' debugger_location_test.dart:$LINE_C:22 ,' |
| 281 ' debugger_location_test.dart:11:23 ,' | 282 ' debugger_location_test.dart:$LINE_C:23 ,' |
| 282 ' debugger_location_test.dart:11:24 ]')); | 283 ' debugger_location_test.dart:$LINE_C:24 ]')); |
| 283 }, | 284 }, |
| 284 | 285 |
| 285 ]; | 286 ]; |
| 286 | 287 |
| 287 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 288 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |