Sha256: f094e60f88890dbec78519a8a7f9cea65c41b0b9e8df90001cfa0e8b251c2d7c

Contents?: true

Size: 1.38 KB

Versions: 71

Compression:

Stored size: 1.38 KB

Contents

import testgen._
import TestSuiteBuilder.{toString, _}
import java.io.File

object FoodChainTestGenerator {
  def sutArgsFromInput(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String = {
    val input = parseResult("input").asInstanceOf[Map[String, Int]]

    val firstParam = input("startVerse").toString
    val secondParam = input("endVerse").toString

    firstParam + ", " + secondParam
  }

  def main(args: Array[String]): Unit = {
    val file = new File("src/main/resources/food-chain.json")

    val RawQuote = "\"\"\""
    def asRawString(str: String): String = s"$RawQuote$str$RawQuote"

    def fromLabeledTestFromInput(argNames: String*)(
      implicit sutFunction: LabeledTest => String = _.property): ToTestCaseData =
      withLabeledTest { sut =>
        labeledTest =>
          val sutFunction = labeledTest.property
          val args = sutArgsFromInput(labeledTest.result, argNames: _*)
          val sutCall = s"$sut.$sutFunction(${args})"
          val expectedLines = labeledTest.expected.right.get.asInstanceOf[List[String]]
          val expected = expectedLines mkString ("", "\n", "\n\n")

          TestCaseData(labeledTest.description, sutCall, asRawString(expected))
      }

    val code = TestSuiteBuilder.build(file,
      fromLabeledTestFromInput("startVerse", "endVerse"))
    println(s"-------------")
    println(code)
    println(s"-------------")
  }
}

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.179 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.178 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.177 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.176 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.175 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.174 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.173 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.172 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.171 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.170 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.169 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.167 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.166 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.165 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.164 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.163 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.162 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.161 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
trackler-2.2.1.160 tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala