OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 mock.log_entry_list; | 5 library mock.log_entry_list; |
6 | 6 |
7 import 'package:matcher/matcher.dart'; | 7 import 'package:matcher/matcher.dart'; |
8 | 8 |
9 import 'call_matcher.dart'; | 9 import 'call_matcher.dart'; |
10 import 'log_entry.dart'; | 10 import 'log_entry.dart'; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 return rtn; | 95 return rtn; |
96 } | 96 } |
97 | 97 |
98 /** Apply a unit test [Matcher] to the [LogEntryList]. */ | 98 /** Apply a unit test [Matcher] to the [LogEntryList]. */ |
99 LogEntryList verify(Matcher matcher) { | 99 LogEntryList verify(Matcher matcher) { |
100 if (_mockFailureHandler == null) { | 100 if (_mockFailureHandler == null) { |
101 _mockFailureHandler = | 101 _mockFailureHandler = |
102 new _MockFailureHandler(getOrCreateExpectFailureHandler()); | 102 new _MockFailureHandler(getOrCreateExpectFailureHandler()); |
103 } | 103 } |
104 expect(logs, matcher, reason:filter, failureHandler: _mockFailureHandler); | 104 expect(logs, matcher, reason: filter, failureHandler: _mockFailureHandler); |
105 return this; | 105 return this; |
106 } | 106 } |
107 | 107 |
108 /** | 108 /** |
109 * Iterate through the list and call the [validator] function with the | 109 * Iterate through the list and call the [validator] function with the |
110 * log [List] and position. The [validator] should return the number of | 110 * log [List] and position. The [validator] should return the number of |
111 * positions to advance upon success, or zero upon failure. When zero is | 111 * positions to advance upon success, or zero upon failure. When zero is |
112 * returned an error is reported. [reason] can be used to provide a | 112 * returned an error is reported. [reason] can be used to provide a |
113 * more descriptive failure message. If a failure occurred false will be | 113 * more descriptive failure message. If a failure occurred false will be |
114 * returned (unless the failure handler itself threw an exception); | 114 * returned (unless the failure handler itself threw an exception); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 * that was used to select the logs that were verified. | 555 * that was used to select the logs that were verified. |
556 */ | 556 */ |
557 String _mockingErrorFormatter(actual, Matcher matcher, String signature, | 557 String _mockingErrorFormatter(actual, Matcher matcher, String signature, |
558 Map matchState, bool verbose) { | 558 Map matchState, bool verbose) { |
559 var description = new StringDescription(); | 559 var description = new StringDescription(); |
560 description.add('Expected ${signature} ').addDescriptionOf(matcher). | 560 description.add('Expected ${signature} ').addDescriptionOf(matcher). |
561 add('\n but: '); | 561 add('\n but: '); |
562 matcher.describeMismatch(actual, description, matchState, verbose).add('.'); | 562 matcher.describeMismatch(actual, description, matchState, verbose).add('.'); |
563 return description.toString(); | 563 return description.toString(); |
564 } | 564 } |
OLD | NEW |