Skip to content

Commit 344ad6a

Browse files
test: fix remaining _build_fire_art mutants with exact style and geometry
- Use exact style equality for heat row bright_red check - Add narrow width test (w=20) to trigger min_w binding constraint - Add wide width test (w=80) to kill //2 → //3 centering mutant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f8033a commit 344ad6a

1 file changed

Lines changed: 54 additions & 2 deletions

File tree

tests/test_fireplace_visual.py

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,18 @@ def test_heat_rows_exact_wave_content(self):
450450
assert inner == "\u2248" * ow or inner == "~" * ow
451451

452452
def test_heat_row_style_is_bright_red(self):
453-
"""Heat wave chars should have bright_red style."""
453+
"""Heat wave chars should have exactly bright_red style."""
454454
w = 50
455455
text = _build_fire_art(w, 20, heat_on=True)
456456
plain = text.plain
457457
# Find the first ≈ or ~
458458
for idx, ch in enumerate(plain):
459459
if ch in ("\u2248", "~"):
460460
style = _style_at(text, idx)
461-
assert "bright_red" in style
461+
assert style == "bright_red", (
462+
f"Heat char {ch!r} at {idx} has style "
463+
f"{style!r}, expected 'bright_red'"
464+
)
462465
return
463466
raise AssertionError("No heat wave character found")
464467

@@ -666,6 +669,55 @@ def test_flame_row_trailing_spaces_only(self):
666669
# Must be only spaces
667670
assert trailing == " " * trail_count
668671

672+
def test_narrow_width_min_w_binding(self):
673+
"""At narrow widths, min_w becomes binding (kills min_w mutations)."""
674+
w = 20
675+
text = _build_fire_art(w, 20, fire_on=True)
676+
plain = text.plain
677+
lines = plain.split("\n")
678+
# With narrow width, flame rows may exceed iw due to min_w constraint
679+
# The key test: if min_w changes (±1, ±2), flame row width changes
680+
flame_widths = []
681+
for line in lines:
682+
if not line.startswith("\u2502\u2502"):
683+
continue
684+
# Find the rightmost ││
685+
right_border = line.rfind("\u2502\u2502")
686+
if right_border <= 0:
687+
continue
688+
inner = line[2:right_border]
689+
if "\u2591" in inner or "\u2593" in inner or inner.strip() == "":
690+
continue
691+
flame_widths.append(len(inner))
692+
# All flame rows should have consistent width
693+
assert len(flame_widths) >= _MIN_FLAME_ROWS
694+
# Verify widths are reasonable (not drastically wrong)
695+
for fw in flame_widths:
696+
assert fw >= 10, f"Flame row too narrow: {fw}"
697+
698+
def test_wide_width_centering_lead_differs_from_third(self):
699+
"""At wider widths, (iw-body_w)//2 differs from //3 (kills //3)."""
700+
w = 80
701+
text = _build_fire_art(w, 20, fire_on=True)
702+
lines = text.plain.split("\n")
703+
for line in lines:
704+
if not line.startswith("\u2502\u2502"):
705+
continue
706+
if not line.endswith("\u2502\u2502"):
707+
continue
708+
inner = line[2:-2]
709+
if "\u2591" in inner or "\u2593" in inner or inner.strip() == "":
710+
continue
711+
lead = len(inner) - len(inner.lstrip(" "))
712+
trail = len(inner) - len(inner.rstrip(" "))
713+
# With //2 floor division, lead <= trail
714+
# With //3, lead would be smaller and trail much larger
715+
if lead + trail >= 4:
716+
# lead should be close to trail (within 1 for odd total)
717+
assert lead >= trail - 1, (
718+
f"Bad centering at w={w}: lead={lead}, trail={trail}"
719+
)
720+
669721
def test_flame_centering_lead_roughly_half(self):
670722
"""Lead should be roughly (iw - body_w) // 2 (kills + and // 3)."""
671723
w = 60

0 commit comments

Comments
 (0)