Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions tests/test_doc_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,11 @@ def test_evolution_prompt_no_quick_ref_block() -> None:
# glob string, a doc block and one live `it(...)` to
# `emrg/gui/test/build-config.test.js` makes the regex report `['/**")) {']`
# where the scanner reports nothing (and the regex is not merely noisy: on the
# two files of its own suite that spell the pattern out in prose it reads 20
# spans where 2 exist, 4 where 0).
# two files of its own suite that spell the pattern out in prose it reads 14
# spans where 2 exist, 4 where 0 - re-measured 2026-10-09, `cyc20261009-022334`:
# 14 on the copy that preceded this file's own rewrite, 21 on the copy carrying
# it because its new comments add spans, and 2 for the scanner on both, so the
# number is re-measured rather than quoted).
#
# What the comment *contains* is still judged by the counter's own pattern
# (`_would_be_counted`), not by a lookalike of it: an earlier version used
Expand Down Expand Up @@ -2150,6 +2153,38 @@ def test_the_span_finder_reads_line_comments_before_strings() -> None:
)


def test_a_quote_in_code_position_does_not_swallow_the_block_below() -> None:
"""The clause that skips an unclosed quote is load-bearing, so it is pinned.

A quote in **code** position - the apostrophe of a regex literal, the one
shape `_block_comment_spans` declares it cannot model - never closes on its
line, so the skip is what keeps the walk alive: without it the literal is
read as an unterminated string, the walk runs to the end of the file, and the
block comment below is never seen. That silent return is the false green this
tripwire exists to prevent. Measured 2026-10-09 (`cyc20261009-022334`):
removing the clause leaves the whole file green, so this is the row that
reaches it; the neighbouring apostrophe row does not, because the
line-comment branch answers its input first.
"""
guard = _loaded_guard_module()
body = (
"const re = /don't/;\n"
"/**\n"
'it("disabled", () => {});\n'
"*/\n"
'it("live", () => {});\n'
)
assert len(guard._DEFINITION_FORM.findall(body)) == 2, (
"premise: the counter counted the commented definition too, which is the "
"over-count this tripwire reports"
)
assert guard._commented_out_definitions(body) == ["/**"], (
"the one block comment in this body must still be reported - a quote in "
"code position is skipped alone, and without that skip the walk runs to "
"the end of the file and the block below is never seen"
)


def test_the_detector_and_the_counter_share_one_definition_of_counted() -> None:
"""The two sides of this tripwire must not drift apart again.

Expand Down
Loading