Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kernel laws consistent with core laws #1922

Merged
merged 21 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait HashTests[A] extends EqLawTests[A] {
Some(eqv),
"hash compatibility" -> forAll(laws.hashCompatibility _),
"same as universal hash" -> forAll(laws.sameAsUniversalHash _),
"same as universal hash" -> forAll((x: A, y: A) => laws.sameAsScalaHashing(x, y, hashA))
"same as scala hashing" -> forAll((x: A, y: A) => laws.sameAsScalaHashing(x, y, hashA))
)

}
Expand Down
8 changes: 8 additions & 0 deletions tests/src/test/scala/cats/tests/FunctionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cats
package tests

import cats.arrow.{Choice, CommutativeArrow}
import cats.kernel.laws.HashLaws
import cats.kernel.laws.discipline.{SerializableTests, _}
import cats.laws.discipline._
import cats.laws.discipline.eq._
Expand Down Expand Up @@ -54,6 +55,13 @@ class FunctionTests extends CatsSuite {
checkAll("Function0[Grp]", GroupLawTests[Function0[Grp]].group)
checkAll("Function0[CGrp]", CommutativeGroupTests[Function0[CGrp]].commutativeGroup)

test("Function0[Hsh]") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious why not just test the hash law? won't pass?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why not just test the full HashLaw? won't pass?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not the same as universal hash and not the same as scala.util.Hashing

forAll { (x: Function0[Hsh], y: Function0[Hsh]) =>
HashLaws[Function0[Hsh]].hashCompatibility(x, y)
}
}


// serialization tests for the various Function0-related instances
checkAll("Eq[() => Eqed]", SerializableTests.serializable(Eq[() => Eqed]))
checkAll("PartialOrder[() => POrd]", SerializableTests.serializable(PartialOrder[() => POrd]))
Expand Down