| 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 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if (++i % 100000000 == 0) { | 24 if (++i % 100000000 == 0) { |
| 25 MyClass.printValue(10000); | 25 MyClass.printValue(10000); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 var tests = [ | 30 var tests = [ |
| 31 | 31 |
| 32 // Go to breakpoint at line 16. | 32 // Go to breakpoint at line 16. |
| 33 (Isolate isolate) { | 33 (Isolate isolate) { |
| 34 return isolate.rootLib.load().then((_) { | 34 return isolate.rootLibrary.load().then((_) { |
| 35 // Set up a listener to wait for breakpoint events. | 35 // Set up a listener to wait for breakpoint events. |
| 36 Completer completer = new Completer(); | 36 Completer completer = new Completer(); |
| 37 isolate.vm.events.stream.listen((ServiceEvent event) { | 37 isolate.vm.events.stream.listen((ServiceEvent event) { |
| 38 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 38 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| 39 print('Breakpoint reached'); | 39 print('Breakpoint reached'); |
| 40 completer.complete(); | 40 completer.complete(); |
| 41 } | 41 } |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 // Add the breakpoint. | 44 // Add the breakpoint. |
| 45 var script = isolate.rootLib.scripts[0]; | 45 var script = isolate.rootLibrary.scripts[0]; |
| 46 var line = 16; | 46 var line = 16; |
| 47 return isolate.addBreakpoint(script, line).then((ServiceObject bpt) { | 47 return isolate.addBreakpoint(script, line).then((ServiceObject bpt) { |
| 48 return completer.future; // Wait for breakpoint reached. | 48 return completer.future; // Wait for breakpoint reached. |
| 49 }); | 49 }); |
| 50 }); | 50 }); |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 // Evaluate against library, class, and instance. | 53 // Evaluate against library, class, and instance. |
| 54 (Isolate isolate) { | 54 (Isolate isolate) { |
| 55 return isolate.getStack().then((ServiceMap stack) { | 55 return isolate.getStack().then((ServiceMap stack) { |
| 56 // Make sure we are in the right place. | 56 // Make sure we are in the right place. |
| 57 expect(stack.type, equals('Stack')); | 57 expect(stack.type, equals('Stack')); |
| 58 expect(stack['frames'].length, greaterThanOrEqualTo(2)); | 58 expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
| 59 expect(stack['frames'][0]['function'].name, equals('printValue')); | 59 expect(stack['frames'][0]['function'].name, equals('printValue')); |
| 60 expect(stack['frames'][0]['function'].dartOwner.name, equals('MyClass')); | 60 expect(stack['frames'][0]['function'].dartOwner.name, equals('MyClass')); |
| 61 | 61 |
| 62 var lib = isolate.rootLib; | 62 var lib = isolate.rootLibrary; |
| 63 var cls = stack['frames'][0]['function'].dartOwner; | 63 var cls = stack['frames'][0]['function'].dartOwner; |
| 64 var instance = stack['frames'][0]['vars'][0]['value']; | 64 var instance = stack['frames'][0]['vars'][0]['value']; |
| 65 | 65 |
| 66 List evals = []; | 66 List evals = []; |
| 67 evals.add(isolate.eval(lib, 'globalVar + 5').then((result) { | 67 evals.add(lib.evaluate('globalVar + 5').then((result) { |
| 68 print(result); | 68 print(result); |
| 69 expect(result.valueAsString, equals('105')); | 69 expect(result.valueAsString, equals('105')); |
| 70 })); | 70 })); |
| 71 evals.add(isolate.eval(lib, 'globalVar + staticVar + 5').then((result) { | 71 evals.add(lib.evaluate('globalVar + staticVar + 5').then((result) { |
| 72 expect(result.type, equals('Error')); | 72 expect(result.type, equals('Error')); |
| 73 })); | 73 })); |
| 74 evals.add(isolate.eval(cls, 'globalVar + staticVar + 5').then((result) { | 74 evals.add(cls.evaluate('globalVar + staticVar + 5').then((result) { |
| 75 print(result); | 75 print(result); |
| 76 expect(result.valueAsString, equals('1105')); | 76 expect(result.valueAsString, equals('1105')); |
| 77 })); | 77 })); |
| 78 evals.add(isolate.eval(cls, 'this + 5').then((result) { | 78 evals.add(cls.evaluate('this + 5').then((result) { |
| 79 expect(result.type, equals('Error')); | 79 expect(result.type, equals('Error')); |
| 80 })); | 80 })); |
| 81 evals.add(isolate.eval(instance, 'this + 5').then((result) { | 81 evals.add(instance.evaluate('this + 5').then((result) { |
| 82 print(result); | 82 print(result); |
| 83 expect(result.valueAsString, equals('10005')); | 83 expect(result.valueAsString, equals('10005')); |
| 84 })); | 84 })); |
| 85 evals.add(isolate.eval(instance, 'this + frog').then((result) { | 85 evals.add(instance.evaluate('this + frog').then((result) { |
| 86 expect(result.type, equals('Error')); | 86 expect(result.type, equals('Error')); |
| 87 })); | 87 })); |
| 88 return Future.wait(evals); | 88 return Future.wait(evals); |
| 89 }); | 89 }); |
| 90 }, | 90 }, |
| 91 | 91 |
| 92 ]; | 92 ]; |
| 93 | 93 |
| 94 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 94 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |