Skip to content

Instantly share code, notes, and snippets.

@jqno
Created March 26, 2012 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqno/2209368 to your computer and use it in GitHub Desktop.
Save jqno/2209368 to your computer and use it in GitHub Desktop.
import org.parboiled.scala._
import org.parboiled.errors.ErrorUtils
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
@RunWith(classOf[JUnitRunner])
class IsolationTest extends FlatSpec with ShouldMatchers {
val input = "abcdxyz"
"Text rule" should "parse different lengths" in {
val result = ReportingParseRunner(FailingParser.Input).run(input)
println(ErrorUtils.printParseErrors(result))
result should be ('matched)
}
}
object FailingParser extends Parser {
def Input = rule { Text(4) ~ Text(3) }
// def Text(places: Int) = nTimes(places, ANY) // works
def Text(places: Int) = rule { nTimes(places, ANY) } // doesn't work
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment