| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013, 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 stack_trace.test.utils; | |
| 6 | |
| 7 import 'package:unittest/unittest.dart'; | |
| 8 | |
| 9 /// Returns a matcher that runs [matcher] against a [Frame]'s `member` field. | |
| 10 Matcher frameMember(matcher) => | |
| 11 transform((frame) => frame.member, matcher, 'member'); | |
| 12 | |
| 13 /// Returns a matcher that runs [matcher] against a [Frame]'s `library` field. | |
| 14 Matcher frameLibrary(matcher) => | |
| 15 transform((frame) => frame.library, matcher, 'library'); | |
| 16 | |
| 17 /// Returns a matcher that runs [transformation] on its input, then matches | |
| 18 /// the output against [matcher]. | |
| 19 /// | |
| 20 /// [description] should be a noun phrase that describes the relation of the | |
| 21 /// output of [transformation] to its input. | |
| 22 Matcher transform(transformation(value), matcher, String description) => | |
| 23 new _TransformMatcher(transformation, wrapMatcher(matcher), description); | |
| 24 | |
| 25 class _TransformMatcher extends Matcher { | |
| 26 final Function _transformation; | |
| 27 final Matcher _matcher; | |
| 28 final String _description; | |
| 29 | |
| 30 _TransformMatcher(this._transformation, this._matcher, this._description); | |
| 31 | |
| 32 bool matches(item, Map matchState) => | |
| 33 _matcher.matches(_transformation(item), matchState); | |
| 34 | |
| 35 Description describe(Description description) => | |
| 36 description.add(_description).add(' ').addDescriptionOf(_matcher); | |
| 37 } | |
| OLD | NEW |