Skip to content

Commit bfdb842

Browse files
committed
Fix for #1
1 parent 0ef077b commit bfdb842

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/main/scala/wolfendale/scalacheck/regexp/GenParser.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ object GenParser extends RegexParsers with PackratParsers {
9898
val wordBoundary: Parser[CharacterClass.Term] = "\\b" ^^^ CharacterClass.WordBoundary
9999

100100
lazy val char: Parser[CharacterClass.Term] = {
101-
val meta = "\\" | "]"
102-
(("\\" ~> meta) | "[^\\]\\\\]".r) ^^ CharacterClass.Literal
101+
val normalChars = "[^\\]\\\\]".r
102+
val meta = "\\" | "]" | "-"
103+
(("\\" ~> meta) | normalChars | "\\" ~> normalChars) ^^ CharacterClass.Literal
103104
}
104105

105106
lazy val characterClassTerm: Parser[CharacterClass.Term] =

src/test/scala/wolfendale/scalacheck/regexp/RegexpGenSpec.scala

+12
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,17 @@ class RegexpGenSpec extends WordSpec with MustMatchers with PropertyChecks {
3434
str must fullyMatch regex r
3535
}
3636
}
37+
38+
"create a valid generator from `^[a-zA-Z &`\\-\\'\\.]{1,35}$`" in {
39+
40+
val r = "^[a-zA-Z &`\\-\\'\\.]{1,35}$"
41+
val gen = RegexpGen.from(r)
42+
43+
forAll(gen) {
44+
str =>
45+
println(str)
46+
str must fullyMatch regex r
47+
}
48+
}
3749
}
3850
}

0 commit comments

Comments
 (0)