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

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

Issue 218273002: Upgrading tests with unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test the Stream.single method. 5 // Test the Stream.single method.
6 library stream_single_test; 6 library stream_single_test;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:isolate'; 10 import 'dart:isolate';
11 import '../../../pkg/unittest/lib/unittest.dart'; 11 import '../../../pkg/unittest/lib/unittest.dart';
12 import 'event_helper.dart'; 12 import 'event_helper.dart';
13 13
14 main() { 14 main() {
15 test("single", () { 15 test("single", () {
16 StreamController c = new StreamController(sync: true); 16 StreamController c = new StreamController(sync: true);
17 Future f = c.stream.single; 17 Future f = c.stream.single;
18 f.then(expectAsync1((v) { Expect.equals(42, v);})); 18 f.then(expectAsync((v) { Expect.equals(42, v);}));
19 new Events.fromIterable([42]).replay(c); 19 new Events.fromIterable([42]).replay(c);
20 }); 20 });
21 21
22 test("single empty", () { 22 test("single empty", () {
23 StreamController c = new StreamController(sync: true); 23 StreamController c = new StreamController(sync: true);
24 Future f = c.stream.single; 24 Future f = c.stream.single;
25 f.catchError(expectAsync1((error) { Expect.isTrue(error is StateError); })); 25 f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); }));
26 new Events.fromIterable([]).replay(c); 26 new Events.fromIterable([]).replay(c);
27 }); 27 });
28 28
29 test("single error", () { 29 test("single error", () {
30 StreamController c = new StreamController(sync: true); 30 StreamController c = new StreamController(sync: true);
31 Future f = c.stream.single; 31 Future f = c.stream.single;
32 f.catchError(expectAsync1((error) { Expect.equals("error", error); })); 32 f.catchError(expectAsync((error) { Expect.equals("error", error); }));
33 Events errorEvents = new Events()..error("error")..close(); 33 Events errorEvents = new Events()..error("error")..close();
34 errorEvents.replay(c); 34 errorEvents.replay(c);
35 }); 35 });
36 36
37 test("single error 2", () { 37 test("single error 2", () {
38 StreamController c = new StreamController(sync: true); 38 StreamController c = new StreamController(sync: true);
39 Future f = c.stream.single; 39 Future f = c.stream.single;
40 f.catchError(expectAsync1((error) { Expect.equals("error", error); })); 40 f.catchError(expectAsync((error) { Expect.equals("error", error); }));
41 Events errorEvents = new Events()..error("error")..error("error2")..close(); 41 Events errorEvents = new Events()..error("error")..error("error2")..close();
42 errorEvents.replay(c); 42 errorEvents.replay(c);
43 }); 43 });
44 44
45 test("single error 3", () { 45 test("single error 3", () {
46 StreamController c = new StreamController(sync: true); 46 StreamController c = new StreamController(sync: true);
47 Future f = c.stream.single; 47 Future f = c.stream.single;
48 f.catchError(expectAsync1((error) { Expect.equals("error", error); })); 48 f.catchError(expectAsync((error) { Expect.equals("error", error); }));
49 Events errorEvents = new Events()..add(499)..error("error")..close(); 49 Events errorEvents = new Events()..add(499)..error("error")..close();
50 errorEvents.replay(c); 50 errorEvents.replay(c);
51 }); 51 });
52 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698