cleanup(test): move CustomMatcher tests to their own file (#83)
diff --git a/test/core_matchers_test.dart b/test/core_matchers_test.dart
index 5b24d46..256d8ff 100644
--- a/test/core_matchers_test.dart
+++ b/test/core_matchers_test.dart
@@ -227,29 +227,4 @@
shouldPass('cow', predicate((x) => x is String, "an instance of String"));
});
});
-
- test("Feature Matcher", () {
- var w = new Widget();
- w.price = 10;
- shouldPass(w, new HasPrice(10));
- shouldPass(w, new HasPrice(greaterThan(0)));
- shouldFail(
- w,
- new HasPrice(greaterThan(10)),
- "Expected: Widget with a price that is a value greater than <10> "
- "Actual: <Instance of 'Widget'> "
- "Which: has price with value <10> which is not "
- "a value greater than <10>");
- });
-
- test("Custom Matcher Exception", () {
- shouldFail(
- "a",
- new BadCustomMatcher(),
- allOf([
- contains("Expected: feature {1: 'a'} "),
- contains("Actual: 'a' "),
- contains("Which: threw 'Exception: bang' "),
- ]));
- });
}
diff --git a/test/custom_matcher_test.dart b/test/custom_matcher_test.dart
new file mode 100644
index 0000000..3ff4813
--- /dev/null
+++ b/test/custom_matcher_test.dart
@@ -0,0 +1,45 @@
+// 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.
+
+import 'package:matcher/matcher.dart';
+import 'package:test/test.dart' show test;
+
+import 'test_utils.dart';
+
+class _BadCustomMatcher extends CustomMatcher {
+ _BadCustomMatcher() : super("feature", "description", {1: "a"});
+ featureValueOf(actual) => throw new Exception("bang");
+}
+
+class _HasPrice extends CustomMatcher {
+ _HasPrice(matcher) : super("Widget with a price that is", "price", matcher);
+ featureValueOf(actual) => actual.price;
+}
+
+void main() {
+ test("Feature Matcher", () {
+ var w = new Widget();
+ w.price = 10;
+ shouldPass(w, new _HasPrice(10));
+ shouldPass(w, new _HasPrice(greaterThan(0)));
+ shouldFail(
+ w,
+ new _HasPrice(greaterThan(10)),
+ "Expected: Widget with a price that is a value greater than <10> "
+ "Actual: <Instance of 'Widget'> "
+ "Which: has price with value <10> which is not "
+ "a value greater than <10>");
+ });
+
+ test("Custom Matcher Exception", () {
+ shouldFail(
+ "a",
+ new _BadCustomMatcher(),
+ allOf([
+ contains("Expected: feature {1: 'a'} "),
+ contains("Actual: 'a' "),
+ contains("Which: threw 'Exception: bang' "),
+ ]));
+ });
+}
diff --git a/test/test_utils.dart b/test/test_utils.dart
index a0dad48..574d257 100644
--- a/test/test_utils.dart
+++ b/test/test_utils.dart
@@ -36,11 +36,6 @@
int price;
}
-class HasPrice extends CustomMatcher {
- HasPrice(matcher) : super("Widget with a price that is", "price", matcher);
- featureValueOf(actual) => actual.price;
-}
-
class SimpleIterable extends Iterable<int> {
final int count;