checks: move reusable test logic to shared lib
diff --git a/pkgs/checks/test/extensions/core_test.dart b/pkgs/checks/test/extensions/core_test.dart
index ac5222e..47096b3 100644
--- a/pkgs/checks/test/extensions/core_test.dart
+++ b/pkgs/checks/test/extensions/core_test.dart
@@ -6,6 +6,8 @@
import 'package:checks/context.dart';
import 'package:test/scaffolding.dart';
+import '../test_shared.dart';
+
void main() {
group('TypeChecks', () {
test('isA', () {
@@ -140,24 +142,3 @@
});
});
}
-
-extension on Check<Iterable<String>?> {
- // TODO: remove this once we have a deepEquals or equivalent
- void toStringEquals(List<String>? other) {
- final otherToString = other.toString();
- context.expect(() => ['toString equals'], (actual) {
- final actualToString = actual.toString();
- return actual.toString() == otherToString
- ? null
- : Rejection(actual: actualToString);
- });
- }
-}
-
-extension on Check<Rejection?> {
- void isARejection({List<String>? which, required String actual}) {
- this.isNotNull()
- ..has((p0) => p0.actual, 'actual').equals(actual)
- ..has((p0) => p0.which, 'which').toStringEquals(which);
- }
-}
diff --git a/pkgs/checks/test/test_shared.dart b/pkgs/checks/test/test_shared.dart
new file mode 100644
index 0000000..4ad7ef8
--- /dev/null
+++ b/pkgs/checks/test/test_shared.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2022, 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:checks/checks.dart';
+import 'package:checks/context.dart';
+
+extension TestIterableCheck on Check<Iterable<String>?> {
+ // TODO: remove this once we have a deepEquals or equivalent
+ void toStringEquals(List<String>? other) {
+ final otherToString = other.toString();
+ context.expect(() => ['toString equals'], (actual) {
+ final actualToString = actual.toString();
+ return actual.toString() == otherToString
+ ? null
+ : Rejection(actual: actualToString);
+ });
+ }
+}
+
+extension RejectionCheck on Check<Rejection?> {
+ void isARejection({List<String>? which, required String actual}) {
+ this.isNotNull()
+ ..has((p0) => p0.actual, 'actual').equals(actual)
+ ..has((p0) => p0.which, 'which').toStringEquals(which);
+ }
+}