Package

cats.effect.laws

util

Permalink

package util

Visibility
  1. Public
  2. All

Type Members

  1. final class TestContext extends ExecutionContext

    Permalink

    A scala.concurrent.ExecutionContext implementation that can be used for testing purposes.

    A scala.concurrent.ExecutionContext implementation that can be used for testing purposes.

    Usage:

    implicit val ec = TestContext()
    
    ec.execute(new Runnable { def run() = println("task1") })
    
    ex.execute(new Runnable {
      def run() = {
        println("outer")
    
        ec.execute(new Runnable {
          def run() = println("inner")
        })
      }
    })
    
    // Nothing executes until `tick` gets called
    ec.tick()
    
    // Testing the resulting state
    assert(ec.state.tasks.isEmpty)
    assert(ec.state.lastReportedFailure == None)
  2. trait TestInstances extends AnyRef

    Permalink

    Defines instances for Future and for IO, meant for law testing by means of TestContext.

    Defines instances for Future and for IO, meant for law testing by means of TestContext.

    The TestContext interpreter is used here for simulating asynchronous execution.

Value Members

  1. object TestContext

    Permalink
  2. object TestInstances extends TestInstances

    Permalink

Ungrouped