Skip to content

Commit

Permalink
Merge branch 'main' of /Users/jlink/Documents/projects/jqwik with con…
Browse files Browse the repository at this point in the history
…flicts.
  • Loading branch information
jlink committed Feb 20, 2024
1 parent ed6130c commit bb32eac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
42 changes: 15 additions & 27 deletions engine/src/test/java/experiments/Experiments.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
package experiments;

import java.util.concurrent.*;
import java.util.function.*;
import java.util.*;

import org.junit.jupiter.api.extension.*;

import net.jqwik.api.*;
import net.jqwik.api.arbitraries.*;
import net.jqwik.api.constraints.*;
import net.jqwik.api.providers.*;
import net.jqwik.api.lifecycle.*;

public class Experiments {
import static org.assertj.core.api.Assertions.*;

@Example
void integers() {
IntegerArbitrary integers = Arbitraries.integers().withDistribution(RandomDistribution.uniform());
class Experiments {

integers.sampleStream().limit(50).forEach(System.out::println);
@Property(tries= 10)
@AddLifecycleHook(ProvideString.class)
void test(String constant, @ForAll int i) {
if (i > 1000) fail("too big");
}
}

@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())
);
}
class ProvideString implements ResolveParameterHook {

@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);
@Override
public Optional<ParameterSupplier> resolve(ParameterResolutionContext parameterContext, LifecycleContext lifecycleContext) {
return Optional.of(ignore -> "constant");
}

}

1 change: 1 addition & 0 deletions kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlinxVersion}")
testImplementation project(path: ':web')

runtimeOnly(project(":engine"))

Expand Down

0 comments on commit bb32eac

Please sign in to comment.