Skip to content

Commit

Permalink
Effects working, not propagating failures
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Mar 15, 2023
1 parent 8b4b657 commit 140c521
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/scala/MainTest.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import org.scalatest.flatspec.AsyncFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalacheck._
import org.scalacheck.effect.PropF
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks

import scala.concurrent.Future

class MainTest extends AsyncFlatSpec with Matchers with ScalaCheckPropertyChecks {
behavior of "Main"

Expand All @@ -11,4 +14,16 @@ class MainTest extends AsyncFlatSpec with Matchers with ScalaCheckPropertyChecks
assert(i < 5) // intentional fail - we want to see how the failure is reported
}
}

it should "perform async computations" in {

PropF.forAllF(Gen.oneOf(0 until 10)) { i =>
Future {
assert(i < 5) // intentional fail - we want to see how the failure is reported
}.map(_ => ()) // forAllF supports Future[Unit] by default, so we need to throw away the Assertion value
}.check().map { r =>
assert(r.passed) // works, but does not propagate the test result
}
}

}

0 comments on commit 140c521

Please sign in to comment.