Sha256: d963168dc3673b630ef863243b72b7f06ab1d04e32aeb156bdae3a60b07c8010

Contents?: true

Size: 1.57 KB

Versions: 68

Compression:

Stored size: 1.57 KB

Contents

import testgen._
import TestSuiteBuilder._
import java.io.File

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

    def mapExpectedToString(arg: Map[String, Int]): String = {
      s"Right(Map(${arg.toSeq
        .sortBy(_._1)
        .map{case (key, value) => "\'" + key.toString + "\' -> " + value.toString}
        .mkString(",\n")}))"
    }

    def toString(expected: CanonicalDataParser.Expected): String = {
      expected match {
        case Left(s: String) => "true"
        case Right(m: Map[String, Int]) => mapExpectedToString(m)
        case _ => throw new IllegalArgumentException
      }
    }

    def toSutCall(labeledTest: LabeledTest, argNames: String*): String = {
      val args = sutArgsFromInput(labeledTest.result, argNames: _*)
      val property = labeledTest.property
      labeledTest.expected match {
        case Left(_) => s"""new DNA($args).$property.isLeft"""
        case Right(_) => s"""new DNA($args).$property"""
        case _ => throw new IllegalArgumentException
      }
    }

    def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
      withLabeledTest { sut =>
        labeledTest =>
          val sutCall = toSutCall(labeledTest, argNames: _*)
          val expected = toString(labeledTest.expected)
          TestCaseData(labeledTest.description, sutCall, expected)
      }


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

Version data entries

68 entries across 68 versions & 1 rubygems

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