Skip to content

Commit

Permalink
Fixed optional bug in invert
Browse files Browse the repository at this point in the history
  • Loading branch information
smartycope committed Apr 20, 2024
1 parent b6f5801 commit 6e138e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ezregex/invert.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ def handle(pattern, amt=1, opposite=False):
case sre.RANGE:
start, end = args
s += chr(randint(start, end))
case sre.MAX_REPEAT | sre.MIN_REPEAT:
case sre.MIN_REPEAT: # optional, I believe
min, max, sub = args
if randint(0, 1) == 1:
s += handle(sub, amt)
case sre.MAX_REPEAT:
min, max, sub = args
if max is None or max is sre.MAXREPEAT:
max = randint(min, self.alot)
Expand Down
5 changes: 5 additions & 0 deletions tests/data/regexs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,11 @@
[],
[]
],
[
"group('pattern', name='i') + optional(digit) + 'test'",
[],
[]
],
// TODO: This is for bytes only programs or something?...
// [
// "digit + LOCALE",
Expand Down

0 comments on commit 6e138e7

Please sign in to comment.