=htp add support infrastructure for folding over tuples with a binary poly-function

This commit is contained in:
Mathias 2014-10-14 17:25:32 +02:00
parent 416bb16aad
commit 129958d039
3 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http.server.util
import org.scalatest.{ Matchers, FreeSpec }
class TupleOpsSpec extends FreeSpec with Matchers {
import TupleOps._
"The TupleOps should" - {
"support folding over tuples using a binary poly-function" - {
"example 1" in {
object Funky extends Poly2 {
implicit def step1 = at[Double, Int](_ + _)
implicit def step2 = at[Double, Symbol]((d, s) (d + s.name.tail.toInt).toByte)
implicit def step3 = at[Byte, String]((byte, s) byte + s.toLong)
}
(1, 'X2, "3").foldLeft(0.0)(Funky) shouldEqual 6L
}
}
}
}