Skip to content

Commit

Permalink
Update connect exercise to match latest canonical json.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricemery committed Feb 17, 2018
1 parent 56479ec commit f1ff758
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exercises/connect/src/test/scala/ConnectTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.scalatest.{Matchers, FunSuite}

/** @version 1.0.0 */
/** @version 1.1.0 */
class ConnectTest extends FunSuite with Matchers {

// Filter readable board into valid input
Expand Down
12 changes: 6 additions & 6 deletions testgen/src/main/scala/ConnectTestGenerator.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.io.File

import testgen.TestSuiteBuilder._
import testgen.TestSuiteBuilder.{toString, _}
import testgen._

object ConnectTestGenerator {
Expand All @@ -16,8 +16,8 @@ object ConnectTestGenerator {
}
}

def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
argNames map (name => toArgString(parseResult(name))) mkString ", "
def sutArgsFromInput(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
argNames map (name => toArgString(parseResult("input").asInstanceOf[Map[String, Any]](name))) mkString(", ")

def toArgString(any: Any): String = {
any match {
Expand All @@ -28,18 +28,18 @@ object ConnectTestGenerator {
}
}

def fromLabeledTest(argNames: String*): ToTestCaseData =
def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
withLabeledTest { sut =>
labeledTest =>
val args = sutArgs(labeledTest.result, argNames: _*)
val args = sutArgsFromInput(labeledTest.result, argNames: _*)
val property = labeledTest.property
val sutCall =
s"""$sut($args).$property"""
val expected = toString(labeledTest.expected)
TestCaseData(labeledTest.description, sutCall, expected)
}

val code = TestSuiteBuilder.build(file, fromLabeledTest("board"),
val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("board"),
Seq(),
Seq("// Filter readable board into valid input",
"private def mkBoard(lines: List[String]): List[String] =",
Expand Down

0 comments on commit f1ff758

Please sign in to comment.