summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPip Cet <pipcet@protonmail.com>2026-05-17 15:27:03 +0000
committerPip Cet <pipcet@protonmail.com>2026-05-20 11:27:40 +0000
commit0b5ead9923516c18bbf45d499661a0641fb07731 (patch)
treebcac88e4175c5415023d2ad120189bd2733d4954 /test
parenta8b9fad89720847a869bf288eb41473b6c82b833 (diff)
Detect some API violations in combine-change-calls (bug#80877)
Quickly verify that the number of unchanged characters before and after the region that changes are supposed to be limited to doesn't change. Suggested by Stefan Monnier. * lisp/subr.el (combine-change-calls-1): Copy BEG into a marker, and count the characters after the changed region. After the changes, ensure the character counts still match. * test/lisp/subr-tests.el (subr-test-combine-change-calls-error): New.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/subr-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index b99328459d6..b6e9eb92855 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1773,5 +1773,24 @@ The argument names are important."
'("foo" "bar" "bazzzzzz"))
'(("foo" "bar") ("bazzzzzz"))))))
+(ert-deftest subr-test-combine-change-calls-error ()
+ "Test detection of unexpected changes in `combine-change-calls'."
+ (with-temp-buffer
+ (insert "a\nb\nc\n")
+ (combine-change-calls 3 5
+ (goto-char (point-min))
+ (search-forward "b")
+ (replace-match "bbb"))
+ (should-error
+ (combine-change-calls 3 7
+ (goto-char (point-min))
+ (search-forward "a")
+ (replace-match "aaa")))
+ (should-error
+ (combine-change-calls 5 9
+ (goto-char (point-min))
+ (search-forward "c")
+ (replace-match "ccc")))))
+
(provide 'subr-tests)
;;; subr-tests.el ends here