Skip to content

Instantly share code, notes, and snippets.

@hohl
Created September 14, 2015 09:21
Show Gist options
  • Save hohl/3daae9b77eb1b02e175e to your computer and use it in GitHub Desktop.
Save hohl/3daae9b77eb1b02e175e to your computer and use it in GitHub Desktop.
Why does this single test case fail, while others work as expected?
// ...
lazy val prefix: Parser[Prefix] =
(host | nick) ~ opt('!' ~> user) ~ opt('@' ~> host) ^^ {
case t ~ u ~ s => Prefix(t, u, s)
}
lazy val host = """[a-zA-Z0-9.:\-^_\-\[\]\\/`]+""".r
lazy val nick = """(\p{L}|[0-9]|[-_\[\]\\`^\{\}\|])+""".r
lazy val user = """[^(\s|@)]+""".r
// ...
// ...
"be able to parse nicks with vertical bars (they are in use even if they are not allowed by RFC1459 or RFC2813)" in {
val prefix = "Miho|Zzz!~Miho@191.ip-149-202-42.eu"
val successfullyParsed = Parser.parseAll(Parser.prefix, prefix) match {
case Parser.Success(Prefix("Miho|Zzz", Some("~Miho"), Some("191.ip-149-202-42.eu")), _) =>
true
case x =>
false
}
successfullyParsed must beTrue
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment