-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package experiments; | ||
|
||
import java.util.concurrent.*; | ||
import java.util.function.*; | ||
|
||
import net.jqwik.api.*; | ||
import net.jqwik.api.arbitraries.*; | ||
import net.jqwik.api.constraints.*; | ||
import net.jqwik.api.providers.*; | ||
|
||
public class Experiments { | ||
|
||
@Example | ||
void integers() { | ||
IntegerArbitrary integers = Arbitraries.integers().withDistribution(RandomDistribution.uniform()); | ||
|
||
integers.sampleStream().limit(50).forEach(System.out::println); | ||
} | ||
|
||
@Provide | ||
Arbitrary<Tuple.Tuple2<String, Supplier<ExecutorService>>> services() { | ||
return Arbitraries.of( | ||
Tuple.of("newSingleThreadExecutor", () -> Executors.newSingleThreadExecutor()), | ||
Tuple.of("newFixedThreadPool", () -> Executors.newFixedThreadPool(2)), | ||
Tuple.of("newCachedThreadPool", () -> Executors.newCachedThreadPool()), | ||
Tuple.of("newVirtualThreadPerTaskExecutor", () -> Executors.newWorkStealingPool()) | ||
); | ||
} | ||
|
||
@Property | ||
void test(@ForAll("services") Tuple.Tuple2<String, Supplier<ExecutorService>> pair) throws Exception { | ||
String name = pair.get1(); | ||
// String service = pair.get2().get().toString(); | ||
System.out.println("Name: " + name); | ||
// System.out.println("Service: " + service); | ||
} | ||
|
||
} | ||
|
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,26 @@ | ||
package experiments | ||
|
||
import net.jqwik.api.* | ||
import net.jqwik.kotlin.api.any | ||
import net.jqwik.kotlin.api.combine | ||
|
||
class KotlinExperiments { | ||
|
||
@Property(tries = 1000, generation = GenerationMode.RANDOMIZED) | ||
fun `filter arbitraries`(@ForAll("combinesOneToThree") tuple: Tuple.Tuple2<Int, Int>) { | ||
println(tuple) | ||
} | ||
|
||
@Provide | ||
fun combinesOneToThree() = combine { | ||
val v1 by Int.any() | ||
val v2 by Int.any() | ||
|
||
filter { v1 == v2 } | ||
|
||
combineAs { | ||
Tuple.of(v1, v2) | ||
} | ||
} | ||
|
||
} |