Skip to content

Commit bec42e8

Browse files
committed
test: cover reused parent anchors across hunks
1 parent 77bbbc1 commit bec42e8

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎tests/test_apply_diff.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,48 @@ def test_apply_diff_applies_stacked_anchors_from_the_tool_description() -> None:
8181
)
8282

8383

84+
def test_apply_diff_reuses_a_prior_parent_anchor_across_stacked_hunks() -> None:
85+
input_text = (
86+
"\n".join(
87+
[
88+
"class Target",
89+
" def first():",
90+
" pass",
91+
"",
92+
" def second():",
93+
" pass",
94+
]
95+
)
96+
+ "\n"
97+
)
98+
diff = "\n".join(
99+
[
100+
"@@ class Target",
101+
"@@ def first():",
102+
"- pass",
103+
"+ return 1",
104+
"@@ class Target",
105+
"@@ def second():",
106+
"- pass",
107+
"+ return 2",
108+
]
109+
)
110+
111+
assert apply_diff(input_text, diff) == (
112+
"\n".join(
113+
[
114+
"class Target",
115+
" def first():",
116+
" return 1",
117+
"",
118+
" def second():",
119+
" return 2",
120+
]
121+
)
122+
+ "\n"
123+
)
124+
125+
84126
def test_apply_diff_stacked_anchors_narrow_to_the_named_block() -> None:
85127
"""The second anchor skips an earlier matching body inside the selected class."""
86128
input_text = (

0 commit comments

Comments
 (0)