net.jqwik.engine.properties.shrinking.OneAfterTheOtherParameterShrinker Maven / Gradle / Ivy
The newest version!
package net.jqwik.engine.properties.shrinking;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import net.jqwik.api.*;
import net.jqwik.api.lifecycle.*;
import org.jspecify.annotations.*;
class OneAfterTheOtherParameterShrinker extends AbstractSampleShrinker {
public OneAfterTheOtherParameterShrinker(Map, TryExecutionResult> falsificationCache) {
super(falsificationCache);
}
@Override
public FalsifiedSample shrink(
Falsifier> falsifier,
FalsifiedSample sample,
Consumer sampleShrunkConsumer,
Consumer shrinkAttemptConsumer
) {
FalsifiedSample current = sample;
for (int i = 0; i < sample.shrinkables().size(); i++) {
current = shrinkSingleParameter(falsifier, current, sampleShrunkConsumer, shrinkAttemptConsumer, i);
}
return current;
}
private FalsifiedSample shrinkSingleParameter(
Falsifier> falsifier,
FalsifiedSample sample,
Consumer sampleShrunkConsumer,
Consumer shrinkAttemptConsumer,
int parameterIndex
) {
Function>, Stream>>> shrinker =
shrinkables -> {
Shrinkable