Skip to content

Commit 1bcfaa1

Browse files
committed
Updated gradle versions plugin to 0.42.0. Added arb values for ParModule to help with upgrading Scala and Scalacheck
1 parent 1dd3b3e commit 1bcfaa1

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ buildscript {
1111
}
1212

1313
dependencies {
14-
classpath "com.github.ben-manes:gradle-versions-plugin:0.36.0"
14+
classpath "com.github.ben-manes:gradle-versions-plugin:0.42.0"
1515
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.1.0"
1616
}
1717

quickcheck/src/main/java/fj/test/Arbitrary.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import fj.P6;
2424
import fj.P7;
2525
import fj.P8;
26+
import fj.Unit;
27+
import fj.control.parallel.ParModule;
28+
import fj.control.parallel.Strategy;
2629
import fj.data.*;
2730
import fj.LcgRng;
2831
import fj.Ord;
@@ -65,9 +68,12 @@
6568
import java.util.concurrent.CopyOnWriteArraySet;
6669
import java.util.concurrent.DelayQueue;
6770
import java.util.concurrent.Delayed;
71+
import java.util.concurrent.ExecutorService;
72+
import java.util.concurrent.Executors;
6873
import java.util.concurrent.LinkedBlockingQueue;
6974
import java.util.concurrent.PriorityBlockingQueue;
7075
import java.util.concurrent.SynchronousQueue;
76+
import java.util.concurrent.ThreadFactory;
7177

7278
/**
7379
* Common Gen helper functions.
@@ -98,6 +104,24 @@ public static <S, A> Gen<State<S, A>> arbState(Gen<S> as, Cogen<S> cs, Gen<A> aa
98104
return arbF(cs, arbP2(as, aa)).map(State::unit);
99105
}
100106

107+
public static Gen<ParModule> arbParModule() {
108+
return Arbitrary.<Unit>arbStrategy().map(s -> ParModule.parModule(s));
109+
}
110+
111+
public static <A> Gen<Strategy<A>> arbStrategy() {
112+
Strategy<A> s = Strategy.<A>executorStrategy(fixedThreadsExecutorService(2));
113+
return Gen.elements(s);
114+
}
115+
116+
private static ExecutorService fixedThreadsExecutorService(int n) {
117+
return Executors.newFixedThreadPool(n, r -> {
118+
ThreadFactory tf = Executors.defaultThreadFactory();
119+
Thread t = tf.newThread(r);
120+
t.setDaemon(true);
121+
return t;
122+
});
123+
}
124+
101125
/**
102126
* An arbitrary for the LcgRng.
103127
*/

0 commit comments

Comments
 (0)