| 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=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --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:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 | 9 |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // silence analyzer. | 71 // silence analyzer. |
| 72 expect(math.sqrt(4), equals(2)); | 72 expect(math.sqrt(4), equals(2)); |
| 73 Library rootLib = await isolate.rootLibrary.load(); | 73 Library rootLib = await isolate.rootLibrary.load(); |
| 74 ServiceFunction function = | 74 ServiceFunction function = |
| 75 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); | 75 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
| 76 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); | 76 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
| 77 print("Breakpoint: $bpt"); | 77 print("Breakpoint: $bpt"); |
| 78 expect(bpt is Breakpoint, isTrue); // I.e, not null. | 78 expect(bpt is Breakpoint, isTrue); // I.e, not null. |
| 79 | 79 |
| 80 bool hitBreakpoint = false; | 80 bool hitBreakpoint = false; |
| 81 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 81 var sub; | 82 var sub; |
| 82 sub = isolate.vm.events.stream.listen((ServiceEvent event) async { | 83 sub = stream.listen((ServiceEvent event) async { |
| 83 print("Event $event"); | 84 print("Event $event"); |
| 84 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 85 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 85 var frameNumber = 1, r; | 86 var frameNumber = 1, r; |
| 86 r = await isolate.evalFrame(frameNumber, '123'); /// instance: ok | 87 r = await isolate.evalFrame(frameNumber, '123'); /// instance: ok |
| 87 expect(r.valueAsString, equals('123')); /// instance: continued | 88 expect(r.valueAsString, equals('123')); /// instance: continued |
| 88 r = await isolate.evalFrame(frameNumber, 'this'); /// scope: ok | 89 r = await isolate.evalFrame(frameNumber, 'this'); /// scope: ok |
| 89 expect(r.clazz.name, equals('C')); /// scope: continued | 90 expect(r.clazz.name, equals('C')); /// scope: continued |
| 90 r = await isolate.evalFrame(frameNumber, 'instVar'); /// instance: contin
ued | 91 r = await isolate.evalFrame(frameNumber, 'instVar'); /// instance: contin
ued |
| 91 expect(r.valueAsString, equals('1')); /// instance: continued | 92 expect(r.valueAsString, equals('1')); /// instance: continued |
| 92 r = await isolate.evalFrame(frameNumber, 'classVar'); /// instance: contin
ued | 93 r = await isolate.evalFrame(frameNumber, 'classVar'); /// instance: contin
ued |
| (...skipping 26 matching lines...) Expand all Loading... |
| 119 | 120 |
| 120 testMethod2(Isolate isolate) async { | 121 testMethod2(Isolate isolate) async { |
| 121 Library rootLib = await isolate.rootLibrary.load(); | 122 Library rootLib = await isolate.rootLibrary.load(); |
| 122 ServiceFunction function = | 123 ServiceFunction function = |
| 123 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); | 124 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
| 124 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); | 125 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
| 125 print("Breakpoint: $bpt"); | 126 print("Breakpoint: $bpt"); |
| 126 expect(bpt is Breakpoint, isTrue); // I.e, not null. | 127 expect(bpt is Breakpoint, isTrue); // I.e, not null. |
| 127 | 128 |
| 128 bool hitBreakpoint = false; | 129 bool hitBreakpoint = false; |
| 130 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 129 var sub; | 131 var sub; |
| 130 sub = isolate.vm.events.stream.listen((ServiceEvent event) async { | 132 sub = stream.listen((ServiceEvent event) async { |
| 131 print("Event $event"); | 133 print("Event $event"); |
| 132 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 134 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 133 var frameNumber = 1, r; | 135 var frameNumber = 1, r; |
| 134 r = await isolate.evalFrame(frameNumber, '123'); | 136 r = await isolate.evalFrame(frameNumber, '123'); |
| 135 expect(r.valueAsString, equals('123')); | 137 expect(r.valueAsString, equals('123')); |
| 136 r = await isolate.evalFrame(frameNumber, 'this'); | 138 r = await isolate.evalFrame(frameNumber, 'this'); |
| 137 expect(r is DartError, isTrue); | 139 expect(r is DartError, isTrue); |
| 138 r = await isolate.evalFrame(frameNumber, 'instVar'); | 140 r = await isolate.evalFrame(frameNumber, 'instVar'); |
| 139 expect(r is DartError, isTrue); | 141 expect(r is DartError, isTrue); |
| 140 r = await isolate.evalFrame(frameNumber, 'classVar'); | 142 r = await isolate.evalFrame(frameNumber, 'classVar'); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 167 | 169 |
| 168 testMethod3(Isolate isolate) async { | 170 testMethod3(Isolate isolate) async { |
| 169 Library rootLib = await isolate.rootLibrary.load(); | 171 Library rootLib = await isolate.rootLibrary.load(); |
| 170 ServiceFunction function = | 172 ServiceFunction function = |
| 171 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); | 173 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
| 172 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); | 174 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
| 173 print("Breakpoint: $bpt"); | 175 print("Breakpoint: $bpt"); |
| 174 expect(bpt is Breakpoint, isTrue); // I.e, not null. | 176 expect(bpt is Breakpoint, isTrue); // I.e, not null. |
| 175 | 177 |
| 176 bool hitBreakpoint = false; | 178 bool hitBreakpoint = false; |
| 179 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 177 var sub; | 180 var sub; |
| 178 sub = isolate.vm.events.stream.listen((ServiceEvent event) async { | 181 sub = stream.listen((ServiceEvent event) async { |
| 179 print("Event $event"); | 182 print("Event $event"); |
| 180 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 183 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 181 var frameNumber = 1, r; | 184 var frameNumber = 1, r; |
| 182 r = await isolate.evalFrame(frameNumber, '123'); | 185 r = await isolate.evalFrame(frameNumber, '123'); |
| 183 expect(r.valueAsString, equals('123')); | 186 expect(r.valueAsString, equals('123')); |
| 184 r = await isolate.evalFrame(frameNumber, 'this'); | 187 r = await isolate.evalFrame(frameNumber, 'this'); |
| 185 expect(r.clazz.name, equals('C')); | 188 expect(r.clazz.name, equals('C')); |
| 186 r = await isolate.evalFrame(frameNumber, 'instVar'); | 189 r = await isolate.evalFrame(frameNumber, 'instVar'); |
| 187 expect(r.valueAsString, equals('1')); | 190 expect(r.valueAsString, equals('1')); |
| 188 r = await isolate.evalFrame(frameNumber, 'classVar'); | 191 r = await isolate.evalFrame(frameNumber, 'classVar'); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 208 | 211 |
| 209 testMethod4(Isolate isolate) async { | 212 testMethod4(Isolate isolate) async { |
| 210 Library rootLib = await isolate.rootLibrary.load(); | 213 Library rootLib = await isolate.rootLibrary.load(); |
| 211 ServiceFunction function = | 214 ServiceFunction function = |
| 212 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); | 215 rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
| 213 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); | 216 Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
| 214 print("Breakpoint: $bpt"); | 217 print("Breakpoint: $bpt"); |
| 215 expect(bpt is Breakpoint, isTrue); // I.e, not null. | 218 expect(bpt is Breakpoint, isTrue); // I.e, not null. |
| 216 | 219 |
| 217 bool hitBreakpoint = false; | 220 bool hitBreakpoint = false; |
| 221 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 218 var sub; | 222 var sub; |
| 219 sub = isolate.vm.events.stream.listen((ServiceEvent event) async { | 223 sub = stream.listen((ServiceEvent event) async { |
| 220 print("Event $event"); | 224 print("Event $event"); |
| 221 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 225 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 222 var frameNumber = 1, r; | 226 var frameNumber = 1, r; |
| 223 r = await isolate.evalFrame(frameNumber, '123'); /// instance: continued | 227 r = await isolate.evalFrame(frameNumber, '123'); /// instance: continued |
| 224 expect(r.valueAsString, equals('123')); /// instance: continued | 228 expect(r.valueAsString, equals('123')); /// instance: continued |
| 225 r = await isolate.evalFrame(frameNumber, 'this'); /// scope: continued | 229 r = await isolate.evalFrame(frameNumber, 'this'); /// scope: continued |
| 226 expect(r.clazz.name, equals('C')); /// scope: continued | 230 expect(r.clazz.name, equals('C')); /// scope: continued |
| 227 r = await isolate.evalFrame(frameNumber, 'instVar'); /// instance: contin
ued | 231 r = await isolate.evalFrame(frameNumber, 'instVar'); /// instance: contin
ued |
| 228 expect(r.valueAsString, equals('1')); /// instance: continued | 232 expect(r.valueAsString, equals('1')); /// instance: continued |
| 229 r = await isolate.evalFrame(frameNumber, 'classVar'); /// instance: conti
nued | 233 r = await isolate.evalFrame(frameNumber, 'classVar'); /// instance: conti
nued |
| (...skipping 26 matching lines...) Expand all Loading... |
| 256 } | 260 } |
| 257 | 261 |
| 258 var tests = [ | 262 var tests = [ |
| 259 testMethod, | 263 testMethod, |
| 260 testMethod2, | 264 testMethod2, |
| 261 testMethod3, | 265 testMethod3, |
| 262 testMethod4, | 266 testMethod4, |
| 263 ]; | 267 ]; |
| 264 | 268 |
| 265 main(args) => runIsolateTests(args, tests); | 269 main(args) => runIsolateTests(args, tests); |
| OLD | NEW |