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: pkg/scheduled_test/test/scheduled_future_matchers_test.dart

Issue 13472016: Split apart several asynchronous tests to reduce timeouts. (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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6 import 'dart:io';
7
8 import 'package:scheduled_test/scheduled_test.dart';
9
10 import 'metatest.dart';
11 import 'utils.dart';
12
13 void main() {
14 setUpTimeout();
15
16 expectTestsPass("expect(..., completes) with a completing future should pass",
17 () {
18 test('test', () {
19 expect(pumpEventQueue(), completes);
20 });
21 });
22
23 expectTestsPass("expect(..., completes) with a failing future should signal "
24 "an out-of-band error", () {
25 var errors;
26 test('test 1', () {
27 currentSchedule.onException.schedule(() {
28 errors = currentSchedule.errors;
29 });
30
31 expect(pumpEventQueue().then((_) {
32 throw 'error';
33 }), completes);
34 });
35
36 test('test 2', () {
37 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
38 expect(errors.map((e) => e.error), equals(['error']));
39 });
40 }, passing: ['test 2']);
41
42 expectTestsPass("expect(..., completion(...)) with a matching future should "
43 "pass", () {
44 test('test', () {
45 expect(pumpEventQueue().then((_) => 'foo'), completion(equals('foo')));
46 });
47 });
48
49 expectTestsPass("expect(..., completion(...)) with a non-matching future "
50 "should signal an out-of-band error", () {
51 var errors;
52 test('test 1', () {
53 currentSchedule.onException.schedule(() {
54 errors = currentSchedule.errors;
55 });
56
57 expect(pumpEventQueue().then((_) => 'foo'), completion(equals('bar')));
58 });
59
60 test('test 2', () {
61 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
62 expect(errors.length, equals(1));
63 expect(errors.first.error, new isInstanceOf<TestFailure>());
64 });
65 }, passing: ['test 2']);
66
67 expectTestsPass("expect(..., completion(...)) with a failing future should "
68 "signal an out-of-band error", () {
69 var errors;
70 test('test 1', () {
71 currentSchedule.onException.schedule(() {
72 errors = currentSchedule.errors;
73 });
74
75 expect(pumpEventQueue().then((_) {
76 throw 'error';
77 }), completion(equals('bar')));
78 });
79
80 test('test 2', () {
81 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
82 expect(errors.map((e) => e.error), equals(['error']));
83 });
84 }, passing: ['test 2']);
85 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/descriptor_test.dart ('k') | pkg/scheduled_test/test/scheduled_process_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698