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.107 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.106 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.105 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.104 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.103 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.102 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.101 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.100 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.99 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.98 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.97 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.96 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.95 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.94 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.93 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.92 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.91 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.90 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.89 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala
trackler-2.2.1.88 tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala