diff options
| author | 夏音 / natsuoto.exe <[email protected]> | 2026-07-01 17:31:04 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-01 17:31:04 +0530 |
| commit | ad4eb75ddcadf263391bba8eed837cce3b860cf9 (patch) | |
| tree | b3ec15be9350eec74079c136d68dbd6c0239e32b /tests/pattern/composition.test.py | |
| parent | 2d9e7395dc62ca7ff9c0bf508ca4fb5e823b538e (diff) | |
| parent | a2195e709d7c4f1fc3c75740446397f1b62c37a0 (diff) | |
| download | edify-ad4eb75ddcadf263391bba8eed837cce3b860cf9.tar.xz edify-ad4eb75ddcadf263391bba8eed837cce3b860cf9.zip | |
fix!: quantifier validation — dangling and stacked quantifiers raise; Hypothesis property gate (#269)
Tightens quantifier semantics so the builder can no longer silently drop
a quantifier from the emitted regex, and locks the invariant in with a
Hypothesis property test.
## Dangling quantifier now raises
`RegexBuilder().exactly(3).to_regex_string()` used to emit `^$` — the
quantifier had no operand, so it was silently discarded. It now raises
`DanglingQuantifierError` at emit time.
```python
RegexBuilder().exactly(3).to_regex_string()
# edify.errors.quantifier.DanglingQuantifierError:
# Dangling quantifier with no operand. Append an element (e.g. .digit()) before compiling.
```
## Stacked quantifiers now raise
`RegexBuilder().one_or_more().exactly(3).digit()` used to emit `\d{3}` —
the second quantifier overwrote the first, silently dropping
`one_or_more`. It now raises `StackedQuantifierError` at chain-call
time.
```python
RegexBuilder().one_or_more().exactly(3).digit()
# edify.errors.quantifier.StackedQuantifierError:
# Cannot stack a quantifier on top of another pending quantifier.
# Add an operand between the two quantifiers or drop one.
```
## Property assertion
Hypothesis-driven test in `tests/builder/properties.test.py` — for any
list of `(quantifier method, element method)` pairs, the emitted regex
is exactly the concatenation of `<element><suffix>` fragments in order.
`hypothesis>=6.100` added to the `dev` dependency group.
## Breaking
Any chain that previously silently emitted a wrong-but-parseable regex
now raises. Correct chains are unaffected.
Closes #109
Closes #110
Closes #111
Diffstat (limited to 'tests/pattern/composition.test.py')
0 files changed, 0 insertions, 0 deletions
