Skip to content

Commit a5aff94

Browse files
committed
Add regression tests for triple-chained prefixes and chain+suffix
PR review flagged that the current tests only cover the narrowest case (a single prefix phrase repeated twice). Add two stronger guards for the exact code path #208's fix touches: 3+ chained repeats, and a repeated chain immediately followed by a suffix (the prefix-run absorption loop and the suffix-boundary loop share the same index variable, so this combination is worth pinning down explicitly).
1 parent 6a7532d commit a5aff94

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/test_prefixes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ def test_repeated_prefix_chain_van_der(self) -> None:
317317
self.m(hn.first, "Charles", hn)
318318
self.m(hn.last, "van der van der Berg", hn)
319319

320+
def test_triple_repeated_prefix_chain(self) -> None:
321+
# a stronger regression guard than the 2-repeat cases above: the
322+
# contiguous-prefix absorption loop should chain any number of
323+
# repeats, not just handle exactly two
324+
hn = HumanName("Juan de la de la de la Vega")
325+
self.m(hn.first, "Juan", hn)
326+
self.m(hn.last, "de la de la de la Vega", hn)
327+
328+
def test_repeated_prefix_chain_followed_by_suffix(self) -> None:
329+
# the prefix-run absorption loop and the suffix-boundary loop share
330+
# the same index variable, so a repeated chain immediately
331+
# followed by a suffix is worth pinning down explicitly
332+
hn = HumanName("Juan de la de la Vega Jr.")
333+
self.m(hn.first, "Juan", hn)
334+
self.m(hn.last, "de la de la Vega", hn)
335+
self.m(hn.suffix, "Jr.", hn)
336+
320337
# --- safety: excluded / ambiguous particles are unchanged ---
321338

322339
def test_leading_von_is_unchanged(self) -> None:

0 commit comments

Comments
 (0)