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=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--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 | 9 |
10 genRepeater(value) { | 10 genRepeater(value) { |
(...skipping 29 matching lines...) Expand all Loading... |
40 r2(); | 40 r2(); |
41 r3(); | 41 r3(); |
42 } | 42 } |
43 | 43 |
44 void testeeDoNamed() { | 44 void testeeDoNamed() { |
45 r1_named(y: 'Not a closure', x: 'Not a closure'); | 45 r1_named(y: 'Not a closure', x: 'Not a closure'); |
46 r2_named(y: 'Not a closure', x: 'Not a closure'); | 46 r2_named(y: 'Not a closure', x: 'Not a closure'); |
47 r3_named(y: 'Not a closure', x: 'Not a closure'); | 47 r3_named(y: 'Not a closure', x: 'Not a closure'); |
48 } | 48 } |
49 | 49 |
| 50 |
50 var tests = [ | 51 var tests = [ |
51 (Isolate isolate) async { | 52 (Isolate isolate) async { |
52 var rootLib = await isolate.rootLibrary.load(); | 53 var rootLib = await isolate.rootLibrary.load(); |
53 | 54 |
54 var breaksHit = 0; | 55 var breaksHit = 0; |
55 | 56 |
56 var subscriptionFuture = | 57 var subscriptionFuture = isolate.vm.listenEventStream( |
57 isolate.vm.listenEventStream(VM.kDebugStream, (ServiceEvent event) { | 58 VM.kDebugStream, (ServiceEvent event) { |
58 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 59 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
59 print("Hit breakpoint ${event.breakpoint}"); | 60 print("Hit breakpoint ${event.breakpoint}"); |
60 breaksHit++; | 61 breaksHit++; |
61 isolate.resume(); | 62 isolate.resume(); |
62 } | 63 } |
63 }); | 64 }); |
64 | 65 |
65 valueOfField(String name) async { | 66 valueOfField(String name) async { |
66 var field = rootLib.variables.singleWhere((v) => v.name == name); | 67 var field = rootLib.variables.singleWhere((v) => v.name == name); |
67 await field.load(); | 68 await field.load(); |
68 return field.staticValue; | 69 return field.staticValue; |
69 } | |
70 | 70 |
71 var r1Ref = await valueOfField('r1'); | 71 } |
| 72 var r1Ref = await valueOfField('r1'); |
72 | 73 |
73 var bpt1 = await isolate.addBreakOnActivation(r1Ref); | 74 var bpt1 = await isolate.addBreakOnActivation(r1Ref); |
74 print("Added breakpoint $bpt1"); | 75 print("Added breakpoint $bpt1"); |
75 expect(bpt1 is Breakpoint, isTrue); | 76 expect(bpt1 is Breakpoint, isTrue); |
76 expect(breaksHit, equals(0)); | 77 expect(breaksHit, equals(0)); |
77 await r1Ref.reload(); | 78 await r1Ref.reload(); |
78 expect(r1Ref.activationBreakpoint, equals(bpt1)); | 79 expect(r1Ref.activationBreakpoint, equals(bpt1)); |
79 print("testeeDo()"); | 80 print("testeeDo()"); |
80 var res = await rootLib.evaluate("testeeDo()"); | 81 var res = await rootLib.evaluate("testeeDo()"); |
81 expect(res is Instance, isTrue); // Not error. | 82 expect(res is Instance, isTrue); // Not error. |
82 expect(breaksHit, equals(1)); | 83 expect(breaksHit, equals(1)); |
83 | 84 |
84 await isolate.removeBreakpoint(bpt1); | 85 await isolate.removeBreakpoint(bpt1); |
85 print("Removed breakpoint $bpt1"); | 86 print("Removed breakpoint $bpt1"); |
86 print("testeeDo()"); | 87 print("testeeDo()"); |
87 await r1Ref.reload(); | 88 await r1Ref.reload(); |
88 expect(r1Ref.activationBreakpoint, equals(null)); | 89 expect(r1Ref.activationBreakpoint, equals(null)); |
89 res = await rootLib.evaluate("testeeDo()"); | 90 res = await rootLib.evaluate("testeeDo()"); |
90 expect(res is Instance, isTrue); // Not error. | 91 expect(res is Instance, isTrue); // Not error. |
91 expect(breaksHit, equals(1)); | 92 expect(breaksHit, equals(1)); |
92 | 93 |
93 await cancelFutureSubscription(subscriptionFuture); | 94 await cancelFutureSubscription(subscriptionFuture); |
94 }, | 95 }, |
95 (Isolate isolate) async { | |
96 var rootLib = await isolate.rootLibrary.load(); | |
97 | 96 |
98 var breaksHit = 0; | 97 (Isolate isolate) async { |
| 98 var rootLib = await isolate.rootLibrary.load(); |
99 | 99 |
100 var subscriptionFuture = | 100 var breaksHit = 0; |
101 isolate.vm.listenEventStream(VM.kDebugStream, (ServiceEvent event) { | |
102 if (event.kind == ServiceEvent.kPauseBreakpoint) { | |
103 print("Hit breakpoint ${event.breakpoint}"); | |
104 breaksHit++; | |
105 isolate.resume(); | |
106 } | |
107 }); | |
108 | 101 |
109 valueOfField(String name) async { | 102 var subscriptionFuture = isolate.vm.listenEventStream( |
110 var field = rootLib.variables.singleWhere((v) => v.name == name); | 103 VM.kDebugStream, (ServiceEvent event) { |
111 await field.load(); | 104 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
112 return field.staticValue; | 105 print("Hit breakpoint ${event.breakpoint}"); |
113 } | 106 breaksHit++; |
| 107 isolate.resume(); |
| 108 } |
| 109 }); |
114 | 110 |
115 var r1Ref = await valueOfField('r1_named'); | 111 valueOfField(String name) async { |
| 112 var field = rootLib.variables.singleWhere((v) => v.name == name); |
| 113 await field.load(); |
| 114 return field.staticValue; |
| 115 } |
| 116 var r1Ref = await valueOfField('r1_named'); |
116 | 117 |
117 var bpt1 = await isolate.addBreakOnActivation(r1Ref); | 118 var bpt1 = await isolate.addBreakOnActivation(r1Ref); |
118 print("Added breakpoint $bpt1"); | 119 print("Added breakpoint $bpt1"); |
119 expect(bpt1 is Breakpoint, isTrue); | 120 expect(bpt1 is Breakpoint, isTrue); |
120 expect(breaksHit, equals(0)); | 121 expect(breaksHit, equals(0)); |
121 await r1Ref.reload(); | 122 await r1Ref.reload(); |
122 expect(r1Ref.activationBreakpoint, equals(bpt1)); | 123 expect(r1Ref.activationBreakpoint, equals(bpt1)); |
123 print("testeeDoNamed()"); | 124 print("testeeDoNamed()"); |
124 var res = await rootLib.evaluate("testeeDoNamed()"); | 125 var res = await rootLib.evaluate("testeeDoNamed()"); |
125 expect(res is Instance, isTrue); // Not error. | 126 expect(res is Instance, isTrue); // Not error. |
126 expect(breaksHit, equals(1)); | 127 expect(breaksHit, equals(1)); |
127 | 128 |
128 await isolate.removeBreakpoint(bpt1); | 129 await isolate.removeBreakpoint(bpt1); |
129 print("Removed breakpoint $bpt1"); | 130 print("Removed breakpoint $bpt1"); |
130 await r1Ref.reload(); | 131 await r1Ref.reload(); |
131 expect(r1Ref.activationBreakpoint, equals(null)); | 132 expect(r1Ref.activationBreakpoint, equals(null)); |
132 print("testeeDoNamed()"); | 133 print("testeeDoNamed()"); |
133 res = await rootLib.evaluate("testeeDoNamed()"); | 134 res = await rootLib.evaluate("testeeDoNamed()"); |
134 expect(res is Instance, isTrue); // Not error. | 135 expect(res is Instance, isTrue); // Not error. |
135 expect(breaksHit, equals(1)); | 136 expect(breaksHit, equals(1)); |
136 | 137 |
137 await cancelFutureSubscription(subscriptionFuture); | 138 await cancelFutureSubscription(subscriptionFuture); |
138 }, | 139 }, |
139 (Isolate isolate) async { | |
140 var rootLib = await isolate.rootLibrary.load(); | |
141 | 140 |
142 var breaksHit = 0; | 141 (Isolate isolate) async { |
| 142 var rootLib = await isolate.rootLibrary.load(); |
143 | 143 |
144 var subscriptionFuture = | 144 var breaksHit = 0; |
145 isolate.vm.listenEventStream(VM.kDebugStream, (ServiceEvent event) { | |
146 if (event.kind == ServiceEvent.kPauseBreakpoint) { | |
147 print("Hit breakpoint ${event.breakpoint}"); | |
148 breaksHit++; | |
149 isolate.resume(); | |
150 } | |
151 }); | |
152 | 145 |
153 valueOfField(String name) async { | 146 var subscriptionFuture = isolate.vm.listenEventStream( |
154 var field = rootLib.variables.singleWhere((v) => v.name == name); | 147 VM.kDebugStream, (ServiceEvent event) { |
155 await field.load(); | 148 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
156 return field.staticValue; | 149 print("Hit breakpoint ${event.breakpoint}"); |
157 } | 150 breaksHit++; |
| 151 isolate.resume(); |
| 152 } |
| 153 }); |
158 | 154 |
159 var r1Ref = await valueOfField('r1'); | 155 valueOfField(String name) async { |
160 var r2Ref = await valueOfField('r2'); | 156 var field = rootLib.variables.singleWhere((v) => v.name == name); |
| 157 await field.load(); |
| 158 return field.staticValue; |
| 159 } |
| 160 var r1Ref = await valueOfField('r1'); |
| 161 var r2Ref = await valueOfField('r2'); |
161 | 162 |
162 var bpt1 = await isolate.addBreakOnActivation(r1Ref); | 163 var bpt1 = await isolate.addBreakOnActivation(r1Ref); |
163 print("Added breakpoint $bpt1"); | 164 print("Added breakpoint $bpt1"); |
164 expect(bpt1 is Breakpoint, isTrue); | 165 expect(bpt1 is Breakpoint, isTrue); |
165 expect(breaksHit, equals(0)); | 166 expect(breaksHit, equals(0)); |
166 await r1Ref.reload(); | 167 await r1Ref.reload(); |
167 expect(r1Ref.activationBreakpoint, equals(bpt1)); | 168 expect(r1Ref.activationBreakpoint, equals(bpt1)); |
168 print("testeeDo()"); | 169 print("testeeDo()"); |
169 var res = await rootLib.evaluate("testeeDo()"); | 170 var res = await rootLib.evaluate("testeeDo()"); |
170 expect(res is Instance, isTrue); // Not error. | 171 expect(res is Instance, isTrue); // Not error. |
171 expect(breaksHit, equals(1)); | 172 expect(breaksHit, equals(1)); |
172 | 173 |
173 var bpt2 = await isolate.addBreakOnActivation(r2Ref); | 174 var bpt2 = await isolate.addBreakOnActivation(r2Ref); |
174 print("Added breakpoint $bpt2"); | 175 print("Added breakpoint $bpt2"); |
175 expect(bpt2 is Breakpoint, isTrue); | 176 expect(bpt2 is Breakpoint, isTrue); |
176 expect(breaksHit, equals(1)); | 177 expect(breaksHit, equals(1)); |
177 await r2Ref.reload(); | 178 await r2Ref.reload(); |
178 expect(r2Ref.activationBreakpoint, equals(bpt2)); | 179 expect(r2Ref.activationBreakpoint, equals(bpt2)); |
179 print("testeeDo()"); | 180 print("testeeDo()"); |
180 res = await rootLib.evaluate("testeeDo()"); | 181 res = await rootLib.evaluate("testeeDo()"); |
181 expect(res is Instance, isTrue); // Not error. | 182 expect(res is Instance, isTrue); // Not error. |
182 expect(breaksHit, equals(3)); | 183 expect(breaksHit, equals(3)); |
183 | 184 |
184 await isolate.removeBreakpoint(bpt1); | 185 await isolate.removeBreakpoint(bpt1); |
185 print("Removed breakpoint $bpt1"); | 186 print("Removed breakpoint $bpt1"); |
186 await r1Ref.reload(); | 187 await r1Ref.reload(); |
187 expect(r1Ref.activationBreakpoint, equals(null)); | 188 expect(r1Ref.activationBreakpoint, equals(null)); |
188 print("testeeDo()"); | 189 print("testeeDo()"); |
189 res = await rootLib.evaluate("testeeDo()"); | 190 res = await rootLib.evaluate("testeeDo()"); |
190 expect(res is Instance, isTrue); // Not error. | 191 expect(res is Instance, isTrue); // Not error. |
191 expect(breaksHit, equals(4)); | 192 expect(breaksHit, equals(4)); |
192 | 193 |
193 await isolate.removeBreakpoint(bpt2); | 194 await isolate.removeBreakpoint(bpt2); |
194 print("Removed breakpoint $bpt2"); | 195 print("Removed breakpoint $bpt2"); |
195 await r2Ref.reload(); | 196 await r2Ref.reload(); |
196 expect(r2Ref.activationBreakpoint, equals(null)); | 197 expect(r2Ref.activationBreakpoint, equals(null)); |
197 print("testeeDo()"); | 198 print("testeeDo()"); |
198 res = await rootLib.evaluate("testeeDo()"); | 199 res = await rootLib.evaluate("testeeDo()"); |
199 expect(res is Instance, isTrue); // Not error. | 200 expect(res is Instance, isTrue); // Not error. |
200 expect(breaksHit, equals(4)); | 201 expect(breaksHit, equals(4)); |
201 | 202 |
202 await cancelFutureSubscription(subscriptionFuture); | 203 await cancelFutureSubscription(subscriptionFuture); |
203 }, | 204 }, |
| 205 |
204 ]; | 206 ]; |
205 | 207 |
206 main(args) => runIsolateTests(args, tests, testeeBefore: testeeSetup); | 208 main(args) => runIsolateTests(args, tests, testeeBefore: testeeSetup); |
OLD | NEW |