diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2024-04-10 12:15:26 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2024-04-10 12:15:26 -0400 |
commit | 36cb16556c60bf4e703764eefd4fb6668ccc37cc (patch) | |
tree | 22ea5c9410cef797c7a9a50c8b1de934185d89e5 /test/src/editfns-tests.el | |
parent | 15bafc04322e9c4e85a00fe593239935eb723b6e (diff) | |
download | emacs-36cb16556c60bf4e703764eefd4fb6668ccc37cc.tar.gz emacs-36cb16556c60bf4e703764eefd4fb6668ccc37cc.tar.bz2 emacs-36cb16556c60bf4e703764eefd4fb6668ccc37cc.zip |
(en/decode_coding_object): Fix `after-change-functions`
For `en/decode-coding-string/region`, `after-change-functions`
were either not run at all, or run only after deleting the text
but not after inserting it.
* src/coding.c (decode_coding_object, encode_coding_object): Run the
after-change-functions after inserting the result.
* test/src/editfns-tests.el (sanity-check-change-functions-with-op):
New macro.
(sanity-check-change-functions-errors): New function.
(editfns-tests--before/after-change-functions): Use them to add
cases for `en/decode-coding-string/region`.
Diffstat (limited to 'test/src/editfns-tests.el')
-rw-r--r-- | test/src/editfns-tests.el | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index a14a5f90b65..a7fcef86209 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -428,9 +428,17 @@ ;;; Try and catch `*-changes-functions' bugs! -(defvar sanity-check--verbose nil) +(defvar sanity-check-change-functions-verbose nil) +(defvar sanity-check-change-functions-op nil) +(defmacro sanity-check-change-functions-with-op (op &rest body) + (declare (debug t) (indent 1)) + `(let ((sanity-check-change-functions-op ,op)) + (sanity-check--message "%S..." sanity-check-change-functions-op) + ,@body + (sanity-check--message "%S...done" sanity-check-change-functions-op))) + (defun sanity-check--message (&rest args) - (if sanity-check--verbose (apply #'message args))) + (if sanity-check-change-functions-verbose (apply #'message args))) (defvar-local sanity-check-change-functions-beg 0) (defvar-local sanity-check-change-functions-end 0) @@ -488,6 +496,12 @@ (+ sanity-check-change-functions-buffer-size offset))) (sanity-check-change-functions-check-size)) +(defun sanity-check-change-functions-errors () + (sanity-check-change-functions-check-size) + (if sanity-check-change-functions-errors + (cons sanity-check-change-functions-op + sanity-check-change-functions-errors))) + (ert-deftest editfns-tests--before/after-change-functions () (with-temp-buffer (add-hook 'before-change-functions @@ -496,8 +510,28 @@ #'sanity-check-change-functions-after nil t) ;; Bug#65451 - (insert "utf-8-unix\n\nUTF") - (call-interactively 'dabbrev-expand) - (should (null sanity-check-change-functions-errors)))) + (sanity-check-change-functions-with-op 'DABBREV-EXPAND + (insert "utf-8-unix\n\nUTF") + (call-interactively 'dabbrev-expand) + (should (null (sanity-check-change-functions-errors)))) + + (let ((beg (point))) + (sanity-check-change-functions-with-op 'ENCODE-CODING-REGION + (insert "ééé") + (encode-coding-region beg (point) 'utf-8) + (should (null (sanity-check-change-functions-errors)))) + + (sanity-check-change-functions-with-op 'DECODE-CODING-REGION + (decode-coding-region beg (point) 'utf-8) + (should (null (sanity-check-change-functions-errors))))) + + (sanity-check-change-functions-with-op 'ENCODE-CODING-STRING + (encode-coding-string "ééé" 'utf-8 nil (current-buffer)) + (should (null (sanity-check-change-functions-errors)))) + + (sanity-check-change-functions-with-op 'DECODE-CODING-STRING + (decode-coding-string "\303\251\303\251\303\251" + 'utf-8 nil (current-buffer)) + (should (null (sanity-check-change-functions-errors)))))) ;;; editfns-tests.el ends here |