-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jqwik-team/use-published-api
Use only published API from jqwik
- Loading branch information
Showing
53 changed files
with
261 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/net/jqwik/vavr/arbitraries/base/ListBasedArbitrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
60 changes: 0 additions & 60 deletions
60
src/main/java/net/jqwik/vavr/arbitraries/base/ListBasedVavrArbitrary.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.