Created
March 26, 2012 20:18
-
-
Save jqno/2209368 to your computer and use it in GitHub Desktop.
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
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