diff options
| author | Gregory Heytings | 2023-01-13 17:43:31 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2023-01-13 17:43:31 -0500 |
| commit | b2fda50178b8151c3fe707d1a1b6b11f0c1eca12 (patch) | |
| tree | d70cd34379ec8aa1fba61860695280d39461e714 /test/src | |
| parent | 977630b5285809a57e50ff5f38d9c34247b549a7 (diff) | |
| download | emacs-b2fda50178b8151c3fe707d1a1b6b11f0c1eca12.tar.gz emacs-b2fda50178b8151c3fe707d1a1b6b11f0c1eca12.zip | |
undo-tests.el: Tests for bug#60467
* test/src/undo-tests.el (undo-test-combine-change-calls-1)
(undo-test-combine-change-calls-2, undo-test-combine-change-calls-3):
New tests.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/undo-tests.el | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index 84151d3b5db..fd45a9101fa 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el | |||
| @@ -439,6 +439,78 @@ Demonstrates bug 16818." | |||
| 439 | 439 | ||
| 440 | (should (string= (buffer-string) "aaaFirst line\nSecond line\nbbb")))) | 440 | (should (string= (buffer-string) "aaaFirst line\nSecond line\nbbb")))) |
| 441 | 441 | ||
| 442 | (ert-deftest undo-test-combine-change-calls-1 () | ||
| 443 | "Test how `combine-change-calls' updates `buffer-undo-list'. | ||
| 444 | Case 1: a file-visiting buffer with `buffer-undo-list' non-nil | ||
| 445 | and `buffer-modified-p' non-nil when `combine-change-calls' is | ||
| 446 | called." | ||
| 447 | (ert-with-temp-file tempfile | ||
| 448 | (with-current-buffer (find-file tempfile) | ||
| 449 | (insert "A") | ||
| 450 | (undo-boundary) | ||
| 451 | (insert "B") | ||
| 452 | (undo-boundary) | ||
| 453 | (insert "C") | ||
| 454 | (undo-boundary) | ||
| 455 | (insert " ") | ||
| 456 | (undo-boundary) | ||
| 457 | (insert "D") | ||
| 458 | (undo-boundary) | ||
| 459 | (insert "E") | ||
| 460 | (undo-boundary) | ||
| 461 | (insert "F") | ||
| 462 | (should (= (length buffer-undo-list) 14)) | ||
| 463 | (goto-char (point-min)) | ||
| 464 | (combine-change-calls (point-min) (point-max) | ||
| 465 | (re-search-forward "ABC ") | ||
| 466 | (replace-match "Z ")) | ||
| 467 | (should (= (length buffer-undo-list) 15))))) | ||
| 468 | |||
| 469 | (ert-deftest undo-test-combine-change-calls-2 () | ||
| 470 | "Test how `combine-change-calls' updates `buffer-undo-list'. | ||
| 471 | Case 2: a file-visiting buffer with `buffer-undo-list' non-nil | ||
| 472 | and `buffer-modified-p' nil when `combine-change-calls' is | ||
| 473 | called." | ||
| 474 | (ert-with-temp-file tempfile | ||
| 475 | (with-current-buffer (find-file tempfile) | ||
| 476 | (insert "A") | ||
| 477 | (undo-boundary) | ||
| 478 | (insert "B") | ||
| 479 | (undo-boundary) | ||
| 480 | (insert "C") | ||
| 481 | (undo-boundary) | ||
| 482 | (insert " ") | ||
| 483 | (undo-boundary) | ||
| 484 | (insert "D") | ||
| 485 | (undo-boundary) | ||
| 486 | (insert "E") | ||
| 487 | (undo-boundary) | ||
| 488 | (insert "F") | ||
| 489 | (should (= (length buffer-undo-list) 14)) | ||
| 490 | (save-buffer) | ||
| 491 | (goto-char (point-min)) | ||
| 492 | (combine-change-calls (point-min) (point-max) | ||
| 493 | (re-search-forward "ABC ") | ||
| 494 | (replace-match "Z ")) | ||
| 495 | (should (= (length buffer-undo-list) 15))))) | ||
| 496 | |||
| 497 | (ert-deftest undo-test-combine-change-calls-3 () | ||
| 498 | "Test how `combine-change-calls' updates `buffer-undo-list'. | ||
| 499 | Case 3: a file-visiting buffer with `buffer-undo-list' nil and | ||
| 500 | `buffer-modified-p' nil when `combine-change-calls' is called." | ||
| 501 | (ert-with-temp-file tempfile | ||
| 502 | (with-current-buffer (find-file tempfile) | ||
| 503 | (insert "ABC DEF") | ||
| 504 | (save-buffer) | ||
| 505 | (kill-buffer)) | ||
| 506 | (with-current-buffer (find-file tempfile) | ||
| 507 | (should (= (length buffer-undo-list) 0)) | ||
| 508 | (goto-char (point-min)) | ||
| 509 | (combine-change-calls (point-min) (point-max) | ||
| 510 | (re-search-forward "ABC ") | ||
| 511 | (replace-match "Z ")) | ||
| 512 | (should (= (length buffer-undo-list) 1))))) | ||
| 513 | |||
| 442 | (defun undo-test-all (&optional interactive) | 514 | (defun undo-test-all (&optional interactive) |
| 443 | "Run all tests for \\[undo]." | 515 | "Run all tests for \\[undo]." |
| 444 | (interactive "p") | 516 | (interactive "p") |