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

Side by Side Diff: test/future_matchers_test.dart

Issue 869053002: unittest: refactor ahead of matcher changes (Closed) Base URL: https://github.com/dart-lang/unittest.git@master
Patch Set: nits Created 5 years, 10 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
« no previous file with comments | « pubspec.yaml ('k') | test/matchers_minified_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 unittest.future_matchers_test;
6
7 import 'dart:async';
8
9 import 'package:metatest/metatest.dart';
10 import 'package:unittest/unittest.dart';
11
12 void main() => initTests(_test);
13
14 void _test(message) {
15 initMetatest(message);
16
17 expectTestResults('group name test', () {
18 test('completes - unexpected error', () {
19 var completer = new Completer();
20 completer.completeError('X');
21 expect(completer.future, completes);
22 });
23
24 test('completes - successfully', () {
25 var completer = new Completer();
26 completer.complete('1');
27 expect(completer.future, completes);
28 });
29
30 test('throws - unexpected to see normal completion', () {
31 var completer = new Completer();
32 completer.complete('1');
33 expect(completer.future, throws);
34 });
35
36 test('throws - expected to see exception', () {
37 var completer = new Completer();
38 completer.completeError('X');
39 expect(completer.future, throws);
40 });
41
42 test('throws - expected to see exception thrown later on', () {
43 var completer = new Completer();
44 var chained = completer.future.then((_) {
45 throw 'X';
46 });
47 expect(chained, throws);
48 completer.complete('1');
49 });
50
51 test('throwsA - unexpected normal completion', () {
52 var completer = new Completer();
53 completer.complete('1');
54 expect(completer.future, throwsA(equals('X')));
55 });
56
57 test('throwsA - correct error', () {
58 var completer = new Completer();
59 completer.completeError('X');
60 expect(completer.future, throwsA(equals('X')));
61 });
62
63 test('throwsA - wrong error', () {
64 var completer = new Completer();
65 completer.completeError('X');
66 expect(completer.future, throwsA(equals('Y')));
67 });
68 }, [
69 {
70 'result': 'fail',
71 'message': 'Expected future to complete successfully, but it failed with '
72 'X',
73 },
74 {'result': 'pass'},
75 {
76 'result': 'fail',
77 'message': 'Expected future to fail, but succeeded with \'1\'.'
78 },
79 {'result': 'pass'},
80 {'result': 'pass'},
81 {
82 'result': 'fail',
83 'message': 'Expected future to fail, but succeeded with \'1\'.'
84 },
85 {'result': 'pass'},
86 {
87 'result': 'fail',
88 'message': '''Expected: 'Y'
89 Actual: 'X'
90 Which: is different.
91 Expected: Y
92 Actual: X
93 ^
94 Differ at offset 0
95 '''
96 }
97 ]);
98 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/matchers_minified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698