-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from travisbrown/topics/updates-and-tests
Update versions and add some tests
- Loading branch information
Showing
6 changed files
with
58 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.catbird.util | ||
|
||
import algebra.laws.GroupLaws | ||
import cats.data.Xor | ||
import cats.laws.discipline.arbitrary._ | ||
import cats.std.int._ | ||
import cats.std.string._ | ||
import com.twitter.util.{ Return, Throw, Try } | ||
import io.catbird.test.bijection.BijectionProperties | ||
import io.catbird.test.util.ArbitraryInstances | ||
import org.scalatest.prop.{ Checkers, PropertyChecks } | ||
import org.scalatest.{ FunSuite, PropSpec } | ||
import org.typelevel.discipline.scalatest.Discipline | ||
|
||
trait TryTest extends ArbitraryInstances with TryConversions with TryInstances | ||
|
||
class TrySuite extends FunSuite with TryTest with Discipline { | ||
checkAll("Try[Int]", GroupLaws[Try[Int]].semigroup(trySemigroup[Int])) | ||
checkAll("Try[Int]", GroupLaws[Try[Int]].monoid) | ||
} | ||
|
||
class TrySpec extends PropSpec with PropertyChecks with Checkers | ||
with TryTest with BijectionProperties { | ||
check { | ||
isBijection[Try[String], Xor[Throwable, String]] | ||
} | ||
|
||
property("Equality for Try should use universal equality for Throw") { | ||
case class SomeError(message: String) extends Exception(message) | ||
|
||
forAll((s: String) => assert(tryEq[Int].eqv(Throw(SomeError(s)), Throw(SomeError(s))))) | ||
} | ||
|
||
property("Equality for Try should never mix up Return and Throw") { | ||
forAll((i: Int) => assert(!tryEq[Int].eqv(Throw(new Exception), Return(i)))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters