Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package scalactic
    Definition Classes
    org
  • trait TripleEqualsSupport extends AnyRef

    Trait that defines abstract methods used to enforce compile-time type constraints for equality comparisons, and defines === and !== operators used by matchers.

    Trait that defines abstract methods used to enforce compile-time type constraints for equality comparisons, and defines === and !== operators used by matchers.

    The abstract methods of this trait are selectively implemented as implicit by subclasses to enable a spectrum of type constraints for the === and !== operators. As an illustration, if in the expression, a === b, the type of a is A and b is B, the following three levels of compile-time checking can be obtained from TripleEqualsSupport subtraits:

    Unchecked - A and B can be any two types. This constraint level is available from subtrait TripleEquals.

    Statically-checked - A must be a subtype of B, or vice versa, or must cooperate such that the equality laws stated in the equals contract are preserved. This (intermediate) constraint level is available by using subtrait TripleEquals and installing the SuperSafe Community Edition Scala compiler plugin.

    Type-checked - A must be a subtype of B, or vice versa. (Both A and B can be the same type, because a type is considered a subtype of itself.) This (strongest) constraint level is available from subtrait TypeCheckedTripleEquals.

    This trait defines all methods that need to be defined implicitly by the subtraits so that if multiple subtraits are used together, the inner-most subtrait in scope can not only enable the implicits it needs by overriding or hiding those methods (currently-in-scope as regular, non-implicit methods) and making them implicit, it can also disable any implicits enabled by its sibling subtraits in enclosing scopes. For example, if your test class mixes in TypeCheckedTripleEquals, inside your test class the following methods will be implicit:

    • convertToCheckingEqualizer
    • typeCheckedConstraint
    • lowPriorityTypeCheckedConstraint
    • convertEquivalenceToAToBConstraint
    • convertEquivalenceToBToAConstraint

    If in the body of a test you want to turn off the type checking, you can import the members of TripleEquals in the body of that test. This will not only hide non-implicit methods convertToEqualizer unconstrainedEquality of TypeCheckedTripleEquals, replacing those with implicit ones defined in TripleEquals, it will also hide the three methods made implicit in TypeCheckedTripleEquals (and listed above), replacing them by non-implicit ones.

    In short, you should be able to select a primary constraint level via either a mixin or import, then change that in nested scopes however you want, again either through a mixin or import, without getting any implicit conversion ambiguity. The innermost constraint level in scope will always be in force.

    Definition Classes
    scalactic
  • CheckingEqualizer
  • Equalizer

class CheckingEqualizer[L] extends AnyRef

Class used via an implicit conversion to enable two objects to be compared with === and !== with a Boolean result and an enforced type constraint between two object types. For example:

assert(a === b)
assert(c !== d)

You can also check numeric values against another with a tolerance. Here are some examples:

assert(a === (2.0 +- 0.1))
assert(c !== (2.0 +- 0.1))

Source
TripleEqualsSupport.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CheckingEqualizer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new CheckingEqualizer(leftSide: L)

    leftSide

    An object to convert to Equalizer, which represents the value on the left side of a === or !== invocation.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. def !==(spread: Spread[L]): Boolean

    Determine whether a numeric object is outside the passed Spread, returning a Boolean.

    Determine whether a numeric object is outside the passed Spread, returning a Boolean.

    spread

    the Spread against which to compare the value passed to the constructor as leftSide

    returns

    true if the value passed to the constructor as leftSide is not within the Spread passed to this method.

  3. def !==[R](rightSide: R)(implicit constraint: CanEqual[L, R]): Boolean

    Compare two objects for inequality, returning a Boolean, using the Constraint instance passed as constraint.

    Compare two objects for inequality, returning a Boolean, using the Constraint instance passed as constraint.

    rightSide

    the object to compare for inequality with leftSide, passed to the constructor

    constraint

    an implicit Constraint instance that enforces a relationship between types L and R and defines a way of calculating equality for objects of type L

    returns

    true if the leftSide and rightSide objects are not equal according to the passed Constraint instance.

  4. final def ##: Int
    Definition Classes
    AnyRef → Any
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def ===(spread: Spread[L]): Boolean

    Determine whether a numeric object is within the passed Spread, returning a Boolean.

    Determine whether a numeric object is within the passed Spread, returning a Boolean.

    spread

    the Spread against which to compare the value passed to the constructor as leftSide

    returns

    true if the value passed to the constructor as leftSide is not within the Spread passed to this method.

  7. def ===[R](rightSide: R)(implicit constraint: CanEqual[L, R]): Boolean

    Compare two objects for equality, returning a Boolean, using the Constraint instance passed as constraint.

    Compare two objects for equality, returning a Boolean, using the Constraint instance passed as constraint.

    rightSide

    the object to compare for equality with leftSide, passed to the constructor

    constraint

    an implicit Constraint instance that enforces a relationship between types L and R and defines a way of calculating equality for objects of type L

    returns

    true if the leftSide and rightSide objects are equal according to the passed Constraint instance.

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. val leftSide: L
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

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

Inherited from AnyRef

Inherited from Any

Ungrouped