From 3f1693ead7f38cfda80a774574017823af9dd13d Mon Sep 17 00:00:00 2001 From: Johannes Link Date: Tue, 9 Jan 2024 08:27:12 +0100 Subject: [PATCH] Added bug to TODO list --- .../test/java/experiments/Experiments.java | 39 +++++++++++++++++++ .../kotlin/experiments/KotlinExperiments.kt | 26 +++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 engine/src/test/java/experiments/Experiments.java create mode 100644 kotlin/src/main/kotlin/experiments/KotlinExperiments.kt diff --git a/engine/src/test/java/experiments/Experiments.java b/engine/src/test/java/experiments/Experiments.java new file mode 100644 index 000000000..88d97e29d --- /dev/null +++ b/engine/src/test/java/experiments/Experiments.java @@ -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>> 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> pair) throws Exception { + String name = pair.get1(); + // String service = pair.get2().get().toString(); + System.out.println("Name: " + name); + // System.out.println("Service: " + service); + } + +} + diff --git a/kotlin/src/main/kotlin/experiments/KotlinExperiments.kt b/kotlin/src/main/kotlin/experiments/KotlinExperiments.kt new file mode 100644 index 000000000..203dd1e45 --- /dev/null +++ b/kotlin/src/main/kotlin/experiments/KotlinExperiments.kt @@ -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) { + println(tuple) + } + + @Provide + fun combinesOneToThree() = combine { + val v1 by Int.any() + val v2 by Int.any() + + filter { v1 == v2 } + + combineAs { + Tuple.of(v1, v2) + } + } + +} \ No newline at end of file