All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalautils.LegacyTripleEquals.scala Maven / Gradle / Ivy

/*
 * Copyright 2001-2008 Artima, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scalautils

trait LegacyTripleEquals extends EqualityConstraints {

  implicit override def defaultEquality[A]: Equality[A] = new DefaultEquality[A]

  override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left)
  override def convertToCheckingEqualizer[T](left: T): CheckingEqualizer[T] = new CheckingEqualizer(left)

  implicit override def convertToLegacyEqualizer[T](left: T): LegacyEqualizer[T] = new LegacyEqualizer(left)
  override def convertToLegacyCheckingEqualizer[T](left: T): LegacyCheckingEqualizer[T] = new LegacyCheckingEqualizer(left)

  override def lowPriorityTypeCheckedEqualityConstraint[A, B](implicit equalityOfA: Equality[A], ev: A <:< B): EqualityConstraint[A, B] = new BasicEqualityConstraint[A, B](equalityOfA)
  override def typeCheckedEqualityConstraint[A, B](implicit equalityOfA: Equality[A], ev: B <:< A): EqualityConstraint[A, B] = new BasicEqualityConstraint[A, B](equalityOfA)

  override def lowPriorityConversionCheckedEqualityConstraint[A, B](implicit equalityOfB: Equality[B], cnv: A => B): EqualityConstraint[A, B] = new AToBEqualityConstraint[A, B](equalityOfB, cnv)
  override def conversionCheckedEqualityConstraint[A, B](implicit equalityOfA: Equality[A], cnv: B => A): EqualityConstraint[A, B] = new BToAEqualityConstraint[A, B](equalityOfA, cnv)

  /**
   * Implicit conversion from Any to Equalizer, used to enable
   * assertions with === comparisons.
   *
   * 

* For more information * on this mechanism, see the documentation for Equalizer. *

* *

* Because trait Suite mixes in Assertions, this implicit conversion will always be * available by default in ScalaTest Suites. This is the only implicit conversion that is in scope by default in every * ScalaTest Suite. Other implicit conversions offered by ScalaTest, such as those that support the matchers DSL * or invokePrivate, must be explicitly invited into your test code, either by mixing in a trait or importing the * members of its companion object. The reason ScalaTest requires you to invite in implicit conversions (with the exception of the * implicit conversion for === operator) is because if one of ScalaTest's implicit conversions clashes with an * implicit conversion used in the code you are trying to test, your program won't compile. Thus there is a chance that if you * are ever trying to use a library or test some code that also offers an implicit conversion involving a === operator, * you could run into the problem of a compiler error due to an ambiguous implicit conversion. If that happens, you can turn off * the implicit conversion offered by this convertToEqualizer method simply by overriding the method in your * Suite subclass, but not marking it as implicit: *

* *
   * // In your Suite subclass
   * override def convertToEqualizer(left: Any) = new Equalizer(left)
   * 
* * @param left the object whose type to convert to Equalizer. * @throws NullPointerException if left is null. */ // implicit override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left) } object LegacyTripleEquals extends LegacyTripleEquals




© 2015 - 2025 Weber Informatics LLC | Privacy Policy