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

Side by Side Diff: tests/lib/async/stream_state_helper.dart

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebuild DOM and rebase. Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library stream_state_helper; 5 library stream_state_helper;
6 6
7 import "../../../pkg/unittest/lib/unittest.dart"; 7 import "../../../pkg/unittest/lib/unittest.dart";
8 import "dart:async"; 8 import "dart:async";
9 import "dart:collection"; 9 import "dart:collection";
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Handling of stream events. 66 // Handling of stream events.
67 void _onData(var data) { 67 void _onData(var data) {
68 _withNextExpectation((Event expect) { 68 _withNextExpectation((Event expect) {
69 if (!expect.matchData(data)) { 69 if (!expect.matchData(data)) {
70 _fail("Expected: $expect\n" 70 _fail("Expected: $expect\n"
71 "Found : [Data: $data]"); 71 "Found : [Data: $data]");
72 } 72 }
73 }); 73 });
74 } 74 }
75 75
76 void _onError(AsyncError error) { 76 void _onError(error) {
77 _withNextExpectation((Event expect) { 77 _withNextExpectation((Event expect) {
78 if (!expect.matchError(error)) { 78 if (!expect.matchError(error)) {
79 _fail("Expected: $expect\n" 79 _fail("Expected: $expect\n"
80 "Found : [Data: ${error.error}]"); 80 "Found : [Data: ${error}]");
81 } 81 }
82 }); 82 });
83 } 83 }
84 84
85 void _onDone() { 85 void _onDone() {
86 _subscription = null; 86 _subscription = null;
87 _withNextExpectation((Event expect) { 87 _withNextExpectation((Event expect) {
88 if (!expect.matchDone()) { 88 if (!expect.matchDone()) {
89 _fail("Expected: $expect\n" 89 _fail("Expected: $expect\n"
90 "Found : [Done]"); 90 "Found : [Done]");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 class Event { 184 class Event {
185 Function _action; 185 Function _action;
186 Event(void this._action()); 186 Event(void this._action());
187 187
188 bool matchData(var data) { 188 bool matchData(var data) {
189 if (!_testData(data)) return false; 189 if (!_testData(data)) return false;
190 if (_action != null) _action(); 190 if (_action != null) _action();
191 return true; 191 return true;
192 } 192 }
193 bool matchError(AsyncError e) { 193 bool matchError(e) {
194 if (!_testError(e)) return false; 194 if (!_testError(e)) return false;
195 if (_action != null) _action(); 195 if (_action != null) _action();
196 return true; 196 return true;
197 } 197 }
198 bool matchDone() { 198 bool matchDone() {
199 if (!_testDone()) return false; 199 if (!_testDone()) return false;
200 if (_action != null) _action(); 200 if (_action != null) _action();
201 return true; 201 return true;
202 } 202 }
203 bool matchPauseChange(StreamController c) { 203 bool matchPauseChange(StreamController c) {
(...skipping 22 matching lines...) Expand all
226 class DataEvent extends Event { 226 class DataEvent extends Event {
227 final data; 227 final data;
228 DataEvent(this.data, void action()) : super(action); 228 DataEvent(this.data, void action()) : super(action);
229 bool _testData(var data) => this.data == data; 229 bool _testData(var data) => this.data == data;
230 String toString() => "[Data: $data]"; 230 String toString() => "[Data: $data]";
231 } 231 }
232 232
233 class ErrorEvent extends Event { 233 class ErrorEvent extends Event {
234 final error; 234 final error;
235 ErrorEvent(this.error, void action()) : super(action); 235 ErrorEvent(this.error, void action()) : super(action);
236 bool _testError(AsyncError error) => this.error == error.error; 236 bool _testError(error) => this.error == error;
237 String toString() => "[Error: $error]"; 237 String toString() => "[Error: $error]";
238 } 238 }
239 239
240 class DoneEvent extends Event { 240 class DoneEvent extends Event {
241 DoneEvent(void action()) : super(action); 241 DoneEvent(void action()) : super(action);
242 bool _testDone() => true; 242 bool _testDone() => true;
243 String toString() => "[Done]"; 243 String toString() => "[Done]";
244 } 244 }
245 245
246 class PauseCallbackEvent extends Event { 246 class PauseCallbackEvent extends Event {
(...skipping 16 matching lines...) Expand all
263 } 263 }
264 264
265 265
266 class LogAnyEvent extends Event { 266 class LogAnyEvent extends Event {
267 String _actual = "*Not matched yet*"; 267 String _actual = "*Not matched yet*";
268 LogAnyEvent(void action()) : super(action); 268 LogAnyEvent(void action()) : super(action);
269 bool _testData(var data) { 269 bool _testData(var data) {
270 _actual = "*[Data $data]"; 270 _actual = "*[Data $data]";
271 return true; 271 return true;
272 } 272 }
273 bool _testError(AsyncError error) { 273 bool _testError(error) {
274 _actual = "*[Error ${error.error}]"; 274 _actual = "*[Error ${error}]";
275 return true; 275 return true;
276 } 276 }
277 bool _testDone() { 277 bool _testDone() {
278 _actual = "*[Done]"; 278 _actual = "*[Done]";
279 return true; 279 return true;
280 } 280 }
281 bool _testPause(StreamController c) { 281 bool _testPause(StreamController c) {
282 _actual = "*[Paused:${c.isPaused}]"; 282 _actual = "*[Paused:${c.isPaused}]";
283 return true; 283 return true;
284 } 284 }
285 bool _testSubcribe(StreamController c) { 285 bool _testSubcribe(StreamController c) {
286 _actual = "*[Has listener:${c.hasListener}, Paused:${c.isPaused}]"; 286 _actual = "*[Has listener:${c.hasListener}, Paused:${c.isPaused}]";
287 return true; 287 return true;
288 } 288 }
289 289
290 String toString() => _actual; 290 String toString() => _actual;
291 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698