net.jqwik.engine.properties.shrinking.PropertyShrinker Maven / Gradle / Ivy
package net.jqwik.engine.properties.shrinking;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.function.*;
import java.util.logging.*;
import org.junit.platform.engine.*;
import net.jqwik.api.*;
import net.jqwik.api.domains.*;
import net.jqwik.api.lifecycle.*;
import net.jqwik.engine.execution.lifecycle.*;
import net.jqwik.engine.properties.*;
import net.jqwik.engine.support.*;
public class PropertyShrinker {
private static final Logger LOG = Logger.getLogger(PropertyShrinker.class.getName());
private final FalsifiedSample originalSample;
private final ShrinkingMode shrinkingMode;
private final int boundedShrinkingSeconds;
private final Consumer falsifiedSampleReporter;
private final Method targetMethod;
private final AtomicInteger shrinkingStepsCounter = new AtomicInteger(0);
private final List shrinkingSequence = new LinkedList<>();
private Optional currentBest = Optional.empty();
private volatile boolean shrinkingInterrupted = false;
public PropertyShrinker(
FalsifiedSample originalSample,
ShrinkingMode shrinkingMode,
int boundedShrinkingSeconds,
Consumer falsifiedSampleReporter,
Method targetMethod
) {
this.originalSample = originalSample;
this.shrinkingMode = shrinkingMode;
this.boundedShrinkingSeconds = boundedShrinkingSeconds;
this.falsifiedSampleReporter = falsifiedSampleReporter;
this.targetMethod = targetMethod;
}
public ShrunkFalsifiedSample shrink(Falsifier super List