Skip to content

Instantly share code, notes, and snippets.

@ghik
Last active November 26, 2015 14:36
Show Gist options
  • Select an option

  • Save ghik/9f7a71a745a1c492a0a4 to your computer and use it in GitHub Desktop.

Select an option

Save ghik/9f7a71a745a1c492a0a4 to your computer and use it in GitHub Desktop.
import org.scalatest.FunSuite
import scala.language.higherKinds
/**
* Author: ghik
* Created: 26/11/15.
*/
class DelegationTest extends FunSuite {
trait Destination[T] {
val te: T
def simple(omg: Int): String
def meth[C[+X] >: Null <: Traversable[X]](map: Map[T, C[String]]): C[(T, String)]
}
class Source {
val te: Double = 3.14
def simple(omg: Int): String = omg.toString
def meth[C[+X] >: Null <: Traversable[X]](map: Map[Double, C[String]]): C[(Double, String)] = null
}
test("simple test") {
val source = new Source
val destination = Delegation[Destination[Double]](source)
assert(source.te == destination.te)
assert(source.simple(42) == destination.simple(42))
assert(source.meth[List](Map.empty) == destination.meth[List](Map.empty))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment