Packages

  • package root
    Definition Classes
    root
  • package zio
    Definition Classes
    root
  • package test

    _ZIO Test_ is a featherweight testing library for effectful programs.

    _ZIO Test_ is a featherweight testing library for effectful programs.

    The library imagines every spec as an ordinary immutable value, providing tremendous potential for composition. Thanks to tight integration with ZIO, specs can use resources (including those requiring disposal), have well- defined linear and parallel semantics, and can benefit from a host of ZIO combinators.

    import zio.test._
    import zio.Clock.nanoTime
    
    object MyTest extends ZIOSpecDefault {
      def spec = suite("clock")(
        test("time is non-zero") {
          for {
            time <- Live.live(nanoTime)
          } yield assertTrue(time >= 0L)
        }
      )
    }
    Definition Classes
    zio
  • package laws

    The laws package provides functionality for describing laws as values.

    The laws package provides functionality for describing laws as values. The fundamental abstraction is a set of ZLaws[Caps, R]. These laws model the laws that instances having a capability of type Caps are expected to satisfy. A capability Caps[_] is an abstraction describing some functionality that is common across different data types and obeys certain laws. For example, we can model the capability of two values of a type being compared for equality as follows:

    trait Equal[-A] {
      def equal(a1: A, a2: A): Boolean
    }

    Definitions of equality are expected to obey certain laws:

    1. Reflexivity - a1 === a1
    2. Symmetry - a1 === a2 ==> a2 === a1
    3. Transitivity - (a1 === a2) && (a2 === a3) ==> (a1 === a3)

    These laws define what the capabilities mean and ensure that it is safe to abstract across different instances with the same capability.

    Using ZIO Test, we can represent these laws as values. To do so, we define each law using one of the ZLaws constructors. For example:

    val transitivityLaw = ZLaws.Laws3[Equal]("transitivityLaw") {
      def apply[A: Equal](a1: A, a2: A, a3: A): TestResult =
        ???
    }

    We can then combine laws using the + operator:

    val reflexivityLaw: = ???
    val symmetryLaw:    = ???
    
    val equalLaws = reflexivityLaw + symmetryLaw + transitivityLaw

    Laws have a run method that takes a generator of values of type A and checks that those values satisfy the laws. In addition, objects can extend ZLawful to provide an even more convenient syntax for users to check that instances satisfy certain laws.

    object Equal extends Lawful[Equal]
    
    object Hash extends Lawful[Hash]
    
    object Ord extends Lawful[Ord]
    
    checkAllLaws(Equal + Hash + Ord)(Gen.int)

    Note that capabilities compose seamlessly because of contravariance. We can combine laws describing different capabilities to construct a set of laws requiring that instances having all of the capabilities satisfy each of the laws.

    Definition Classes
    test
  • object ZLawsF

    ZLaws[CapsF, Caps, R] describes a set of laws that a parameterized type F[A] with capabilities CapsF is expected to satisfy with respect to all types A that have capabilities Caps.

    ZLaws[CapsF, Caps, R] describes a set of laws that a parameterized type F[A] with capabilities CapsF is expected to satisfy with respect to all types A that have capabilities Caps. Laws can be run by providing a GenF that is capable of generating F[A] values given a generator of A values and a generator of values of some type A. Laws can be combined using + to produce a set of laws that require both sets of laws to be satisfied.

    Definition Classes
    laws
  • object Contravariant
    Definition Classes
    ZLawsF
  • ComposeLaw
  • Law1
  • Law1ZIO
  • Law2
  • Law2ZIO
  • Law3
  • Law3ZIO

abstract class ComposeLaw[-CapsF[_[-_]], -Caps[_]] extends Contravariant[CapsF, Caps, Any]

Constructs a law from a pure function taking one parameterized value and two functions that can be composed.

Self Type
ComposeLaw[CapsF, Caps]
Linear Supertypes
Contravariant[CapsF, Caps, Any], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ComposeLaw
  2. Contravariant
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ComposeLaw(label: String)

Abstract Value Members

  1. abstract def apply[F[-_], A, B, C](fa: F[A], f: (B) => A, g: (C) => B)(implicit arg0: CapsF[F], arg1: Caps[A], arg2: Caps[B], arg3: Caps[C]): TestResult

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +[CapsF1[x[-_]] <: CapsF[x[_]], Caps1[x] <: Caps[x], R1 <: Any](that: Contravariant[CapsF1, Caps1, R1]): Contravariant[CapsF1, Caps1, R1]

    Combine these laws with the specified laws to produce a set of laws that require both sets of laws to be satisfied.

    Combine these laws with the specified laws to produce a set of laws that require both sets of laws to be satisfied.

    Definition Classes
    Contravariant
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def run[R, F[-_], A](genF: GenF[R, F], gen: Gen[R, A])(implicit arg0: CapsF[F], arg1: Caps[A], trace: Trace): URIO[R, TestResult]

    Test that values of type F[+_] satisfy the laws using the specified function to construct a generator of F[A] values given a generator of A values.

    Test that values of type F[+_] satisfy the laws using the specified function to construct a generator of F[A] values given a generator of A values.

    Definition Classes
    ComposeLawContravariant
  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Contravariant[CapsF, Caps, Any]

Inherited from AnyRef

Inherited from Any

Ungrouped