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

Unified Diff: pkg/matcher/lib/src/operator_matchers.dart

Issue 807193003: Re-apply "Remove unittest and matcher from the repo." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years 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 | « pkg/matcher/lib/src/numeric_matchers.dart ('k') | pkg/matcher/lib/src/pretty_print.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/matcher/lib/src/operator_matchers.dart
diff --git a/pkg/matcher/lib/src/operator_matchers.dart b/pkg/matcher/lib/src/operator_matchers.dart
deleted file mode 100644
index 4661b7d51e3e6dc48af7ee5b514b29f5a6fab063..0000000000000000000000000000000000000000
--- a/pkg/matcher/lib/src/operator_matchers.dart
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (c) 2012, 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 matcher.operator_matchers;
-
-import 'interfaces.dart';
-import 'util.dart';
-
-/// This returns a matcher that inverts [matcher] to its logical negation.
-Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher));
-
-class _IsNot extends Matcher {
- final Matcher _matcher;
-
- const _IsNot(this._matcher);
-
- bool matches(item, Map matchState) => !_matcher.matches(item, matchState);
-
- Description describe(Description description) =>
- description.add('not ').addDescriptionOf(_matcher);
-}
-
-/// This returns a matcher that matches if all of the matchers passed as
-/// arguments (up to 7) match.
-///
-/// Instead of passing the matchers separately they can be passed as a single
-/// List argument. Any argument that is not a matcher is implicitly wrapped in a
-/// Matcher to check for equality.
-Matcher allOf(arg0,
- [arg1 = null,
- arg2 = null,
- arg3 = null,
- arg4 = null,
- arg5 = null,
- arg6 = null]) {
- return new _AllOf(_wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6));
-}
-
-class _AllOf extends Matcher {
- final List<Matcher> _matchers;
-
- const _AllOf(this._matchers);
-
- bool matches(item, Map matchState) {
- for (var matcher in _matchers) {
- if (!matcher.matches(item, matchState)) {
- addStateInfo(matchState, {'matcher': matcher});
- return false;
- }
- }
- return true;
- }
-
- Description describeMismatch(item, Description mismatchDescription,
- Map matchState, bool verbose) {
- var matcher = matchState['matcher'];
- matcher.describeMismatch(item, mismatchDescription,
- matchState['state'], verbose);
- return mismatchDescription;
- }
-
- Description describe(Description description) =>
- description.addAll('(', ' and ', ')', _matchers);
-}
-
-/// Matches if any of the given matchers evaluate to true.
-///
-/// The arguments can be a set of matchers as separate parameters
-/// (up to 7), or a List of matchers.
-///
-/// The matchers are evaluated from left to right using short-circuit
-/// evaluation, so evaluation stops as soon as a matcher returns true.
-///
-/// Any argument that is not a matcher is implicitly wrapped in a
-/// Matcher to check for equality.
-Matcher anyOf(arg0,
- [arg1 = null,
- arg2 = null,
- arg3 = null,
- arg4 = null,
- arg5 = null,
- arg6 = null]) {
- return new _AnyOf(_wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6));
-}
-
-class _AnyOf extends Matcher {
- final List<Matcher> _matchers;
-
- const _AnyOf(this._matchers);
-
- bool matches(item, Map matchState) {
- for (var matcher in _matchers) {
- if (matcher.matches(item, matchState)) {
- return true;
- }
- }
- return false;
- }
-
- Description describe(Description description) =>
- description.addAll('(', ' or ', ')', _matchers);
-}
-
-List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
- Iterable<Matcher> matchers;
- if (arg0 is List) {
- if (arg1 != null || arg2 != null || arg3 != null || arg4 != null ||
- arg5 != null || arg6 != null) {
- throw new ArgumentError('If arg0 is a List, all other arguments must be'
- ' null.');
- }
-
- matchers = arg0;
- } else {
- matchers = [arg0, arg1, arg2, arg3, arg4, arg5, arg6]
- .where((e) => e != null);
- }
-
- return matchers
- .map((e) => wrapMatcher(e))
- .toList();
-}
« no previous file with comments | « pkg/matcher/lib/src/numeric_matchers.dart ('k') | pkg/matcher/lib/src/pretty_print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698