public
Last active

Failing test

  • Download Gist
gistfile1.scala
Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
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
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.