Skip to content

Commit

Permalink
Merge pull request #14 from jqwik-team/use-published-api
Browse files Browse the repository at this point in the history
Use only published API from jqwik
  • Loading branch information
Befrish authored Mar 11, 2023
2 parents 2559922 + 191770f commit d4d3f3e
Show file tree
Hide file tree
Showing 53 changed files with 261 additions and 522 deletions.
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ static isSnapshotRelease(versionString) {

ext {
moduleName = 'net.jqwik.vavr'
jqwikVavrVersion = '2.0.0'
jqwikVavrVersion = '2.1.0-SNAPSHOT'
jqwikVersion = '1.6.5'
junitPlatformVersion = '1.8.2'
vavrVersion = '0.10.4'
junitJupiterVersion = '5.8.2'
hamcrestVersion = '2.2'
isSnapshotRelease = isSnapshotRelease(jqwikVavrVersion)
}
Expand All @@ -34,13 +34,15 @@ version = jqwikVavrVersion
description = "Jqwik Vavr support module"

dependencies {
api("net.jqwik:jqwik:${jqwikVersion}")
api("net.jqwik:jqwik-api:${jqwikVersion}")

implementation("net.jqwik:jqwik-engine:${jqwikVersion}")
implementation("io.vavr:vavr:${vavrVersion}")

testImplementation("org.junit.jupiter:junit-jupiter:${junitJupiterVersion}")
testImplementation("org.hamcrest:hamcrest:${hamcrestVersion}")
testRuntimeOnly("net.jqwik:jqwik-engine:${jqwikVersion}")

// Only needed to work around intelliJ bug with running all tests in package
testImplementation("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}")
}

jar {
Expand Down
18 changes: 6 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.jqwik</groupId>
<artifactId>jqwik-vavr</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<url>https://github.com/Befrish/jqwik-vavr</url>
Expand Down Expand Up @@ -43,15 +43,14 @@
<jqwik.version>1.6.5</jqwik.version>
<vavr.version>0.10.4</vavr.version>

<junit-jupiter.version>5.8.2</junit-jupiter.version>
<hamcrest.version>2.2</hamcrest.version>

<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>

<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
<spotbugs-maven-plugin.version>4.6.0.0</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.7.3.2</spotbugs-maven-plugin.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<checkstyle.version>8.45.1</checkstyle.version>
</properties>
Expand All @@ -65,23 +64,18 @@

<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<artifactId>jqwik-api</artifactId>
<version>${jqwik.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik-engine</artifactId>
<version>${jqwik.version}</version>
<scope>compile</scope>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/net/jqwik/vavr/SingletonShrinkable.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package net.jqwik.vavr.arbitraries;

import net.jqwik.engine.properties.arbitraries.EdgeCasesSupport;
import net.jqwik.vavr.arbitraries.base.SingleValueArbitrary;
import io.vavr.Lazy;
import net.jqwik.api.Arbitrary;
import net.jqwik.api.EdgeCases;

public class VavrLazyArbitrary<T> extends SingleValueArbitrary<T, Lazy<T>> implements Arbitrary<Lazy<T>> {

Expand All @@ -17,9 +15,4 @@ protected Lazy<T> mapValue(final T value) {
return Lazy.of(() -> value);
}

@Override
protected EdgeCases<Lazy<T>> edgeCases(final Arbitrary<T> innerArbitrary, final int maxEdgeCases) {
return EdgeCasesSupport.map(innerArbitrary.edgeCases(), this::mapValue);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import net.jqwik.api.Arbitraries;
import net.jqwik.api.Arbitrary;
import net.jqwik.api.EdgeCases;
import net.jqwik.api.RandomGenerator;
import net.jqwik.engine.properties.arbitraries.EdgeCasesSupport;
import net.jqwik.api.arbitraries.ArbitraryDecorator;

import java.util.Arrays;

public abstract class DoubleValueArbitrary<T1, T2, U> implements Arbitrary<U> {
public abstract class DoubleValueArbitrary<T1, T2, U> extends ArbitraryDecorator<U> implements Arbitrary<U> {

private final Arbitrary<T1> firstArbitrary;
private final Arbitrary<T2> secondArbitrary;
Expand All @@ -22,10 +18,8 @@ public DoubleValueArbitrary(final Arbitrary<T1> firstArbitrary, final Arbitrary<
protected abstract U mapSecondValue(T2 value);

@Override
public RandomGenerator<U> generator(final int genSize) {
return Arbitraries.of(true, false)
.generator(genSize)
.flatMap(this::getMappedArbitrary, genSize, false);
protected Arbitrary<U> arbitrary() {
return Arbitraries.of(true, false).flatMap(this::getMappedArbitrary);
}

private Arbitrary<U> getMappedArbitrary(final Boolean firstValue) {
Expand All @@ -34,11 +28,4 @@ private Arbitrary<U> getMappedArbitrary(final Boolean firstValue) {
: this.secondArbitrary.map(this::mapSecondValue);
}

@Override
public EdgeCases<U> edgeCases(final int maxEdgeCases) {
final EdgeCases<U> firstEdgeCases = EdgeCasesSupport.map(this.firstArbitrary.edgeCases(), this::mapFirstValue);
final EdgeCases<U> secondEdgeCases = EdgeCasesSupport.map(this.secondArbitrary.edgeCases(), this::mapSecondValue);
return EdgeCasesSupport.concat(Arrays.asList(firstEdgeCases, secondEdgeCases), maxEdgeCases);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package net.jqwik.vavr.arbitraries.base;

import io.vavr.collection.Traversable;
import net.jqwik.api.Arbitrary;
import net.jqwik.api.arbitraries.StreamableArbitrary;
import net.jqwik.api.arbitraries.ArbitraryDecorator;
import net.jqwik.api.arbitraries.ListArbitrary;
import net.jqwik.api.RandomDistribution;

import java.util.function.BiFunction;
import java.util.function.Function;

public abstract class ListBasedArbitrary<T, U extends Traversable<T>> extends ArbitraryDecorator<U>
implements StreamableArbitrary<T,U> {

private ListArbitrary<T> listArbitrary;

public ListBasedArbitrary(final Arbitrary<T> elementArbitrary) {
this.listArbitrary = elementArbitrary.list();
}

protected abstract U convertJavaListToVavrCollection(java.util.List<T> javaList);

@Override
protected Arbitrary<U> arbitrary() {
return listArbitrary.map(this::convertJavaListToVavrCollection);
}

@Override
public ListBasedArbitrary<T, U> ofMinSize(final int minSize) {
final ListBasedArbitrary<T, U> clone = typedClone();
clone.listArbitrary = listArbitrary.ofMinSize(minSize);
return clone;
}

@Override
public ListBasedArbitrary<T, U> ofMaxSize(final int maxSize) {
final ListBasedArbitrary<T, U> clone = typedClone();
clone.listArbitrary = listArbitrary.ofMaxSize(maxSize);
return clone;
}

@Override
public ListBasedArbitrary<T, U> withSizeDistribution(final RandomDistribution distribution) {
final ListBasedArbitrary<T, U> clone = typedClone();
clone.listArbitrary = listArbitrary.withSizeDistribution(distribution);
return clone;
}

@Override
public <R> Arbitrary<R> reduce(final R initial, final BiFunction<R, T, R> accumulator) {
return listArbitrary.reduce(initial, accumulator);
}

public ListBasedArbitrary<T, U> uniqueElements(final Function<T, Object> by) {
final ListBasedArbitrary<T, U> clone = typedClone();
clone.listArbitrary = listArbitrary.uniqueElements(by);
return clone;
}

}

This file was deleted.

Loading

0 comments on commit d4d3f3e

Please sign in to comment.