diff options
| author | Stefan Monnier | 2024-04-10 12:15:26 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2024-04-10 12:15:26 -0400 |
| commit | 36cb16556c60bf4e703764eefd4fb6668ccc37cc (patch) | |
| tree | 22ea5c9410cef797c7a9a50c8b1de934185d89e5 /test/src | |
| parent | 15bafc04322e9c4e85a00fe593239935eb723b6e (diff) | |
| download | emacs-36cb16556c60bf4e703764eefd4fb6668ccc37cc.tar.gz 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')
| -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 @@ | |||
| 428 | 428 | ||
| 429 | ;;; Try and catch `*-changes-functions' bugs! | 429 | ;;; Try and catch `*-changes-functions' bugs! |
| 430 | 430 | ||
| 431 | (defvar sanity-check--verbose nil) | 431 | (defvar sanity-check-change-functions-verbose nil) |
| 432 | (defvar sanity-check-change-functions-op nil) | ||
| 433 | (defmacro sanity-check-change-functions-with-op (op &rest body) | ||
| 434 | (declare (debug t) (indent 1)) | ||
| 435 | `(let ((sanity-check-change-functions-op ,op)) | ||
| 436 | (sanity-check--message "%S..." sanity-check-change-functions-op) | ||
| 437 | ,@body | ||
| 438 | (sanity-check--message "%S...done" sanity-check-change-functions-op))) | ||
| 439 | |||
| 432 | (defun sanity-check--message (&rest args) | 440 | (defun sanity-check--message (&rest args) |
| 433 | (if sanity-check--verbose (apply #'message args))) | 441 | (if sanity-check-change-functions-verbose (apply #'message args))) |
| 434 | 442 | ||
| 435 | (defvar-local sanity-check-change-functions-beg 0) | 443 | (defvar-local sanity-check-change-functions-beg 0) |
| 436 | (defvar-local sanity-check-change-functions-end 0) | 444 | (defvar-local sanity-check-change-functions-end 0) |
| @@ -488,6 +496,12 @@ | |||
| 488 | (+ sanity-check-change-functions-buffer-size offset))) | 496 | (+ sanity-check-change-functions-buffer-size offset))) |
| 489 | (sanity-check-change-functions-check-size)) | 497 | (sanity-check-change-functions-check-size)) |
| 490 | 498 | ||
| 499 | (defun sanity-check-change-functions-errors () | ||
| 500 | (sanity-check-change-functions-check-size) | ||
| 501 | (if sanity-check-change-functions-errors | ||
| 502 | (cons sanity-check-change-functions-op | ||
| 503 | sanity-check-change-functions-errors))) | ||
| 504 | |||
| 491 | (ert-deftest editfns-tests--before/after-change-functions () | 505 | (ert-deftest editfns-tests--before/after-change-functions () |
| 492 | (with-temp-buffer | 506 | (with-temp-buffer |
| 493 | (add-hook 'before-change-functions | 507 | (add-hook 'before-change-functions |
| @@ -496,8 +510,28 @@ | |||
| 496 | #'sanity-check-change-functions-after nil t) | 510 | #'sanity-check-change-functions-after nil t) |
| 497 | 511 | ||
| 498 | ;; Bug#65451 | 512 | ;; Bug#65451 |
| 499 | (insert "utf-8-unix\n\nUTF") | 513 | (sanity-check-change-functions-with-op 'DABBREV-EXPAND |
| 500 | (call-interactively 'dabbrev-expand) | 514 | (insert "utf-8-unix\n\nUTF") |
| 501 | (should (null sanity-check-change-functions-errors)))) | 515 | (call-interactively 'dabbrev-expand) |
| 516 | (should (null (sanity-check-change-functions-errors)))) | ||
| 517 | |||
| 518 | (let ((beg (point))) | ||
| 519 | (sanity-check-change-functions-with-op 'ENCODE-CODING-REGION | ||
| 520 | (insert "ééé") | ||
| 521 | (encode-coding-region beg (point) 'utf-8) | ||
| 522 | (should (null (sanity-check-change-functions-errors)))) | ||
| 523 | |||
| 524 | (sanity-check-change-functions-with-op 'DECODE-CODING-REGION | ||
| 525 | (decode-coding-region beg (point) 'utf-8) | ||
| 526 | (should (null (sanity-check-change-functions-errors))))) | ||
| 527 | |||
| 528 | (sanity-check-change-functions-with-op 'ENCODE-CODING-STRING | ||
| 529 | (encode-coding-string "ééé" 'utf-8 nil (current-buffer)) | ||
| 530 | (should (null (sanity-check-change-functions-errors)))) | ||
| 531 | |||
| 532 | (sanity-check-change-functions-with-op 'DECODE-CODING-STRING | ||
| 533 | (decode-coding-string "\303\251\303\251\303\251" | ||
| 534 | 'utf-8 nil (current-buffer)) | ||
| 535 | (should (null (sanity-check-change-functions-errors)))))) | ||
| 502 | 536 | ||
| 503 | ;;; editfns-tests.el ends here | 537 | ;;; editfns-tests.el ends here |