Skip to content

Commit

Permalink
Make parseRootWithURLs return URLS on Left case too
Browse files Browse the repository at this point in the history
  • Loading branch information
reidspencer committed Oct 29, 2024
1 parent af569f7 commit 60e000b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TopLevelParserTest extends ParsingTest {
val rpi: RiddlParserInput = Await.result(RiddlParserInput.fromURL(url), 10.seconds)
val tlp = TopLevelParser(rpi,false)
tlp.parseRootWithURLs match {
case Left(messages) => fail(messages.format)
case Left((messages, _)) => fail(messages.format)
case Right((root, urls)) =>
root.domains.head.id.value must be("Everything")
val paths: Seq[String] = urls.map(_.path)
Expand All @@ -92,5 +92,16 @@ class TopLevelParserTest extends ParsingTest {
paths must contain("language/jvm/src/test/input/everything_full.riddl")
}
}
"return URLs on failure" in { (td: TestData) =>
val rpi: RiddlParserInput = RiddlParserInput("some source that ain't riddl", td)
val tlp = TopLevelParser(rpi, false)
tlp.parseRootWithURLs match {
case Left((messages, urls)) =>
urls must be(empty)
messages mustNot be(empty)
succeed
case Right((root, urls)) => fail("Test should have yields Left")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ trait ExtensibleTopLevelParser(using PlatformContext)

def parseNebula: Either[Messages, Nebula] = doParse[Nebula](nebula(_))

def parseRootWithURLs: Either[Messages, (Root, Seq[URL])] = {
def parseRootWithURLs: Either[(Messages, Seq[URL]), (Root, Seq[URL])] = {
doParse[Root](root(_)) match {
case l @ Left(messages) => Left(messages)
case l @ Left(messages) => Left(messages -> this.getURLs)
case r @ Right(root) => Right(root -> this.getURLs)
}
}
Expand Down

0 comments on commit 60e000b

Please sign in to comment.