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

Side by Side Diff: runtime/observatory/tests/service/contexts_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 library inbound_references_test; 6 library inbound_references_test;
7 7
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 'test_helper.dart'; 10 import 'test_helper.dart';
11 11
12 var cleanBlock, copyingBlock, fullBlock, fullBlockWithChain; 12 var cleanBlock, copyingBlock, fullBlock, fullBlockWithChain;
13 13
14 Function genCleanBlock() { 14 Function genCleanBlock() {
15 block(x) => x; 15 block(x) => x;
16 return block; 16 return block;
17 } 17 }
18 18
19 Function genCopyingBlock() { 19 Function genCopyingBlock() {
20 final x = 'I could be copied into the block'; 20 final x = 'I could be copied into the block';
21 block() => x; 21 block() => x;
22 return block; 22 return block;
23 } 23 }
24 24
25 Function genFullBlock() { 25 Function genFullBlock() {
26 var x = 42; // I must captured in a context. 26 var x = 42; // I must captured in a context.
27 block() => x; 27 block() => x;
28 x++; 28 x++;
29 return block; 29 return block;
30 } 30 }
31 31
32 Function genFullBlockWithChain() { 32 Function genFullBlockWithChain() {
33 var x = 420; // I must captured in a context. 33 var x = 420; // I must captured in a context.
34 outerBlock() { 34 outerBlock() {
35 var y = 4200; 35 var y = 4200;
36 innerBlock() => x + y; 36 innerBlock() => x + y;
37 y++; 37 y++;
38 return innerBlock; 38 return innerBlock;
39 } 39 }
40
40 x++; 41 x++;
41 return outerBlock(); 42 return outerBlock();
42 } 43 }
43 44
44 void script() { 45 void script() {
45 cleanBlock = genCleanBlock(); 46 cleanBlock = genCleanBlock();
46 copyingBlock = genCopyingBlock(); 47 copyingBlock = genCopyingBlock();
47 fullBlock = genFullBlock(); 48 fullBlock = genFullBlock();
48 fullBlockWithChain = genFullBlockWithChain(); 49 fullBlockWithChain = genFullBlockWithChain();
49 } 50 }
50 51
51 var tests = [ 52 var tests = [
52 53 (Isolate isolate) => isolate.rootLibrary.load().then((Library lib) {
53 (Isolate isolate) => 54 Field field = lib.variables.singleWhere((v) => v.name == 'cleanBlock');
54 isolate.rootLibrary.load().then((Library lib) { 55 return field.load().then((_) {
55 Field field = lib.variables.singleWhere((v) => v.name == 'cleanBlock'); 56 return field.staticValue.load().then((Instance block) {
56 return field.load().then((_) { 57 expect(block.isClosure, isTrue);
57 return field.staticValue.load().then((Instance block) { 58 expect(block.closureContext.isContext, isTrue);
58 expect(block.isClosure, isTrue); 59 expect(block.closureContext.length, equals(0));
59 expect(block.closureContext.isContext, isTrue); 60 return block.closureContext.load().then((Context ctxt) {
60 expect(block.closureContext.length, equals(0)); 61 expect(ctxt.parentContext, isNull);
61 return block.closureContext.load().then((Context ctxt) {
62 expect(ctxt.parentContext, isNull);
63 });
64 });
65 });
66 }),
67
68 (Isolate isolate) =>
69 isolate.rootLibrary.load().then((Library lib) {
70 Field field = lib.variables.singleWhere((v) => v.name == 'copyingBlock');
71 return field.load().then((_) {
72 return field.staticValue.load().then((Instance block) {
73 expect(block.isClosure, isTrue);
74 expect(block.closureContext.isContext, isTrue);
75 expect(block.closureContext.length, equals(1));
76 return block.closureContext.load().then((Context ctxt) {
77 expect(ctxt.variables.single.value.asValue.isString, isTrue);
78 expect(ctxt.variables.single.value.asValue.valueAsString,
79 equals('I could be copied into the block'));
80 expect(ctxt.parentContext.isContext, isTrue);
81 expect(ctxt.parentContext.length, equals(0));
82 return ctxt.parentContext.load().then((Context outerCtxt) {
83 expect(outerCtxt.parentContext, isNull);
84 });
85 });
86 });
87 });
88 }),
89
90 (Isolate isolate) =>
91 isolate.rootLibrary.load().then((Library lib) {
92 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlock');
93 return field.load().then((_) {
94 return field.staticValue.load().then((Instance block) {
95 expect(block.isClosure, isTrue);
96 expect(block.closureContext.isContext, isTrue);
97 expect(block.closureContext.length, equals(1));
98 return block.closureContext.load().then((Context ctxt) {
99 expect(ctxt.variables.single.value.asValue.isInt, isTrue);
100 expect(ctxt.variables.single.value.asValue.valueAsString, equals('43') );
101 expect(ctxt.parentContext.isContext, isTrue);
102 expect(ctxt.parentContext.length, equals(0));
103 return ctxt.parentContext.load().then((Context outerCtxt) {
104 expect(outerCtxt.parentContext, isNull);
105 });
106 });
107 });
108 });
109 }),
110
111 (Isolate isolate) =>
112 isolate.rootLibrary.load().then((Library lib) {
113 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlockWithChain ');
114 return field.load().then((_) {
115 return field.staticValue.load().then((Instance block) {
116 expect(block.isClosure, isTrue);
117 expect(block.closureContext.isContext, isTrue);
118 expect(block.closureContext.length, equals(1));
119 return block.closureContext.load().then((Context ctxt) {
120 expect(ctxt.variables.single.value.asValue.isInt, isTrue);
121 expect(ctxt.variables.single.value.asValue.valueAsString,
122 equals('4201'));
123 expect(ctxt.parentContext.isContext, isTrue);
124 expect(ctxt.parentContext.length, equals(1));
125 return ctxt.parentContext.load().then((Context outerCtxt) {
126 expect(outerCtxt.variables.single.value.asValue.isInt, isTrue);
127 expect(outerCtxt.variables.single.value.asValue.valueAsString,
128 equals('421'));
129 expect(outerCtxt.parentContext.isContext, isTrue);
130 expect(outerCtxt.parentContext.length, equals(0));
131 return outerCtxt.parentContext.load().then((Context outerCtxt2) {
132 expect(outerCtxt2.parentContext, isNull);
133 }); 62 });
134 }); 63 });
135 }); 64 });
136 }); 65 }),
137 }); 66 (Isolate isolate) => isolate.rootLibrary.load().then((Library lib) {
138 }), 67 Field field =
139 68 lib.variables.singleWhere((v) => v.name == 'copyingBlock');
69 return field.load().then((_) {
70 return field.staticValue.load().then((Instance block) {
71 expect(block.isClosure, isTrue);
72 expect(block.closureContext.isContext, isTrue);
73 expect(block.closureContext.length, equals(1));
74 return block.closureContext.load().then((Context ctxt) {
75 expect(ctxt.variables.single.value.asValue.isString, isTrue);
76 expect(ctxt.variables.single.value.asValue.valueAsString,
77 equals('I could be copied into the block'));
78 expect(ctxt.parentContext.isContext, isTrue);
79 expect(ctxt.parentContext.length, equals(0));
80 return ctxt.parentContext.load().then((Context outerCtxt) {
81 expect(outerCtxt.parentContext, isNull);
82 });
83 });
84 });
85 });
86 }),
87 (Isolate isolate) => isolate.rootLibrary.load().then((Library lib) {
88 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlock');
89 return field.load().then((_) {
90 return field.staticValue.load().then((Instance block) {
91 expect(block.isClosure, isTrue);
92 expect(block.closureContext.isContext, isTrue);
93 expect(block.closureContext.length, equals(1));
94 return block.closureContext.load().then((Context ctxt) {
95 expect(ctxt.variables.single.value.asValue.isInt, isTrue);
96 expect(ctxt.variables.single.value.asValue.valueAsString,
97 equals('43'));
98 expect(ctxt.parentContext.isContext, isTrue);
99 expect(ctxt.parentContext.length, equals(0));
100 return ctxt.parentContext.load().then((Context outerCtxt) {
101 expect(outerCtxt.parentContext, isNull);
102 });
103 });
104 });
105 });
106 }),
107 (Isolate isolate) => isolate.rootLibrary.load().then((Library lib) {
108 Field field =
109 lib.variables.singleWhere((v) => v.name == 'fullBlockWithChain');
110 return field.load().then((_) {
111 return field.staticValue.load().then((Instance block) {
112 expect(block.isClosure, isTrue);
113 expect(block.closureContext.isContext, isTrue);
114 expect(block.closureContext.length, equals(1));
115 return block.closureContext.load().then((Context ctxt) {
116 expect(ctxt.variables.single.value.asValue.isInt, isTrue);
117 expect(ctxt.variables.single.value.asValue.valueAsString,
118 equals('4201'));
119 expect(ctxt.parentContext.isContext, isTrue);
120 expect(ctxt.parentContext.length, equals(1));
121 return ctxt.parentContext.load().then((Context outerCtxt) {
122 expect(outerCtxt.variables.single.value.asValue.isInt, isTrue);
123 expect(outerCtxt.variables.single.value.asValue.valueAsString,
124 equals('421'));
125 expect(outerCtxt.parentContext.isContext, isTrue);
126 expect(outerCtxt.parentContext.length, equals(0));
127 return outerCtxt.parentContext
128 .load()
129 .then((Context outerCtxt2) {
130 expect(outerCtxt2.parentContext, isNull);
131 });
132 });
133 });
134 });
135 });
136 }),
140 ]; 137 ];
141 138
142 main(args) => runIsolateTests(args, tests, testeeBefore: script); 139 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/complex_reload_test.dart ('k') | runtime/observatory/tests/service/crash_dump_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698