Skip to content

Commit 0083d09

Browse files
committed
add BireducibleTests
1 parent 82be290 commit 0083d09

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2015 Typelevel
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
package cats
23+
package laws
24+
package discipline
25+
26+
import org.scalacheck.Arbitrary
27+
import org.scalacheck.Cogen
28+
import org.scalacheck.Prop._
29+
30+
import arbitrary._
31+
32+
trait BireducibleTests[F[_, _]] extends BifoldableTests[F] {
33+
def laws: BireducibleLaws[F]
34+
35+
def bireducible[
36+
A: Arbitrary: Cogen: Eq: Semigroup,
37+
B: Arbitrary: Cogen: Eq: Semigroup,
38+
C: Arbitrary: Cogen: Eq: Monoid
39+
](implicit arbF: Arbitrary[F[A, B]]): RuleSet =
40+
new DefaultRuleSet(
41+
"bireducible",
42+
Some(bifoldable[A, B, C]),
43+
"bireduceLeft consistent with default implementation" ->
44+
forAll(laws.bireduceLeftConsistentWithDefaultImplementation[A, B] _),
45+
"bireduceRight consistent with default implementation" ->
46+
forAll(laws.bireduceRightConsistentWithDefaultImplementation[A, B] _),
47+
"bireduceMap consistent with default implementation" ->
48+
forAll(laws.bireduceMapConsistentWithDefaultImplementation[A, B, C] _),
49+
"bireduce consistent with default implementation" ->
50+
forAll(laws.bireduceConsistentWithDefaultImplementation[A, B] _),
51+
"bireduceLeftTo consistent with bireduceRightTo" ->
52+
forAll(laws.bireduceLeftToConsistentWithBireduceRightTo[A, B, C] _)
53+
)
54+
}
55+
56+
object BireducibleTests {
57+
def apply[F[_, _]: Bireducible]: BireducibleTests[F] =
58+
new BireducibleTests[F] { def laws: BireducibleLaws[F] = BireducibleLaws[F] }
59+
}

0 commit comments

Comments
 (0)