Skip to content

Commit

Permalink
Add align=none, maxColumn=120 and modifications'
Browse files Browse the repository at this point in the history
  • Loading branch information
easel committed Oct 1, 2018
1 parent ecedc87 commit 2cda6cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// default settings
align=none
maxColumn = 120
11 changes: 4 additions & 7 deletions js/src/main/scala/cats/js/instances/future.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object future extends FutureInstances0
object Await {
def result[A](f: Future[A], atMost: FiniteDuration): A = f.value match {
case Some(v) => v.get
case None => throw new IllegalStateException()
case None => throw new IllegalStateException()
}
}

Expand All @@ -25,21 +25,18 @@ private[instances] sealed trait FutureInstances0 extends FutureInstances1 {
Await.result(x, atMost)
}

def futureOrder[A: Order](atMost: FiniteDuration)(
implicit ec: E): Order[Future[A]] =
def futureOrder[A: Order](atMost: FiniteDuration)(implicit ec: E): Order[Future[A]] =
new Order[Future[A]] {
def compare(x: Future[A], y: Future[A]): Int =
Await.result((x zip y).map { case (x, y) => x compare y }, atMost)
}
}

private[instances] sealed trait FutureInstances1 extends FutureInstances2 {
def futurePartialOrder[A: PartialOrder](atMost: FiniteDuration)(
implicit ec: E): PartialOrder[Future[A]] =
def futurePartialOrder[A: PartialOrder](atMost: FiniteDuration)(implicit ec: E): PartialOrder[Future[A]] =
new PartialOrder[Future[A]] {
def partialCompare(x: Future[A], y: Future[A]): Double =
Await.result((x zip y).map { case (x, y) => x partialCompare y },
atMost)
Await.result((x zip y).map { case (x, y) => x partialCompare y }, atMost)
}

}
Expand Down
11 changes: 3 additions & 8 deletions js/src/test/scala/cats/tests/FutureTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package cats
package js
package tests

import cats.kernel.laws.discipline.{
MonoidTests => MonoidLawTests,
SemigroupTests => SemigroupLawTests
}
import cats.kernel.laws.discipline.{MonoidTests => MonoidLawTests, SemigroupTests => SemigroupLawTests}
import cats.laws.discipline._
import cats.js.instances.Await
import cats.js.instances.future.futureComonad
Expand Down Expand Up @@ -56,15 +53,13 @@ class FutureTests extends CatsSuite {
implicit def cogenForFuture[A]: Cogen[Future[A]] =
Cogen[Unit].contramap(_ => ())

checkAll("Future[Int]",
MonadErrorTests[Future, Throwable].monadError[Int, Int, Int])
checkAll("Future[Int]", MonadErrorTests[Future, Throwable].monadError[Int, Int, Int])
checkAll("Future[Int]", ComonadTests[Future].comonad[Int, Int, Int])
checkAll("Future", MonadTests[Future].monad[Int, Int, Int])

{
implicit val F = ListWrapper.semigroup[Int]
checkAll("Future[ListWrapper[Int]]",
SemigroupLawTests[Future[ListWrapper[Int]]].semigroup)
checkAll("Future[ListWrapper[Int]]", SemigroupLawTests[Future[ListWrapper[Int]]].semigroup)
}

checkAll("Future[Int]", MonoidLawTests[Future[Int]].monoid)
Expand Down
11 changes: 3 additions & 8 deletions jvm/src/test/scala/cats/tests/FutureSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package cats
package jvm
package tests

import cats.kernel.laws.discipline.{
MonoidTests => MonoidLawTests,
SemigroupTests => SemigroupLawTests
}
import cats.kernel.laws.discipline.{MonoidTests => MonoidLawTests, SemigroupTests => SemigroupLawTests}
import cats.laws.discipline._
import cats.laws.discipline.arbitrary._
import cats.tests.{CatsSuite, ListWrapper}
Expand Down Expand Up @@ -43,15 +40,13 @@ class FutureSuite extends CatsSuite {
implicit val nonFatalArbitrary: Arbitrary[Throwable] =
Arbitrary(arbitrary[Exception].map(identity))

checkAll("Future with Throwable",
MonadErrorTests[Future, Throwable].monadError[Int, Int, Int])
checkAll("Future with Throwable", MonadErrorTests[Future, Throwable].monadError[Int, Int, Int])
checkAll("Future", MonadTests[Future].monad[Int, Int, Int])
checkAll("Future", CoflatMapTests[Future].coflatMap[Int, Int, Int])

{
implicit val F = ListWrapper.semigroup[Int]
checkAll("Future[ListWrapper[Int]]",
SemigroupLawTests[Future[ListWrapper[Int]]].semigroup)
checkAll("Future[ListWrapper[Int]]", SemigroupLawTests[Future[ListWrapper[Int]]].semigroup)
}

checkAll("Future[Int]", MonoidLawTests[Future[Int]].monoid)
Expand Down

0 comments on commit 2cda6cd

Please sign in to comment.