Skip to content

Instantly share code, notes, and snippets.

@dgouyette
Created August 18, 2015 15:30
Show Gist options
  • Save dgouyette/3505f5851ff27036b7b9 to your computer and use it in GitHub Desktop.
Save dgouyette/3505f5851ff27036b7b9 to your computer and use it in GitHub Desktop.
Basic tests with shapeless
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