Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: packages/stack_trace/test/utils.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/stack_trace/test/trace_test.dart ('k') | packages/stack_trace/test/vm_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/stack_trace/test/utils.dart
diff --git a/packages/stack_trace/test/utils.dart b/packages/stack_trace/test/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..912f8f4ed007a5aace161296fdbe72ca58ab1083
--- /dev/null
+++ b/packages/stack_trace/test/utils.dart
@@ -0,0 +1,37 @@
+// 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:test/test.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);
+}
« no previous file with comments | « packages/stack_trace/test/trace_test.dart ('k') | packages/stack_trace/test/vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698