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 ZLawsF2
    Definition Classes
    laws
  • object Divariant
    Definition Classes
    ZLawsF2
  • ComposeLaw
  • Law1

abstract class Law1[-CapsBothF[_[-_, +_]], -CapsLeft[_], -CapsRight[_]] extends Divariant[CapsBothF, CapsLeft, CapsRight, Any]

Constructs a law from a pure function taking a single parameter.

Self Type
Law1[CapsBothF, CapsLeft, CapsRight]
Linear Supertypes
Divariant[CapsBothF, CapsLeft, CapsRight, Any], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Law1
  2. Divariant
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Law1(label: String)

Abstract Value Members

  1. abstract def apply[F[-_, +_], A, B](fa: F[A, B])(implicit arg0: CapsBothF[F], arg1: CapsLeft[A], arg2: CapsRight[B]): 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[-_, +_]] <: CapsBothF[x[_, _]], CapsLeft1[x] <: CapsLeft[x], CapsRight1[x] <: CapsRight[x], R1 <: Any](that: Divariant[CapsF1, CapsLeft1, CapsRight1, R1]): Divariant[CapsF1, CapsLeft1, CapsRight1, 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
    Divariant
  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, B](genF: GenF2[R, F], gen: Gen[R, B])(implicit arg0: CapsBothF[F], arg1: CapsLeft[A], arg2: CapsRight[B], 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,B] values given a generator of B values.

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

    Definition Classes
    Law1Divariant
  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 Divariant[CapsBothF, CapsLeft, CapsRight, Any]

Inherited from AnyRef

Inherited from Any

Ungrouped