Sha256: e5034d0ec5ddf5a9d25a8aae74a628b48baa8c6e3c68b7e6116cbe98e00c79b4

Contents?: true

Size: 1.53 KB

Versions: 95

Compression:

Stored size: 1.53 KB

Contents

import java.io.File

import testgen.TestSuiteBuilder._
import testgen._

object HouseTestGenerator {
  def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String = {
    val startVerse = parseResult.get("start verse")
    val endVerse = parseResult.get("end verse")
    val verse = parseResult.get("verse")

    startVerse match {
      case Some(s) => s.toString + endVerse.map(s => ", " + s.toString).getOrElse("")
      case _ => verse match {
        case Some(s) => s.toString
        case _ => throw new IllegalStateException("Missing params")
      }
    }
  }


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

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

    def fromLabeledTest(argNames: String*)(
      implicit sutFunction: LabeledTest => String = _.property): ToTestCaseData =
      withLabeledTest { sut =>
        labeledTest =>
          val sutFunction = labeledTest.property
          val args = sutArgs(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,
      fromLabeledTest("verse", "start verse", "end verse"))
    println(s"-------------")
    println(code)
    println(s"-------------")
  }
}

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
trackler-2.2.1.47 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.46 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.45 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.44 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.43 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.42 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.41 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.40 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.39 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.38 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.37 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.36 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.35 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.34 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.33 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.32 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.31 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.30 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.29 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.28 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala