Skip to content

Instantly share code, notes, and snippets.

@systay
Created May 21, 2011 12:33
Show Gist options
  • Save systay/984483 to your computer and use it in GitHub Desktop.
Save systay/984483 to your computer and use it in GitHub Desktop.
Failing test
package org.neo4j.lab.cypher
import commands.Query
import util.parsing.combinator.JavaTokenParsers
import org.junit.Assert._
import org.junit.Test
class ParserTest {
@Test def lowerCaseWorks() {
val parser = new TestParser
val option: Option[Let] = parser.parse("let a = \"hello world\"")
if (option.isEmpty)
fail();
}
@Test def upperCaseWorks() {
val parser = new TestParser
val option: Option[Let] = parser.parse("LET a = \"hello world\"")
if (option.isEmpty)
fail();
}
}
case class Let(variable:String, value:String)
class TestParser extends JavaTokenParsers {
def let: Parser[Let] = "let" ~> ident ~ "=" ~ stringLiteral ^^ {
case variable ~ "=" ~ value => Let(variable, value)
}
def parse(statement: String): Option[Let] =
parseAll(let, statement) match {
case Success(r, q) => Option(r)
case x => println(x); None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment