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

Side by Side Diff: utils/tests/pub/error_group_test.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 error_group_test; 5 library error_group_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 18 matching lines...) Expand all
29 test('should pass signaled errors to .done', () { 29 test('should pass signaled errors to .done', () {
30 expect(errorGroup.done, throwsFormatException); 30 expect(errorGroup.done, throwsFormatException);
31 errorGroup.signalError(new AsyncError(new FormatException())); 31 errorGroup.signalError(new AsyncError(new FormatException()));
32 }); 32 });
33 33
34 test("shouldn't allow additional futures or streams once an error has been " 34 test("shouldn't allow additional futures or streams once an error has been "
35 "signaled", () { 35 "signaled", () {
36 expect(errorGroup.done, throwsFormatException); 36 expect(errorGroup.done, throwsFormatException);
37 errorGroup.signalError(new AsyncError(new FormatException())); 37 errorGroup.signalError(new AsyncError(new FormatException()));
38 38
39 expect(() => errorGroup.registerFuture(new Future.immediate(null)), 39 expect(() => errorGroup.registerFuture(new Future.value()),
40 throwsStateError); 40 throwsStateError);
41 expect(() => errorGroup.registerStream(new StreamController().stream), 41 expect(() => errorGroup.registerStream(new StreamController().stream),
42 throwsStateError); 42 throwsStateError);
43 }); 43 });
44 }); 44 });
45 45
46 group('with a single future', () { 46 group('with a single future', () {
47 Completer completer; 47 Completer completer;
48 Future future; 48 Future future;
49 49
50 setUp(() { 50 setUp(() {
51 errorGroup = new ErrorGroup(); 51 errorGroup = new ErrorGroup();
52 completer = new Completer(); 52 completer = new Completer();
53 future = errorGroup.registerFuture(completer.future); 53 future = errorGroup.registerFuture(completer.future);
54 }); 54 });
55 55
56 test('should pass through a value from the future', () { 56 test('should pass through a value from the future', () {
57 expect(future, completion(equals('value'))); 57 expect(future, completion(equals('value')));
58 expect(errorGroup.done, completes); 58 expect(errorGroup.done, completes);
59 completer.complete('value'); 59 completer.complete('value');
60 }); 60 });
61 61
62 test("shouldn't allow additional futures or streams once .done has " 62 test("shouldn't allow additional futures or streams once .done has "
63 "been called", () { 63 "been called", () {
64 completer.complete('value'); 64 completer.complete('value');
65 65
66 expect(() => errorGroup.registerFuture(new Future.immediate(null)), 66 expect(() => errorGroup.registerFuture(new Future.value()),
67 throwsStateError); 67 throwsStateError);
68 expect(() => errorGroup.registerStream(new StreamController().stream), 68 expect(() => errorGroup.registerStream(new StreamController().stream),
69 throwsStateError); 69 throwsStateError);
70 }); 70 });
71 71
72 test('should pass through an exception from the future if it has a ' 72 test('should pass through an exception from the future if it has a '
73 'listener', () { 73 'listener', () {
74 expect(future, throwsFormatException); 74 expect(future, throwsFormatException);
75 // errorGroup shouldn't top-level the exception 75 // errorGroup shouldn't top-level the exception
76 completer.completeError(new FormatException()); 76 completer.completeError(new FormatException());
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 expect(stream.toList(), completion(equals(['value1', 'value2']))); 445 expect(stream.toList(), completion(equals(['value1', 'value2'])));
446 controller..add('value1')..add('value2')..close(); 446 controller..add('value1')..add('value2')..close();
447 447
448 expect(stream.toList().then((_) { 448 expect(stream.toList().then((_) {
449 // shouldn't cause a top-level exception 449 // shouldn't cause a top-level exception
450 completer.completeError(new FormatException()); 450 completer.completeError(new FormatException());
451 }), completes); 451 }), completes);
452 }); 452 });
453 }); 453 });
454 } 454 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698