Skip to content

Commit 7f46d9d

Browse files
committed
Rename Coarbitrary to Cogen
1 parent d011bf1 commit 7f46d9d

9 files changed

Lines changed: 1280 additions & 1284 deletions

File tree

demo/src/main/java/fj/demo/test/ListFunctorLaws.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import fj.function.Effect1;
1616
import fj.test.CheckResult;
1717
import static fj.test.CheckResult.summary;
18-
import static fj.test.Coarbitrary.coarbInteger;
19-
import static fj.test.Coarbitrary.coarbLong;
18+
import static fj.test.Cogen.cogenInteger;
19+
import static fj.test.Cogen.cogenLong;
2020
import fj.test.Property;
2121
import static fj.test.Property.prop;
2222
import static fj.test.Property.property;
@@ -42,7 +42,7 @@ For any list, mapping the identity function (\x -> x) produces the same list.
4242
public final class ListFunctorLaws {
4343
final Property identity = property(arbList(arbString), x -> prop(listEqual(stringEqual).eq(x, x.map(Function.identity()))));
4444

45-
final Property composition = property(arbF(coarbInteger, arbString), arbF(coarbLong, arbInteger), arbList(arbLong), (f, g, x) -> {
45+
final Property composition = property(arbF(cogenInteger, arbString), arbF(cogenLong, arbInteger), arbList(arbLong), (f, g, x) -> {
4646
final List<String> s1 = x.map(compose(f, g));
4747
final List<String> s2 = x.map(g).map(f);
4848
return prop(listEqual(stringEqual).eq(s1, s2));

props-core/src/test/java/fj/data/ReaderTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import static fj.F1Functions.bind;
99
import static fj.F1Functions.map;
1010
import static fj.test.Arbitrary.*;
11-
import static fj.test.Coarbitrary.coarbInteger;
11+
import static fj.test.Cogen.cogenInteger;
1212
import static fj.test.Property.prop;
1313
import static fj.test.Property.property;
1414
import static org.junit.Assert.assertTrue;
@@ -39,8 +39,8 @@ public void testFlatMap() {
3939
@Test
4040
public void testMapProp() {
4141
Property p = property(
42-
arbF(coarbInteger, arbInteger),
43-
arbF(coarbInteger, arbInteger),
42+
arbF(cogenInteger, arbInteger),
43+
arbF(cogenInteger, arbInteger),
4444
arbInteger,
4545
(f, g, i) -> {
4646
int expected = map(f, g).f(i);
@@ -52,9 +52,9 @@ public void testMapProp() {
5252

5353
@Test
5454
public void testFlatMapProp() {
55-
Gen<F<Integer, Reader<Integer, Integer>>> a = arbF(coarbInteger, arbReader());
55+
Gen<F<Integer, Reader<Integer, Integer>>> a = arbF(cogenInteger, arbReader());
5656
Property p = property(
57-
arbF(coarbInteger, arbInteger),
57+
arbF(cogenInteger, arbInteger),
5858
a,
5959
arbInteger,
6060
(f, g, i) -> {
@@ -72,7 +72,7 @@ public void testLeftIdentity() {
7272
Property p = Property.property(
7373
arbInteger,
7474
arbInteger,
75-
arbF(coarbInteger, arbReader()),
75+
arbF(cogenInteger, arbReader()),
7676
(i, j, f) -> {
7777
int a = Reader.<Integer, Integer>constant(i).flatMap(f).f(j);
7878
int b = f.f(i).f(j);
@@ -99,8 +99,8 @@ public void testAssociativity() {
9999
Property p = Property.property(
100100
arbInteger,
101101
arbReader(),
102-
arbF(coarbInteger, arbReader()),
103-
arbF(coarbInteger, arbReader()),
102+
arbF(cogenInteger, arbReader()),
103+
arbF(cogenInteger, arbReader()),
104104
(i, r, f, g) -> {
105105
boolean b2 = r.flatMap(f).flatMap(g).f(i) == r.flatMap(x -> f.f(x).flatMap(g)).f(i);
106106
return prop(b2);
@@ -109,7 +109,7 @@ public void testAssociativity() {
109109
}
110110

111111
public Gen<Reader<Integer, Integer>> arbReader() {
112-
return Arbitrary.arbReader(coarbInteger, arbInteger);
112+
return Arbitrary.arbReader(cogenInteger, arbInteger);
113113
}
114114

115115

props-core/src/test/java/fj/data/TestRngState.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import fj.*;
44
import fj.test.Arbitrary;
5-
import fj.test.Coarbitrary;
5+
import fj.test.Cogen;
66
import fj.test.Gen;
77
import fj.test.Property;
88
import org.junit.Assert;
@@ -12,7 +12,7 @@
1212
import static fj.data.Stream.unfold;
1313
import static fj.data.test.PropertyAssert.assertResult;
1414
import static fj.test.Arbitrary.*;
15-
import static fj.test.Coarbitrary.coarbInteger;
15+
import static fj.test.Cogen.cogenInteger;
1616
import static fj.test.Property.prop;
1717
import static fj.test.Property.property;
1818
import static fj.test.Variant.variant;
@@ -80,19 +80,19 @@ public void testTraverse() {
8080
}
8181

8282
public static Gen<State<LcgRng, Integer>> arbState() {
83-
return Arbitrary.arbState(Arbitrary.arbLcgRng(), Coarbitrary.coarbLcgRng(), arbInteger);
83+
return Arbitrary.arbState(Arbitrary.arbLcgRng(), Cogen.cogenLcgRng(), arbInteger);
8484
}
8585

8686
public static Gen<F<LcgRng, P2<LcgRng, Integer>>> arbStateF() {
87-
return arbF(Coarbitrary.coarbLcgRng(), arbP2(arbLcgRng(), arbInteger));
87+
return arbF(Cogen.cogenLcgRng(), arbP2(arbLcgRng(), arbInteger));
8888
}
8989

90-
public static Coarbitrary<State<LcgRng, Integer>> coarbState() {
91-
return Coarbitrary.coarbState(Arbitrary.arbLcgRng(), (LcgRng s, Integer j) -> (long) (j >= 0 ? 2 * j : -2 * j + 1));
90+
public static Cogen<State<LcgRng, Integer>> cogenState() {
91+
return Cogen.cogenState(Arbitrary.arbLcgRng(), (LcgRng s, Integer j) -> (long) (j >= 0 ? 2 * j : -2 * j + 1));
9292
}
9393

9494
public static Gen<F<Integer, State<LcgRng, Integer>>> arbBindable() {
95-
return arbF(coarbInteger, arbState());
95+
return arbF(cogenInteger, arbState());
9696
}
9797

9898
// Left identity: return i >>= f == f i

props-core/src/test/java/fj/data/WriterTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import static fj.data.test.PropertyAssert.assertResult;
1313
import static fj.test.Arbitrary.*;
14-
import static fj.test.Coarbitrary.coarbInteger;
14+
import static fj.test.Cogen.cogenInteger;
1515
import static fj.test.Property.prop;
1616
import static fj.test.Property.property;
1717
import static org.junit.Assert.assertTrue;
@@ -46,7 +46,7 @@ public void testTellProp() {
4646

4747
@Test
4848
public void testMap() {
49-
Property p = property(arbInteger, arbF(coarbInteger, arbInteger), (i, f) -> {
49+
Property p = property(arbInteger, arbF(cogenInteger, arbInteger), (i, f) -> {
5050
boolean b = eq.eq(defaultWriter.f(i).map(f), defaultWriter.f(f.f(i)));
5151
return prop(b);
5252
});
@@ -55,7 +55,7 @@ public void testMap() {
5555

5656
@Test
5757
public void testFlatMap() {
58-
Property p = property(arbInteger,arbF(coarbInteger, arbWriterStringInt()), (i, f) -> {
58+
Property p = property(arbInteger,arbF(cogenInteger, arbWriterStringInt()), (i, f) -> {
5959
boolean b = eq.eq(Writer.<Integer>stringLogger().f(i).flatMap(f), f.f(i));
6060
return prop(b);
6161
});
@@ -76,7 +76,7 @@ public <A> Gen<Writer<String, A>> arbWriterString(Gen<A> arb) {
7676
public void testLeftIdentity() {
7777
Property p = Property.property(
7878
arbInteger,
79-
arbF(coarbInteger, arbWriterStringInt()),
79+
arbF(cogenInteger, arbWriterStringInt()),
8080
(i, f) -> {
8181
return prop(eq.eq(defaultWriter.f(i).flatMap(f), f.f(i)));
8282
});
@@ -98,8 +98,8 @@ public void testRightIdentity() {
9898
public void testAssociativity() {
9999
Property p = Property.property(
100100
arbWriterStringInt(),
101-
arbF(coarbInteger, arbWriterStringInt()),
102-
arbF(coarbInteger, arbWriterStringInt()),
101+
arbF(cogenInteger, arbWriterStringInt()),
102+
arbF(cogenInteger, arbWriterStringInt()),
103103
(w, f, g) -> {
104104
boolean t = eq.eq(w.flatMap(f).flatMap(g), w.flatMap(x -> f.f(x).flatMap(g)));
105105
return prop(t);

0 commit comments

Comments
 (0)