Index: runtime/observatory/tests/service/evaluate_activation_test.dart |
diff --git a/runtime/observatory/tests/service/evaluate_activation_test.dart b/runtime/observatory/tests/service/evaluate_activation_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6f37a68001efceb0eabb716183c163c86f2434fa |
--- /dev/null |
+++ b/runtime/observatory/tests/service/evaluate_activation_test.dart |
@@ -0,0 +1,248 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// VMOptions=--compile-all --error_on_bad_type --error_on_bad_override |
+ |
+import 'package:observatory/service_io.dart'; |
+import 'package:unittest/unittest.dart'; |
+import 'test_helper.dart'; |
+import 'dart:async'; |
+ |
+import 'dart:math' as math; |
+ |
+breakHere() {} |
+ |
+class C { |
+ var instVar = 1; |
+ static var classVar = 2; |
+ |
+ method(methodParam) { |
+ var methodTemp = 4; |
+ [5].forEach((outerParam) { |
+ var outerTemp = 6; |
+ [7].forEach((innerParam) { |
+ var innerTemp = 8; |
+ breakHere(); |
+ }); |
+ }); |
+ } |
+ |
+ static method2(methodParam) { |
+ var methodTemp = 4; |
+ [5].forEach((outerParam) { |
+ var outerTemp = 6; |
+ [7].forEach((innerParam) { |
+ var innerTemp = 8; |
+ breakHere(); |
+ }); |
+ }); |
+ } |
+ |
+ method3(methodParam) { |
+ var methodTemp = 4; |
+ breakHere(); |
+ } |
+ |
+ static var closureWithReturnedHome; |
+ method4(methodParam) { |
+ var methodTemp = 4; |
+ [5].forEach((outerParam) { |
+ var outerTemp = 6; |
+ closureWithReturnedHome = (innerParam) { |
+ var innerTemp = 8; |
+ breakHere(); |
+ }; |
+ }); |
+ } |
+} |
+ |
+testMethod(Isolate isolate) async { |
+ Library rootLib = await isolate.rootLib.load(); |
+ ServiceFunction function = |
+ rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
+ Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
+ print("Breakpoint: $bpt"); |
+ expect(bpt is Breakpoint, isTrue); // I.e, not null. |
+ |
+ bool hitBreakpoint = false; |
+ var sub = isolate.vm.events.stream.listen((ServiceEvent event) async { |
+ print("Event $event"); |
+ if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
+ var n = 1; |
Cutch
2015/04/10 21:15:25
frameNum ?
rmacnak
2015/04/10 22:36:44
Done.
|
+ expect((await isolate.evalFrame(n, '123')).valueAsString, /// brokeninstance: runtime error |
Cutch
2015/04/10 21:15:25
column limits..
rmacnak
2015/04/10 22:36:44
Lots of reshuffling, still doesn't quite fit with
|
+ equals('123')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'this')).clazz.name, /// missingscope: runtime error |
+ equals('C')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'instVar')).valueAsString, /// missingscope: continued |
+ equals('1')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'classVar')).valueAsString, /// brokeninstance: continued |
+ equals('2')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'methodParam')).valueAsString, /// missingscope: continued |
+ equals('3')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'methodTemp')).valueAsString, /// missingscope: continued |
+ equals('4')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerParam')).valueAsString, /// missingscope: continued |
+ equals('5')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerTemp')).valueAsString, /// missingscope: continued |
+ equals('6')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'innerParam')).valueAsString, /// brokeninstance: continued |
+ equals('7')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'innerTemp')).valueAsString, /// brokeninstance: continued |
+ equals('8')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'math.sqrt')).isClosure, /// brokeninstance: continued |
+ isTrue); /// brokeninstance: continued |
+ |
+ hitBreakpoint = true; |
+ isolate.resume(); |
+ } |
+ }); |
+ |
+ var result = await isolate.eval(rootLib, 'new C().method(3);'); |
+ print("Result $result"); |
+ expect(hitBreakpoint, isTrue); |
+ sub.cancel(); // So the next test gets the events. |
+} |
+ |
+testMethod2(Isolate isolate) async { |
+ Library rootLib = await isolate.rootLib.load(); |
+ ServiceFunction function = |
+ rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
+ Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
+ print("Breakpoint: $bpt"); |
+ expect(bpt is Breakpoint, isTrue); // I.e, not null. |
+ |
+ bool hitBreakpoint = false; |
+ var sub = isolate.vm.events.stream.listen((ServiceEvent event) async { |
+ print("Event $event"); |
+ if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
+ var n = 1; |
+ expect((await isolate.evalFrame(n, '123')).valueAsString, |
+ equals('123')); |
+ expect((await isolate.evalFrame(n, 'this')) is DartError, |
+ isTrue); |
+ expect((await isolate.evalFrame(n, 'instVar')) is DartError, |
+ isTrue); |
+ expect((await isolate.evalFrame(n, 'classVar')).valueAsString, |
+ equals('2')); |
+ expect((await isolate.evalFrame(n, 'methodParam')).valueAsString, /// missingscope: continued |
+ equals('3')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'methodTemp')).valueAsString, /// missingscope: continued |
+ equals('4')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerParam')).valueAsString, /// missingscope: continued |
+ equals('5')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerTemp')).valueAsString, /// missingscope: continued |
+ equals('6')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'innerParam')).valueAsString, |
+ equals('7')); |
+ expect((await isolate.evalFrame(n, 'innerTemp')).valueAsString, |
+ equals('8')); |
+ expect((await isolate.evalFrame(n, 'math.sqrt')).isClosure, |
+ isTrue); |
+ |
+ hitBreakpoint = true; |
+ isolate.resume(); |
+ } |
+ }); |
+ |
+ var result = await isolate.eval(rootLib, 'C.method2(3);'); |
+ print("Result $result"); |
+ expect(hitBreakpoint, isTrue); |
+ sub.cancel(); // So the next test gets the events. |
+} |
+ |
+testMethod3(Isolate isolate) async { |
+ Library rootLib = await isolate.rootLib.load(); |
+ ServiceFunction function = |
+ rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
+ Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
+ print("Breakpoint: $bpt"); |
+ expect(bpt is Breakpoint, isTrue); // I.e, not null. |
+ |
+ bool hitBreakpoint = false; |
+ var sub = isolate.vm.events.stream.listen((ServiceEvent event) async { |
+ print("Event $event"); |
+ if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
+ var n = 1; |
+ expect((await isolate.evalFrame(n, '123')).valueAsString, |
+ equals('123')); |
+ expect((await isolate.evalFrame(n, 'this')).clazz.name, |
+ equals('C')); |
+ expect((await isolate.evalFrame(n, 'instVar')).valueAsString, |
+ equals('1')); |
+ expect((await isolate.evalFrame(n, 'classVar')).valueAsString, |
+ equals('2')); |
+ expect((await isolate.evalFrame(n, 'methodParam')).valueAsString, |
+ equals('3')); |
+ expect((await isolate.evalFrame(n, 'methodTemp')).valueAsString, |
+ equals('4')); |
+ expect((await isolate.evalFrame(n, 'math.sqrt')).isClosure, |
+ isTrue); |
+ |
+ hitBreakpoint = true; |
+ isolate.resume(); |
+ } |
+ }); |
+ |
+ var result = await isolate.eval(rootLib, 'new C().method3(3);'); |
+ print("Result $result"); |
+ expect(hitBreakpoint, isTrue); |
+ sub.cancel(); // So the next test gets the events. |
Cutch
2015/04/10 21:15:25
these tests should return a completer's future tha
rmacnak
2015/04/10 22:36:44
That's too soon because the result of the library
|
+} |
+ |
+ |
+testMethod4(Isolate isolate) async { |
+ Library rootLib = await isolate.rootLib.load(); |
+ ServiceFunction function = |
+ rootLib.functions.singleWhere((f) => f.name == 'breakHere'); |
+ Breakpoint bpt = await isolate.addBreakpointAtEntry(function); |
+ print("Breakpoint: $bpt"); |
+ expect(bpt is Breakpoint, isTrue); // I.e, not null. |
+ |
+ bool hitBreakpoint = false; |
+ var sub = isolate.vm.events.stream.listen((ServiceEvent event) async { |
+ print("Event $event"); |
+ if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
+ var n = 1; |
+ expect((await isolate.evalFrame(n, '123')).valueAsString, /// brokeninstance: runtime error |
+ equals('123')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'this')).clazz.name, /// missingscope: runtime error |
+ equals('C')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'instVar')).valueAsString, /// missingscope: continued |
+ equals('1')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'classVar')).valueAsString, /// brokeninstance: continued |
+ equals('2')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'methodParam')).valueAsString, /// missingscope: continued |
+ equals('3')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'methodTemp')).valueAsString, /// missingscope: continued |
+ equals('4')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerParam')).valueAsString, /// missingscope: continued |
+ equals('5')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'outerTemp')).valueAsString, /// missingscope: continued |
+ equals('6')); /// missingscope: continued |
+ expect((await isolate.evalFrame(n, 'innerParam')).valueAsString, /// brokeninstance: continued |
+ equals('7')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'innerTemp')).valueAsString, /// brokeninstance: continued |
+ equals('8')); /// brokeninstance: continued |
+ expect((await isolate.evalFrame(n, 'math.sqrt')).isClosure, /// brokeninstance: continued |
+ isTrue); /// brokeninstance: continued |
+ |
+ hitBreakpoint = true; |
+ isolate.resume(); |
+ } |
+ }); |
+ |
+ var result = await isolate.eval(rootLib, |
+ '(){ new C().method4(3); C.closureWithReturnedHome(7); }()'); |
+ print("Result $result"); |
+ expect(hitBreakpoint, isTrue); |
+ sub.cancel(); // So the next test gets the events. |
+} |
+ |
+var tests = [ |
+ testMethod, |
+ testMethod2, |
+ testMethod3, |
+ testMethod4, |
+]; |
+ |
+main(args) => runIsolateTests(args, tests); |