Skip to content

Commit

Permalink
Ref lift#913 Do regex matcher for digit parser or number parser for u…
Browse files Browse the repository at this point in the history
…nicode compatibility, since String#toInt doesn't work for extended unicode integers.
  • Loading branch information
indrajitr committed Feb 27, 2011
1 parent 4150aae commit 94555af
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
"provide a digit parser - returning a String" in {
val isDigit: String => Boolean =
(s: String) => digit(s) match {
case Success(x, y) => s.toInt == x
case _ => true
case Success(x, y) => s mustMatch ("\\p{Nd}")
case _ => true
}
forAll(isDigit) must pass
}
"provide an aNumber parser - returning an Int if succeeding" in {
val number: String => Boolean =
(s: String) => {
aNumber(s) match {
case Success(x, y) => s.toInt == x
case _ => true
case Success(x, y) => s mustMatch ("\\p{Nd}+")
case _ => true
}
}
forAll(number) must pass
Expand Down Expand Up @@ -119,8 +119,7 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
val permutationOk = (s: String) => permuteParsers(s)
AbcdStringGen.abcdString must pass(permutationOk)
}
"provide a permuteAll parser succeeding if any permutation of the list given parsers, or a sublist of the given parsers succeeds" in
{
"provide a permuteAll parser succeeding if any permutation of the list given parsers, or a sublist of the given parsers succeeds" in {
def permuteAllParsers(s: String) = shouldSucceed(permuteAll(parserA, parserB, parserC, parserD)(s))
implicit def pick3Letters = AbcdStringGen.pickN(3, List("a", "b", "c"))
forAll((s: String) => (!(new scala.collection.immutable.StringOps(s)).isEmpty) ==> permuteAllParsers(s)) must pass
Expand Down

0 comments on commit 94555af

Please sign in to comment.