Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: runtime/observatory/tests/service/causal_async_star_stack_contents_test.dart

Issue 2751423005: Run dartfmt on all files under runtime. (Closed)
Patch Set: Run dartfmt on all files under runtime. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 --verbose_debug 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug
5 5
6 import 'dart:developer'; 6 import 'dart:developer';
7 import 'package:observatory/models.dart' as M; 7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/service_io.dart'; 8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'service_test_common.dart'; 10 import 'service_test_common.dart';
11 import 'test_helper.dart'; 11 import 'test_helper.dart';
12 12
13 const LINE_A = 26; 13 const LINE_A = 26;
14 const LINE_B = 19; 14 const LINE_B = 19;
15 const LINE_C = 21; 15 const LINE_C = 21;
16 16
17 foobar() async* { 17 foobar() async* {
18 debugger(); 18 debugger();
19 yield 1; // LINE_B. 19 yield 1; // LINE_B.
20 debugger(); 20 debugger();
21 yield 2; // LINE_C. 21 yield 2; // LINE_C.
22 } 22 }
23 23
24 helper() async { 24 helper() async {
25 debugger(); 25 debugger();
26 print('helper'); // LINE_A. 26 print('helper'); // LINE_A.
27 await for (var i in foobar()) { 27 await for (var i in foobar()) {
28 print('helper $i'); 28 print('helper $i');
29 } 29 }
30 } 30 }
31 31
32 testMain() { 32 testMain() {
33 helper(); 33 helper();
34 } 34 }
35 35
36 var tests = [ 36 var tests = [
37 hasStoppedAtBreakpoint, 37 hasStoppedAtBreakpoint,
38 stoppedAtLine(LINE_A), 38 stoppedAtLine(LINE_A),
39 (Isolate isolate) async { 39 (Isolate isolate) async {
40 ServiceMap stack = await isolate.getStack(); 40 ServiceMap stack = await isolate.getStack();
41 // No causal frames because we are in a completely synchronous stack. 41 // No causal frames because we are in a completely synchronous stack.
42 expect(stack['asyncCausalFrames'], isNotNull); 42 expect(stack['asyncCausalFrames'], isNotNull);
43 var asyncStack = stack['asyncCausalFrames']; 43 var asyncStack = stack['asyncCausalFrames'];
44 expect(asyncStack[0].toString(), contains('helper')); 44 expect(asyncStack[0].toString(), contains('helper'));
45 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); 45 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
46 expect(asyncStack[2].toString(), contains('testMain')); 46 expect(asyncStack[2].toString(), contains('testMain'));
47 }, 47 },
48 resumeIsolate, 48 resumeIsolate,
49 hasStoppedAtBreakpoint, 49 hasStoppedAtBreakpoint,
50 stoppedAtLine(LINE_B), 50 stoppedAtLine(LINE_B),
51
52 (Isolate isolate) async { 51 (Isolate isolate) async {
53 ServiceMap stack = await isolate.getStack(); 52 ServiceMap stack = await isolate.getStack();
54 // Has causal frames (we are inside an async function) 53 // Has causal frames (we are inside an async function)
55 expect(stack['asyncCausalFrames'], isNotNull); 54 expect(stack['asyncCausalFrames'], isNotNull);
56 var asyncStack = stack['asyncCausalFrames']; 55 var asyncStack = stack['asyncCausalFrames'];
57 expect(asyncStack[0].toString(), contains('foobar')); 56 expect(asyncStack[0].toString(), contains('foobar'));
58 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); 57 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
59 expect(asyncStack[2].toString(), contains('helper')); 58 expect(asyncStack[2].toString(), contains('helper'));
60 expect(asyncStack[3].kind, equals(M.FrameKind.asyncSuspensionMarker)); 59 expect(asyncStack[3].kind, equals(M.FrameKind.asyncSuspensionMarker));
61 expect(asyncStack[4].toString(), contains('testMain')); 60 expect(asyncStack[4].toString(), contains('testMain'));
62 }, 61 },
63
64 resumeIsolate, 62 resumeIsolate,
65 hasStoppedAtBreakpoint, 63 hasStoppedAtBreakpoint,
66 stoppedAtLine(LINE_C), 64 stoppedAtLine(LINE_C),
67
68 (Isolate isolate) async { 65 (Isolate isolate) async {
69 ServiceMap stack = await isolate.getStack(); 66 ServiceMap stack = await isolate.getStack();
70 // Has causal frames (we are inside a function called by an async function) 67 // Has causal frames (we are inside a function called by an async function)
71 expect(stack['asyncCausalFrames'], isNotNull); 68 expect(stack['asyncCausalFrames'], isNotNull);
72 var asyncStack = stack['asyncCausalFrames']; 69 var asyncStack = stack['asyncCausalFrames'];
73 print('async:'); 70 print('async:');
74 await printFrames(asyncStack); 71 await printFrames(asyncStack);
75 print('sync:'); 72 print('sync:');
76 await printFrames(stack['frames']); 73 await printFrames(stack['frames']);
77 expect(asyncStack[0].toString(), contains('foobar')); 74 expect(asyncStack[0].toString(), contains('foobar'));
78 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); 75 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
79 expect(asyncStack[2].toString(), contains('helper')); 76 expect(asyncStack[2].toString(), contains('helper'));
80 expect(asyncStack[3].kind, equals(M.FrameKind.asyncSuspensionMarker)); 77 expect(asyncStack[3].kind, equals(M.FrameKind.asyncSuspensionMarker));
81 expect(asyncStack[4].toString(), contains('testMain')); 78 expect(asyncStack[4].toString(), contains('testMain'));
82 // Line 21. 79 // Line 21.
83 expect(await asyncStack[0].location.toUserString(), contains('.dart:21')); 80 expect(await asyncStack[0].location.toUserString(), contains('.dart:21'));
84 // Line 27. 81 // Line 27.
85 expect(await asyncStack[2].location.toUserString(), contains('.dart:27')); 82 expect(await asyncStack[2].location.toUserString(), contains('.dart:27'));
86 // Line 30. 83 // Line 30.
87 expect(await asyncStack[4].location.toUserString(), contains('.dart:33')); 84 expect(await asyncStack[4].location.toUserString(), contains('.dart:33'));
88 }, 85 },
89 ]; 86 ];
90 87
91 main(args) => runIsolateTestsSynchronous(args, 88 main(args) =>
92 tests, 89 runIsolateTestsSynchronous(args, tests, testeeConcurrent: testMain);
93 testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698