Last active
November 26, 2015 14:36
-
-
Save ghik/9f7a71a745a1c492a0a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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