OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library matcher.util; | |
6 | |
7 import 'core_matchers.dart'; | |
8 import 'interfaces.dart'; | |
9 | |
10 /// Useful utility for nesting match states. | |
11 void addStateInfo(Map matchState, Map values) { | |
12 var innerState = new Map.from(matchState); | |
13 matchState.clear(); | |
14 matchState['state'] = innerState; | |
15 matchState.addAll(values); | |
16 } | |
17 | |
18 /// Takes an argument and returns an equivalent [Matcher]. | |
19 /// | |
20 /// If the argument is already a matcher this does nothing, | |
21 /// else if the argument is a function, it generates a predicate | |
22 /// function matcher, else it generates an equals matcher. | |
23 Matcher wrapMatcher(x) { | |
24 if (x is Matcher) { | |
25 return x; | |
26 } else if (x is Function) { | |
27 return predicate(x); | |
28 } else { | |
29 return equals(x); | |
30 } | |
31 } | |
OLD | NEW |