Fix `which` arguments for new APIs since last merge
diff --git a/pkgs/checks/lib/src/extensions/core.dart b/pkgs/checks/lib/src/extensions/core.dart
index 61ca996..1f40b88 100644
--- a/pkgs/checks/lib/src/extensions/core.dart
+++ b/pkgs/checks/lib/src/extensions/core.dart
@@ -147,7 +147,7 @@
(actual) {
if (actual.compareTo(other) > 0) return null;
return Rejection(
- which: prefixFirst('is not greater than ', literal(other)));
+ which: () => prefixFirst('is not greater than ', literal(other)));
});
}
@@ -158,7 +158,7 @@
(actual) {
if (actual.compareTo(other) >= 0) return null;
return Rejection(
- which:
+ which: () =>
prefixFirst('is not greater than or equal to ', literal(other)));
});
}
@@ -168,7 +168,8 @@
context.expect(() => prefixFirst('is less than ', literal(other)),
(actual) {
if (actual.compareTo(other) < 0) return null;
- return Rejection(which: prefixFirst('is not less than ', literal(other)));
+ return Rejection(
+ which: () => prefixFirst('is not less than ', literal(other)));
});
}
@@ -179,7 +180,8 @@
(actual) {
if (actual.compareTo(other) <= 0) return null;
return Rejection(
- which: prefixFirst('is not less than or equal to ', literal(other)));
+ which: () =>
+ prefixFirst('is not less than or equal to ', literal(other)));
});
}
}
diff --git a/pkgs/checks/lib/src/extensions/iterable.dart b/pkgs/checks/lib/src/extensions/iterable.dart
index 984db89..63bc75f 100644
--- a/pkgs/checks/lib/src/extensions/iterable.dart
+++ b/pkgs/checks/lib/src/extensions/iterable.dart
@@ -13,7 +13,7 @@
Subject<T> get first => context.nest(() => ['has first element'], (actual) {
final iterator = actual.iterator;
if (!iterator.moveNext()) {
- return Extracted.rejection(which: ['has no elements']);
+ return Extracted.rejection(which: () => ['has no elements']);
}
return Extracted.value(iterator.current);
});
@@ -21,7 +21,7 @@
Subject<T> get last => context.nest(() => ['has last element'], (actual) {
final iterator = actual.iterator;
if (!iterator.moveNext()) {
- return Extracted.rejection(which: ['has no elements']);
+ return Extracted.rejection(which: () => ['has no elements']);
}
var current = iterator.current;
while (iterator.moveNext()) {
@@ -33,11 +33,12 @@
Subject<T> get single => context.nest(() => ['has single element'], (actual) {
final iterator = actual.iterator;
if (!iterator.moveNext()) {
- return Extracted.rejection(which: ['has no elements']);
+ return Extracted.rejection(which: () => ['has no elements']);
}
final value = iterator.current;
if (iterator.moveNext()) {
- return Extracted.rejection(which: ['has more than one element']);
+ return Extracted.rejection(
+ which: () => ['has more than one element']);
}
return Extracted.value(value);
});
diff --git a/pkgs/checks/test/context_test.dart b/pkgs/checks/test/context_test.dart
index 3fd92ac..2fccf96 100644
--- a/pkgs/checks/test/context_test.dart
+++ b/pkgs/checks/test/context_test.dart
@@ -112,7 +112,7 @@
check(null).context.expectUnawaited(() => [''], (actual, reject) {
final completer = Completer<void>()
..future.then((_) {
- reject(Rejection(which: ['foo']));
+ reject(Rejection(which: () => ['foo']));
});
callback = completer.complete;
});
@@ -165,11 +165,13 @@
onError.context.expectUnawaited(() => ['emits no further errors'],
(actual, reject) async {
await for (var error in actual.rest) {
- reject(Rejection(which: [
- ...prefixFirst('threw late error', literal(error.error)),
- ...(const LineSplitter().convert(
- TestHandle.current.formatStackTrace(error.stackTrace).toString()))
- ]));
+ reject(Rejection(
+ which: () => [
+ ...prefixFirst('threw late error', literal(error.error)),
+ ...(const LineSplitter().convert(TestHandle.current
+ .formatStackTrace(error.stackTrace)
+ .toString()))
+ ]));
}
});
}