Add some matcher messaging to ParserSpec

This commit is contained in:
Dale Wijnand 2018-12-22 16:26:55 +00:00
parent 6988b2289a
commit 3d924978c2
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
1 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@
import java.net.URI
import org.scalatest.matchers.MatchResult
import org.scalatest.prop.PropertyChecks
import org.scalatest.{ Matchers, PropSpec }
import sbt.Def._
@ -71,7 +72,14 @@ class ParserSpec extends PropSpec with PropertyChecks with Matchers {
val structure = TestBuild.structure(env, settings, build.allProjects.head._1)
val string = displayMasked(scopedKey, ScopeMask())
val parser = makeParser(structure)
val result = DefaultParsers.result(parser, string).left.map(_().toString)
result shouldBe Right(scopedKey)
string should { left =>
val result = DefaultParsers.result(parser, left)
val resultStr = result.fold(_ => "<parse error>", _.toString)
MatchResult(
result == Right(scopedKey),
s"$left parsed back to $resultStr rather than $scopedKey",
s"$left parsed back to $scopedKey",
)
}
}
}