Skip to content

Commit

Permalink
Added bug to TODO list
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Jan 9, 2024
1 parent e6c5d14 commit 3f1693e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
39 changes: 39 additions & 0 deletions engine/src/test/java/experiments/Experiments.java
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);
}

}

26 changes: 26 additions & 0 deletions kotlin/src/main/kotlin/experiments/KotlinExperiments.kt
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)
}
}

}

0 comments on commit 3f1693e

Please sign in to comment.