Skip to content

Commit

Permalink
update rtsspec (zio#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuwalow authored and ghostdogpr committed Aug 19, 2019
1 parent d1db588 commit 21bb6f2
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions core-tests/jvm/src/test/scala/zio/RTSSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat
effect, bind, map $testSyncEvalLoopEffect
effect, bind, map, redeem $testSyncEvalLoopEffectThrow
sync effect $testEvalOfSyncEffect
sync on defer $testManualSyncOnDefer
deep effects $testEvalOfDeepSyncEffect
flip must make error into value $testFlipError
flip must make value into error $testFlipValue
Expand All @@ -56,7 +55,7 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat
run swallows inner interruption $testRunSwallowsInnerInterrupt
timeout a long computation $testTimeoutOfLongComputation
catchAllCause $testCatchAllCause
exception in fromFuture does not kill fiber $testFromFutureDoesNotKillFiber
exception in fromFuture does not kill fiber $testFromFutureDoesNotKillFiber

RTS finalizers
fail ensuring $testEvalOfFailEnsuring
Expand Down Expand Up @@ -127,9 +126,8 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat
RTS regression tests
deadlock regression 1 $testDeadlockRegression
check interruption regression 1 $testInterruptionRegression1
manual sync interruption $testManualSyncInterruption
max yield Ops 1 $testOneMaxYield

RTS option tests
lifting a value to an option $testLiftingOptionalValue
using the none value $testLiftingNoneValue
Expand Down Expand Up @@ -273,20 +271,6 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat
unsafeRun(sumIo(1000)) must_=== sum(1000)
}

def testManualSyncOnDefer = {
def sync[A](effect: => A): IO[Throwable, A] =
IO.effectTotal(effect)
.foldCauseM({
case Cause.Die(t) => IO.fail(t)
case cause => IO.halt(cause)
}, IO.succeed(_))

def putStrLn(text: String): IO[Throwable, Unit] =
sync(println(text))

unsafeRun(putStrLn("Hello")) must_=== (())
}

@silent
def testEvalOfRedeemOfSyncEffectError =
unsafeRun(
Expand Down Expand Up @@ -1033,7 +1017,6 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat
ref <- Ref.make[List[Fiber[_, _]]](Nil) // To make strong ref
_ <- forkAwaitStart(forkAwaitStart(forkAwaitStart(IO.succeed(()), ref), ref), ref)
fibs <- ZIO.children
_ <- ref.get.map(list => println(list.mkString(", ")))
} yield fibs must have size 1).supervised
)
}
Expand Down Expand Up @@ -1354,25 +1337,6 @@ class RTSSpec(implicit ee: ExecutionEnv) extends TestRuntime with org.specs2.mat

}

def testManualSyncInterruption = {
def sync[A](effect: => A): IO[Throwable, A] =
IO.effectTotal(effect)
.foldCauseM({
case Cause.Die(t) => IO.fail(t)
case cause => IO.halt(cause)
}, IO.succeed(_))

def putStr(text: String): IO[Throwable, Unit] =
sync(scala.io.StdIn.print(text))

unsafeRun(
for {
fiber <- putStr(".").forever.fork
_ <- fiber.interrupt
} yield true
)
}

def testOneMaxYield = {
val rts = new DefaultRuntime {
override val Platform = PlatformLive.Default.withExecutor(PlatformLive.ExecutorUtil.makeDefault(1))
Expand Down

0 comments on commit 21bb6f2

Please sign in to comment.