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

org.specs2.mock.mockito.EqualsFunction0.scala Maven / Gradle / Ivy

There is a newer version: 3.7
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.matchers


/**
 * Ad-hoc implementation of the Equals matcher overriding the matching for byname values
 */
case class EqualsFunction0(wanted: scala.Any) extends Equals(wanted) {

  override def matches(actual: scala.Any) = {
    val value =
      if (actual.isInstanceOf[Function0[_]])
        try { actual.asInstanceOf[Function0[_]].apply() } catch { case e: Throwable => e }
      else
        actual

    Equality.areEqual(super.getWanted, value)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy