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

Side by Side Diff: tests/lib_strong/async/stream_take_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 class A { const A(); } 9 class A {
10 class B extends A { const B(); } 10 const A();
11 }
12
13 class B extends A {
14 const B();
15 }
11 16
12 /// Stream which emits an error if it's not canceled at the correct time. 17 /// Stream which emits an error if it's not canceled at the correct time.
13 /// 18 ///
14 /// Must be canceled after at most [maxEvents] events. 19 /// Must be canceled after at most [maxEvents] events.
15 Stream makeStream(int maxEvents) { 20 Stream makeStream(int maxEvents) {
16 var c; 21 var c;
17 int event = 0; 22 int event = 0;
18 bool canceled = false; 23 bool canceled = false;
19 c = new StreamController(onListen: () { 24 c = new StreamController(onListen: () {
20 new Timer.periodic(const Duration(milliseconds: 10), (t) { 25 new Timer.periodic(const Duration(milliseconds: 10), (t) {
(...skipping 10 matching lines...) Expand all
31 } 36 }
32 }); 37 });
33 }, onCancel: () { 38 }, onCancel: () {
34 canceled = true; 39 canceled = true;
35 }); 40 });
36 return c.stream; 41 return c.stream;
37 } 42 }
38 43
39 main() { 44 main() {
40 asyncStart(); 45 asyncStart();
41 tests().then((_) { asyncEnd(); }); 46 tests().then((_) {
47 asyncEnd();
48 });
42 } 49 }
43 50
44 tests() async { 51 tests() async {
45 await expectThrowsAsync(makeStream(4).take(5).toList(), "5/4"); 52 await expectThrowsAsync(makeStream(4).take(5).toList(), "5/4");
46 await expectThrowsAsync(makeStream(0).take(1).toList(), "1/0"); 53 await expectThrowsAsync(makeStream(0).take(1).toList(), "1/0");
47 54
48 Expect.listEquals([0, 1, 2, 3, 4], await makeStream(5).take(5).toList()); 55 Expect.listEquals([0, 1, 2, 3, 4], await makeStream(5).take(5).toList());
49 56
50 Expect.listEquals([0, 1, 2, 3], await makeStream(5).take(4).toList()); 57 Expect.listEquals([0, 1, 2, 3], await makeStream(5).take(4).toList());
51 58
52 Expect.listEquals([0], await makeStream(5).take(1).toList()); 59 Expect.listEquals([0], await makeStream(5).take(1).toList());
53 60
54 Expect.listEquals([], await makeStream(5).take(0).toList()); 61 Expect.listEquals([], await makeStream(5).take(0).toList());
55 62
56 Expect.listEquals([], await makeStream(0).take(0).toList()); 63 Expect.listEquals([], await makeStream(0).take(0).toList());
57 } 64 }
58 65
59 Future expectThrowsAsync(Future computation, String name) { 66 Future expectThrowsAsync(Future computation, String name) {
60 return computation.then((_) { 67 return computation.then((_) {
61 Expect.fail("$name: Did not throw"); 68 Expect.fail("$name: Did not throw");
62 }, onError: (e, s){}); 69 }, onError: (e, s) {});
63 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698