35dc712dd5
This class uses zones to track stack traces across asynchronous boundaries. It will aid considerably in debugging errors in heavily-asynchronous programs. R=floitsch@google.com, rnystrom@google.com BUG=7040 Review URL: https://codereview.chromium.org//75863004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30738 260f80e4-7a28-3924-810f-c04153c831b5
38 lines
1.4 KiB
Dart
38 lines
1.4 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library stack_trace.test.utils;
|
|
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
/// Returns a matcher that runs [matcher] against a [Frame]'s `member` field.
|
|
Matcher frameMember(matcher) =>
|
|
transform((frame) => frame.member, matcher, 'member');
|
|
|
|
/// Returns a matcher that runs [matcher] against a [Frame]'s `library` field.
|
|
Matcher frameLibrary(matcher) =>
|
|
transform((frame) => frame.library, matcher, 'library');
|
|
|
|
/// Returns a matcher that runs [transformation] on its input, then matches
|
|
/// the output against [matcher].
|
|
///
|
|
/// [description] should be a noun phrase that describes the relation of the
|
|
/// output of [transformation] to its input.
|
|
Matcher transform(transformation(value), matcher, String description) =>
|
|
new _TransformMatcher(transformation, wrapMatcher(matcher), description);
|
|
|
|
class _TransformMatcher extends Matcher {
|
|
final Function _transformation;
|
|
final Matcher _matcher;
|
|
final String _description;
|
|
|
|
_TransformMatcher(this._transformation, this._matcher, this._description);
|
|
|
|
bool matches(item, Map matchState) =>
|
|
_matcher.matches(_transformation(item), matchState);
|
|
|
|
Description describe(Description description) =>
|
|
description.add(_description).add(' ').addDescriptionOf(_matcher);
|
|
}
|