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 /// The mirror matchers library provides some additional matchers that | 5 /** |
6 /// make use of `dart:mirrors`. | 6 * The mirror matchers library provides some additional matchers that |
| 7 * make use of `dart:mirrors`. |
| 8 */ |
7 library matcher.mirror_matchers; | 9 library matcher.mirror_matchers; |
8 | 10 |
9 import 'dart:mirrors'; | 11 import 'dart:mirrors'; |
10 | 12 |
11 import 'matcher.dart'; | 13 import 'matcher.dart'; |
12 | 14 |
13 /// Returns a matcher that checks if a class instance has a property | 15 /** |
14 /// with name [name], and optionally, if that property in turn satisfies | 16 * Returns a matcher that checks if a class instance has a property |
15 /// a [matcher]. | 17 * with name [name], and optionally, if that property in turn satisfies |
| 18 * a [matcher]. |
| 19 */ |
16 Matcher hasProperty(String name, [matcher]) => | 20 Matcher hasProperty(String name, [matcher]) => |
17 new _HasProperty(name, matcher == null ? null : wrapMatcher(matcher)); | 21 new _HasProperty(name, matcher == null ? null : wrapMatcher(matcher)); |
18 | 22 |
19 class _HasProperty extends Matcher { | 23 class _HasProperty extends Matcher { |
20 final String _name; | 24 final String _name; |
21 final Matcher _matcher; | 25 final Matcher _matcher; |
22 | 26 |
23 const _HasProperty(this._name, [this._matcher]); | 27 const _HasProperty(this._name, [this._matcher]); |
24 | 28 |
25 bool matches(item, Map matchState) { | 29 bool matches(item, Map matchState) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 var innerDescription = new StringDescription(); | 71 var innerDescription = new StringDescription(); |
68 _matcher.describeMismatch(matchState['value'], innerDescription, | 72 _matcher.describeMismatch(matchState['value'], innerDescription, |
69 matchState['state'], verbose); | 73 matchState['state'], verbose); |
70 if (innerDescription.length > 0) { | 74 if (innerDescription.length > 0) { |
71 mismatchDescription.add(' which ').add(innerDescription.toString()); | 75 mismatchDescription.add(' which ').add(innerDescription.toString()); |
72 } | 76 } |
73 } | 77 } |
74 return mismatchDescription; | 78 return mismatchDescription; |
75 } | 79 } |
76 } | 80 } |
OLD | NEW |