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

Side by Side Diff: tests/lib/async/catch_errors12_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) 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 import 'package:async_helper/async_helper.dart'; 5 import 'package:async_helper/async_helper.dart';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import 'dart:async'; 7 import 'dart:async';
8 import 'catch_errors.dart'; 8 import 'catch_errors.dart';
9 9
10 main() { 10 main() {
11 asyncStart(); 11 asyncStart();
12 Completer done = new Completer(); 12 Completer done = new Completer();
13 13
14 var events = []; 14 var events = [];
15 // Tests that errors that have been delayed by several milliseconds with 15 // Tests that errors that have been delayed by several milliseconds with
16 // Timers are still caught by `catchErrors`. 16 // Timers are still caught by `catchErrors`.
17 catchErrors(() { 17 catchErrors(() {
18 events.add("catch error entry"); 18 events.add("catch error entry");
19 Timer.run(() { throw "timer error"; }); 19 Timer.run(() {
20 new Timer(const Duration(milliseconds: 100), () { throw "timer2 error"; }); 20 throw "timer error";
21 });
22 new Timer(const Duration(milliseconds: 100), () {
23 throw "timer2 error";
24 });
21 new Future.value(499).then((x) { 25 new Future.value(499).then((x) {
22 new Timer(const Duration(milliseconds: 200), () { 26 new Timer(const Duration(milliseconds: 200), () {
23 done.complete(499); 27 done.complete(499);
24 throw x; 28 throw x;
25 }); 29 });
26 }); 30 });
27 throw "catch error"; 31 throw "catch error";
28 }).listen((x) { 32 }).listen((x) {
29 events.add(x); 33 events.add(x);
30 }, 34 }, onDone: () {
31 onDone: () { Expect.fail("Unexpected callback"); }); 35 Expect.fail("Unexpected callback");
36 });
32 done.future.whenComplete(() { 37 done.future.whenComplete(() {
33 // Give time to execute the callbacks. 38 // Give time to execute the callbacks.
34 Timer.run(() { 39 Timer.run(() {
35 Expect.listEquals([ 40 Expect.listEquals([
36 "catch error entry", 41 "catch error entry",
37 "main exit", 42 "main exit",
38 "catch error", 43 "catch error",
39 "timer error", 44 "timer error",
40 "timer2 error", 45 "timer2 error",
41 499, 46 499,
42 ], 47 ], events);
43 events);
44 asyncEnd(); 48 asyncEnd();
45 }); 49 });
46 }); 50 });
47 events.add("main exit"); 51 events.add("main exit");
48 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698