pTest<T> function
Implementation
@isTest
void pTest<T>(
String description, {
int? runCount,
Predicate<T>? skipIf,
required Generator<T> generateInput,
required Body<T> body,
}) async {
final inputs = Iterable.generate(
runCount ?? 100,
(_) => generateInput(_deterministicRandom),
).iterator;
final doesPassFun = _doesPass(body);
test(description, () async {
while (inputs.moveNext()) {
final input = inputs.current;
final doesPass = skipIf == null
? await doesPassFun(input)
: (skipIf(input) || await doesPassFun(input));
if (!doesPass) {
stderr.writeln('Fails for input: $input');
await body(input);
}
}
});
}