Created
August 18, 2015 15:30
-
-
Save dgouyette/3505f5851ff27036b7b9 to your computer and use it in GitHub Desktop.
Basic tests with shapeless
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._ | |
import shapeless._ | |
class ShapeLessSpec extends FlatSpec with ShouldMatchers { | |
object Add1 extends Poly1 { | |
implicit def caseInt = at[Int](x => x) | |
} | |
object Add2 extends Poly2 { | |
implicit def caseInt = at[Int, Int](_+_) | |
} | |
type IntPair = Int :: Int :: HNil | |
def sum(l: IntPair) = { | |
import Add1._ | |
import Add2._ | |
l.reduceLeft(Add1) | |
} | |
"Une manche 0 + 0" should " doit avoir un score de 0" in { | |
sum(0 :: 0 :: HNil) shouldEqual 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment