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 –
不知道如何......你能提供答案嗎? –