Skip to content

Commit f0c4a72

Browse files
committed
Lock structural block visibility
Require every standard-delimited block candidate to become either a parsed entry or an explicit failed block across whitespace and identifier variants.
1 parent f8e24e5 commit f0c4a72

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎tests/splitter_tests/test_splitter_block_start_detection.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,34 @@ def test_newline_before_parenthesis_delimiter_is_explicit_failure():
203203
assert library.failed_blocks[0].raw == bibtex
204204

205205

206+
@pytest.mark.parametrize(
207+
"entry_type", ["article", "systematic-review", "review:type", "software/package"]
208+
)
209+
@pytest.mark.parametrize("separator", ["", " ", "\n ", "\r\n\t"])
210+
@pytest.mark.parametrize(
211+
"opening, closing, expected_kind",
212+
[("{", "}", "entry"), ("(", ")", "failed")],
213+
ids=["supported-curly", "unsupported-parenthesis"],
214+
)
215+
def test_structural_block_candidate_never_becomes_implicit_comment(
216+
entry_type: str, separator: str, opening: str, closing: str, expected_kind: str
217+
):
218+
"""A standard-delimited candidate must be parsed or explicitly retained as failed."""
219+
source = f"@{entry_type}{separator}{opening}key, title = {{Visible block}}{closing}"
220+
221+
library = Splitter(source).split()
222+
223+
assert len(library.comments) == 0
224+
assert len(library.blocks) == 1
225+
if expected_kind == "entry":
226+
assert len(library.entries) == 1
227+
assert len(library.failed_blocks) == 0
228+
else:
229+
assert len(library.entries) == 0
230+
assert len(library.failed_blocks) == 1
231+
assert library.failed_blocks[0].raw == source
232+
233+
206234
@pytest.mark.parametrize(
207235
"unsupported_block",
208236
[

0 commit comments

Comments
 (0)