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

Side by Side Diff: lib/src/future_matchers.dart

Issue 840133003: matcher: fixed status file, formatting, tweaks to readme (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: nits 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
« no previous file with comments | « lib/src/expect.dart ('k') | lib/src/interfaces.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; 5 library matcher.future_matchers;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'expect.dart'; 9 import 'expect.dart';
10 import 'interfaces.dart'; 10 import 'interfaces.dart';
(...skipping 28 matching lines...) Expand all
39 final Matcher _matcher; 39 final Matcher _matcher;
40 final String _id; 40 final String _id;
41 41
42 const _Completes(this._matcher, this._id); 42 const _Completes(this._matcher, this._id);
43 43
44 bool matches(item, Map matchState) { 44 bool matches(item, Map matchState) {
45 if (item is! Future) return false; 45 if (item is! Future) return false;
46 var done = wrapAsync((fn) => fn(), _id); 46 var done = wrapAsync((fn) => fn(), _id);
47 47
48 item.then((value) { 48 item.then((value) {
49 done(() { if (_matcher != null) expect(value, _matcher); }); 49 done(() {
50 if (_matcher != null) expect(value, _matcher);
51 });
50 }, onError: (error, trace) { 52 }, onError: (error, trace) {
51 var id = _id == '' ? '' : '${_id} '; 53 var id = _id == '' ? '' : '${_id} ';
52 var reason = 'Expected future ${id}to complete successfully, ' 54 var reason = 'Expected future ${id}to complete successfully, '
53 'but it failed with ${error}'; 55 'but it failed with ${error}';
54 if (trace != null) { 56 if (trace != null) {
55 var stackTrace = trace.toString(); 57 var stackTrace = trace.toString();
56 stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}'; 58 stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}';
57 reason = '$reason\nStack trace:\n$stackTrace'; 59 reason = '$reason\nStack trace:\n$stackTrace';
58 } 60 }
59 done(() => fail(reason)); 61 done(() => fail(reason));
60 }); 62 });
61 63
62 return true; 64 return true;
63 } 65 }
64 66
65 Description describe(Description description) { 67 Description describe(Description description) {
66 if (_matcher == null) { 68 if (_matcher == null) {
67 description.add('completes successfully'); 69 description.add('completes successfully');
68 } else { 70 } else {
69 description.add('completes to a value that ').addDescriptionOf(_matcher); 71 description.add('completes to a value that ').addDescriptionOf(_matcher);
70 } 72 }
71 return description; 73 return description;
72 } 74 }
73 } 75 }
OLDNEW
« no previous file with comments | « lib/src/expect.dart ('k') | lib/src/interfaces.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698