OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 | 4 |
5 import 'dart:async'; | |
6 import 'dart:developer'; | 5 import 'dart:developer'; |
7 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
9 import 'service_test_common.dart'; | 8 import 'service_test_common.dart'; |
10 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
11 | 10 |
12 generator() async* { | 11 generator() async* { |
13 var x = 3; | 12 var x = 3; |
14 var y = 4; | 13 var y = 4; |
15 debugger(); | 14 debugger(); |
16 yield y; | 15 yield y; |
17 var z = x + y; | 16 var z = x + y; |
18 debugger(); | 17 debugger(); |
19 yield z; | 18 yield z; |
20 } | 19 } |
21 | 20 |
22 testFunction() async { | 21 testFunction() async { |
23 await for (var ignored in generator()); | 22 await for (var ignored in generator()); |
24 } | 23 } |
25 | 24 |
26 var tests = [ | 25 var tests = [ |
27 | 26 |
28 hasStoppedAtBreakpoint, | 27 hasStoppedAtBreakpoint, |
29 | 28 |
30 (Isolate isolate) async { | 29 (Isolate isolate) async { |
31 // Make sure we are in the right place. | 30 // Make sure we are in the right place. |
32 var stack = await isolate.getStack(); | 31 var stack = await isolate.getStack(); |
33 var topFrame = 0; | 32 var topFrame = 0; |
34 expect(stack.type, equals('Stack')); | 33 expect(stack.type, equals('Stack')); |
35 expect(await stack['frames'][topFrame].location.getLine(), 16); | 34 expect(await stack['frames'][topFrame].location.getLine(), 15); |
36 | 35 |
37 var result = await isolate.evalFrame(topFrame, "x"); | 36 var result = await isolate.evalFrame(topFrame, "x"); |
38 print(result); | 37 print(result); |
39 expect(result.valueAsString, equals("3")); | 38 expect(result.valueAsString, equals("3")); |
40 }, | 39 }, |
41 | 40 |
42 resumeIsolate, | 41 resumeIsolate, |
43 | 42 |
44 hasStoppedAtBreakpoint, | 43 hasStoppedAtBreakpoint, |
45 | 44 |
46 (Isolate isolate) async { | 45 (Isolate isolate) async { |
47 // Make sure we are in the right place. | 46 // Make sure we are in the right place. |
48 var stack = await isolate.getStack(); | 47 var stack = await isolate.getStack(); |
49 var topFrame = 0; | 48 var topFrame = 0; |
50 expect(stack.type, equals('Stack')); | 49 expect(stack.type, equals('Stack')); |
51 expect(await stack['frames'][topFrame].location.getLine(), 19); | 50 expect(await stack['frames'][topFrame].location.getLine(), 18); |
52 | 51 |
53 var result = await isolate.evalFrame(topFrame, "z"); | 52 var result = await isolate.evalFrame(topFrame, "z"); |
54 print(result); | 53 print(result); |
55 expect(result.valueAsString, equals("7")); | 54 expect(result.valueAsString, equals("7")); |
56 }, | 55 }, |
57 | 56 |
58 resumeIsolate, | 57 resumeIsolate, |
59 | 58 |
60 ]; | 59 ]; |
61 | 60 |
62 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 61 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
OLD | NEW |