0
私は(彼らは一番下にある例えばfixture1
など、今のところ、いくつかの依存関係を無視して)次の関数を使用して、私のテストを定義したいと思います:Scalaで関数の引数を連鎖させるには?
multiTest("my test name", fixture1) { case (x: Double, y: Int, z: String) =>
// test body
}
とmultiTest
のように私のベースのカスタムFunSpecLike
サブクラスで定義されています
def multiTest(testName: String, fixture: FixtureTable)(fun: => Unit)(implicit pos: source.Position): Unit = {
val heading = fixture.heading
fixture.values.foreach { tuple =>
it(autoGenerateDesc(heading, tuple)) {
fun tuple // <<<<<< how can I pass the tuple to the definition above?
}
}
}
どのようにタプルを関数にプッシュできますか?
欠けている部分の一部が
は以下のとおりです。case class FixtureTable(heading: Map[String, String], values: Seq[Any])
// tableFor generates the permutations of all paramater values
val fixture1 : FixtureTable = tableFor(
("x", List(1e-1, 1e-2)),
("y", List(1, 2, 3)),
("z", List("a", "b")))
これはあなたの質問に答えますか? http://stackoverflow.com/questions/1987820/how-to-apply-a-function-to-a-tuple –
どのように答えが得られますか。 –