class
LegacyEqualizer
[L]
extends AnyRef
Instance Constructors
-
new
LegacyEqualizer
(left: L)
Value Members
-
def
!=
(arg0: AnyRef): Boolean
-
def
!=
(arg0: Any): Boolean
-
def
!==
(interval: Interval[L]): Option[String]
-
def
!==
(right: Any)(implicit equality: Equality[L]): Option[String]
-
def
##
(): Int
-
def
==
(arg0: AnyRef): Boolean
-
def
==
(arg0: Any): Boolean
-
def
===
(interval: Interval[L]): Option[String]
-
def
===
(right: Any)(implicit equality: Equality[L]): Option[String]
-
def
asInstanceOf
[T0]
: T0
-
def
clone
(): AnyRef
-
def
eq
(arg0: AnyRef): Boolean
-
def
equals
(arg0: Any): Boolean
-
def
finalize
(): Unit
-
def
getClass
(): java.lang.Class[_]
-
def
getObjectsForFailureMessage
(a: Any, b: Any): (Any, Any)
-
def
hashCode
(): Int
-
def
isInstanceOf
[T0]
: Boolean
-
def
ne
(arg0: AnyRef): Boolean
-
def
notify
(): Unit
-
def
notifyAll
(): Unit
-
def
synchronized
[T0]
(arg0: ⇒ T0): T0
-
def
toString
(): String
-
def
wait
(): Unit
-
def
wait
(arg0: Long, arg1: Int): Unit
-
def
wait
(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
Class used via an implicit conversion to enable any two objects to be compared with
===
in assertions in tests. For example:The benefit of using
assert(a === b)
rather thanassert(a == b)
is that aTestFailedException
produced by the former will include the values ofa
andb
in its detail message. The implicit method that performs the conversion fromAny
toEqualizer
isconvertToEqualizer
in traitAssertions
.In case you're not familiar with how implicit conversions work in Scala, here's a quick explanation. The
convertToEqualizer
method inAssertions
is defined as an "implicit" method that takes anAny
, which means you can pass in any object, and it will convert it to anEqualizer
. TheEqualizer
has===
defined. Most objects don't have===
defined as a method on them. Take two Strings, for example:Given this code, the Scala compiler looks for an
===
method on classString
, because that's the class of"hello"
.String
doesn't define===
, so the compiler looks for an implicit conversion fromString
to something that does have an===
method, and it finds theconvertToEqualizer
method. It then rewrites the code to this:So inside a
Suite
(which mixes inAssertions
,===
will work on anything. The only situation in which the implicit conversion wouldn't happen is on types that have an===
method already defined.The primary constructor takes one object,
left
, whose type is being converted toEqualizer
. Theleft
value may be anull
reference, because this is allowed by Scala's==
operator.