summaryrefslogtreecommitdiff
path: root/llm-tools-hl-test.el
diff options
context:
space:
mode:
Diffstat (limited to 'llm-tools-hl-test.el')
-rw-r--r--llm-tools-hl-test.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/llm-tools-hl-test.el b/llm-tools-hl-test.el
index 879a4b4..82117b7 100644
--- a/llm-tools-hl-test.el
+++ b/llm-tools-hl-test.el
@@ -680,3 +680,22 @@ tried to parse a line like \"~payload\" as an operation."
680 (should-not (member "some payload" file-anchors)) 680 (should-not (member "some payload" file-anchors))
681 (should-not (member "another line" file-anchors)) 681 (should-not (member "another line" file-anchors))
682 (should-not (member "replacement" file-anchors)))))) 682 (should-not (member "replacement" file-anchors))))))
683
684(ert-deftest llm-tools--hl-apply-replace-delete-offset-test ()
685 "Replace same-count lines then delete a later line.
686The replace's offset delta should be 0 (2 payload lines replacing 2 lines).
687With the buggy formula (- b a 1) this computed to +2 instead, causing the
688delete to target past the end of the buffer."
689 (let* ((content "A\nB\nC\nD\nE\n")
690 (file (make-temp-file nil nil nil content))
691 (a2 (llm-tools--hl-file-line-hash file 2))
692 (a3 (llm-tools--hl-file-line-hash file 3))
693 (a5 (llm-tools--hl-file-line-hash file 5))
694 (patch (format "@@ %s\n= %s..%s\n~X\n~Y\n- %s..%s"
695 file a2 a3 a5 a5)))
696 (unwind-protect
697 (progn
698 (llm-tools--hl-apply patch)
699 (let ((lines (llm-tools--hl-file-lines file)))
700 (should (equal lines '("A" "X" "Y" "D")))))
701 (delete-file file))))