diff options
Diffstat (limited to 'test/src/buffer-tests.el')
| -rw-r--r-- | test/src/buffer-tests.el | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index c1e5d0ebed3..13d48b31a4f 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el | |||
| @@ -1482,4 +1482,53 @@ with parameters from the *Messages* buffer modification." | |||
| 1482 | (when auto-save | 1482 | (when auto-save |
| 1483 | (ignore-errors (delete-file auto-save)))))))) | 1483 | (ignore-errors (delete-file auto-save)))))))) |
| 1484 | 1484 | ||
| 1485 | (ert-deftest test-buffer-modifications () | ||
| 1486 | (ert-with-temp-file file | ||
| 1487 | (with-current-buffer (find-file file) | ||
| 1488 | (auto-save-mode 1) | ||
| 1489 | (should-not (buffer-modified-p)) | ||
| 1490 | (insert "foo") | ||
| 1491 | (should (buffer-modified-p)) | ||
| 1492 | (should-not (eq (buffer-modified-p) 'autosaved)) | ||
| 1493 | (do-auto-save nil t) | ||
| 1494 | (should (eq (buffer-modified-p) 'autosaved)) | ||
| 1495 | (with-silent-modifications | ||
| 1496 | (put-text-property 1 3 'face 'bold)) | ||
| 1497 | (should (eq (buffer-modified-p) 'autosaved)) | ||
| 1498 | (save-buffer) | ||
| 1499 | (should-not (buffer-modified-p)) | ||
| 1500 | (with-silent-modifications | ||
| 1501 | (put-text-property 1 3 'face 'italic)) | ||
| 1502 | (should-not (buffer-modified-p))))) | ||
| 1503 | |||
| 1504 | (ert-deftest test-restore-buffer-modified-p () | ||
| 1505 | (ert-with-temp-file file | ||
| 1506 | (with-current-buffer (find-file file) | ||
| 1507 | (auto-save-mode 1) | ||
| 1508 | (should-not (buffer-modified-p)) | ||
| 1509 | (insert "foo") | ||
| 1510 | (should (buffer-modified-p)) | ||
| 1511 | (restore-buffer-modified-p nil) | ||
| 1512 | (should-not (buffer-modified-p)) | ||
| 1513 | (insert "bar") | ||
| 1514 | (do-auto-save nil t) | ||
| 1515 | (should (eq (buffer-modified-p) 'autosaved)) | ||
| 1516 | (insert "zot") | ||
| 1517 | (restore-buffer-modified-p 'autosaved) | ||
| 1518 | (should (eq (buffer-modified-p) 'autosaved)) | ||
| 1519 | |||
| 1520 | ;; Clean up. | ||
| 1521 | (when (file-exists-p buffer-auto-save-file-name) | ||
| 1522 | (delete-file buffer-auto-save-file-name)))) | ||
| 1523 | |||
| 1524 | (ert-with-temp-file file | ||
| 1525 | (with-current-buffer (find-file file) | ||
| 1526 | (auto-save-mode 1) | ||
| 1527 | (should-not (buffer-modified-p)) | ||
| 1528 | (insert "foo") | ||
| 1529 | (should (buffer-modified-p)) | ||
| 1530 | (should-not (eq (buffer-modified-p) 'autosaved)) | ||
| 1531 | (restore-buffer-modified-p 'autosaved) | ||
| 1532 | (should (eq (buffer-modified-p) 'autosaved))))) | ||
| 1533 | |||
| 1485 | ;;; buffer-tests.el ends here | 1534 | ;;; buffer-tests.el ends here |