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: test/future_matchers_test.dart

Issue 840133003: matcher: fixed status file, formatting, tweaks to readme (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: Created 5 years, 11 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 matcher.future_matchers_test; 5 library matcher.future_matchers_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:matcher/matcher.dart'; 9 import 'package:matcher/matcher.dart';
10 import 'package:unittest/unittest.dart' show test, group; 10 import 'package:unittest/unittest.dart' show test, group;
11 11
12 import 'test_utils.dart'; 12 import 'test_utils.dart';
13 13
14 void main() { 14 void main() {
15 initUtils(); 15 initUtils();
16 16
17 test('completes - unexpected error', () { 17 test('completes - unexpected error', () {
18 var completer = new Completer(); 18 var completer = new Completer();
19 completer.completeError('X'); 19 completer.completeError('X');
20 shouldFail(completer.future, completes, 20 shouldFail(completer.future, completes, contains(
21 contains('Expected future to complete successfully, ' 21 'Expected future to complete successfully, '
22 'but it failed with X'), 22 'but it failed with X'), isAsync: true);
23 isAsync: true);
24 }); 23 });
25 24
26 test('completes - successfully', () { 25 test('completes - successfully', () {
27 var completer = new Completer(); 26 var completer = new Completer();
28 completer.complete('1'); 27 completer.complete('1');
29 shouldPass(completer.future, completes, isAsync: true); 28 shouldPass(completer.future, completes, isAsync: true);
30 }); 29 });
31 30
32 test('throws - unexpected to see normal completion', () { 31 test('throws - unexpected to see normal completion', () {
33 var completer = new Completer(); 32 var completer = new Completer();
34 completer.complete('1'); 33 completer.complete('1');
35 shouldFail(completer.future, throws, 34 shouldFail(completer.future, throws,
36 contains("Expected future to fail, but succeeded with '1'"), 35 contains("Expected future to fail, but succeeded with '1'"),
37 isAsync: true); 36 isAsync: true);
38 }); 37 });
39 38
40 test('throws - expected to see exception', () { 39 test('throws - expected to see exception', () {
41 var completer = new Completer(); 40 var completer = new Completer();
42 completer.completeError('X'); 41 completer.completeError('X');
43 shouldPass(completer.future, throws, isAsync: true); 42 shouldPass(completer.future, throws, isAsync: true);
44 }); 43 });
45 44
46 test('throws - expected to see exception thrown later on', () { 45 test('throws - expected to see exception thrown later on', () {
47 var completer = new Completer(); 46 var completer = new Completer();
48 var chained = completer.future.then((_) { throw 'X'; }); 47 var chained = completer.future.then((_) {
48 throw 'X';
49 });
49 shouldPass(chained, throws, isAsync: true); 50 shouldPass(chained, throws, isAsync: true);
50 completer.complete('1'); 51 completer.complete('1');
51 }); 52 });
52 53
53 test('throwsA - unexpected normal completion', () { 54 test('throwsA - unexpected normal completion', () {
54 var completer = new Completer(); 55 var completer = new Completer();
55 completer.complete('1'); 56 completer.complete('1');
56 shouldFail(completer.future, throwsA(equals('X')), 57 shouldFail(completer.future, throwsA(equals('X')),
57 contains("Expected future to fail, but succeeded with '1'"), 58 contains("Expected future to fail, but succeeded with '1'"),
58 isAsync: true); 59 isAsync: true);
59 }); 60 });
60 61
61 test('throwsA - correct error', () { 62 test('throwsA - correct error', () {
62 var completer = new Completer(); 63 var completer = new Completer();
63 completer.completeError('X'); 64 completer.completeError('X');
64 shouldPass(completer.future, throwsA(equals('X')), isAsync: true); 65 shouldPass(completer.future, throwsA(equals('X')), isAsync: true);
65 }); 66 });
66 67
67 test('throwsA - wrong error', () { 68 test('throwsA - wrong error', () {
68 var completer = new Completer(); 69 var completer = new Completer();
69 completer.completeError('X'); 70 completer.completeError('X');
70 shouldFail(completer.future, throwsA(equals('Y')), 71 shouldFail(completer.future, throwsA(equals('Y')),
71 "Expected: 'Y' Actual: 'X' " 72 "Expected: 'Y' Actual: 'X' "
72 "Which: is different. " 73 "Which: is different. "
73 "Expected: Y Actual: X ^ Differ at offset 0", 74 "Expected: Y Actual: X ^ Differ at offset 0", isAsync: true);
74 isAsync: true);
75 }); 75 });
76 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698