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

Side by Side Diff: pkg/matcher/test/future_matchers_test.dart

Issue 313563002: pkg/matcher: Reverting 36881,36896 while investigating dart2js checked crash (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library matcher.future_matchers_test;
6
7 import 'dart:async';
8
9 import 'package:matcher/matcher.dart';
10 import 'package:unittest/unittest.dart' show test, group;
11
12 import 'test_utils.dart';
13
14 void main() {
15 initUtils();
16
17 test('completes - unexpected error', () {
18 var completer = new Completer();
19 completer.completeError('X');
20 shouldFail(completer.future, completes,
21 contains('Expected future to complete successfully, '
22 'but it failed with X'),
23 isAsync: true);
24 });
25
26 test('completes - successfully', () {
27 var completer = new Completer();
28 completer.complete('1');
29 shouldPass(completer.future, completes, isAsync: true);
30 });
31
32 test('throws - unexpected to see normal completion', () {
33 var completer = new Completer();
34 completer.complete('1');
35 shouldFail(completer.future, throws,
36 contains("Expected future to fail, but succeeded with '1'"),
37 isAsync: true);
38 });
39
40 test('throws - expected to see exception', () {
41 var completer = new Completer();
42 completer.completeError('X');
43 shouldPass(completer.future, throws, isAsync: true);
44 });
45
46 test('throws - expected to see exception thrown later on', () {
47 var completer = new Completer();
48 var chained = completer.future.then((_) { throw 'X'; });
49 shouldPass(chained, throws, isAsync: true);
50 completer.complete('1');
51 });
52
53 test('throwsA - unexpected normal completion', () {
54 var completer = new Completer();
55 completer.complete('1');
56 shouldFail(completer.future, throwsA(equals('X')),
57 contains("Expected future to fail, but succeeded with '1'"),
58 isAsync: true);
59 });
60
61 test('throwsA - correct error', () {
62 var completer = new Completer();
63 completer.completeError('X');
64 shouldPass(completer.future, throwsA(equals('X')), isAsync: true);
65 });
66
67 test('throwsA - wrong error', () {
68 var completer = new Completer();
69 completer.completeError('X');
70 shouldFail(completer.future, throwsA(equals('Y')),
71 "Expected: 'Y' Actual: 'X' "
72 "Which: is different. "
73 "Expected: Y Actual: X ^ Differ at offset 0",
74 isAsync: true);
75 });
76 }
OLDNEW
« no previous file with comments | « pkg/matcher/test/deprecated_matchers_test.dart ('k') | pkg/matcher/test/iterable_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698