Created
May 21, 2011 12:33
-
-
Save systay/984483 to your computer and use it in GitHub Desktop.
Failing test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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