diff options
| author | Eli Zaretskii | 2015-11-27 13:11:57 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-11-27 13:11:57 +0200 |
| commit | 9a57376b13aa816baa4bf3c19e92983642517308 (patch) | |
| tree | dc0760ebf7841438826fa25e17fe9864e91eb39b | |
| parent | 8dcdca346f02ebb93feab9f9b8c9091bc39eb058 (diff) | |
| parent | 7fa3a0c264800c9a19ce26467effcb76dfb9a3f8 (diff) | |
| download | emacs-9a57376b13aa816baa4bf3c19e92983642517308.tar.gz emacs-9a57376b13aa816baa4bf3c19e92983642517308.zip | |
Merge branch 'emacs-25' of git.savannah.gnu.org:/srv/git/emacs into emacs-25
| -rw-r--r-- | test/automated/abbrev-tests.el | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/automated/abbrev-tests.el b/test/automated/abbrev-tests.el index d08e026ac59..6163e0b2c39 100644 --- a/test/automated/abbrev-tests.el +++ b/test/automated/abbrev-tests.el | |||
| @@ -20,10 +20,23 @@ | |||
| 20 | ;; You should have received a copy of the GNU General Public License | 20 | ;; You should have received a copy of the GNU General Public License |
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 22 | 22 | ||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; `kill-all-abbrevs-test' will remove all user *and* system abbrevs | ||
| 26 | ;; if called noninteractively with the init file loaded. | ||
| 27 | |||
| 23 | ;;; Code: | 28 | ;;; Code: |
| 24 | 29 | ||
| 25 | (require 'ert) | 30 | (require 'ert) |
| 26 | (require 'abbrev) | 31 | (require 'abbrev) |
| 32 | (require 'seq) | ||
| 33 | |||
| 34 | ;; set up test abbrev table and abbrev entry | ||
| 35 | (defun setup-test-abbrev-table () | ||
| 36 | (defvar ert-test-abbrevs nil) | ||
| 37 | (define-abbrev-table 'ert-test-abbrevs '(("a-e-t" "abbrev-ert-test"))) | ||
| 38 | (abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value") | ||
| 39 | ert-test-abbrevs) | ||
| 27 | 40 | ||
| 28 | (ert-deftest copy-abbrev-table-test () | 41 | (ert-deftest copy-abbrev-table-test () |
| 29 | (defvar foo-abbrev-table nil) ; Avoid compiler warning | 42 | (defvar foo-abbrev-table nil) ; Avoid compiler warning |
| @@ -38,6 +51,48 @@ | |||
| 38 | (should (abbrev-table-p new-foo-abbrev-table))) | 51 | (should (abbrev-table-p new-foo-abbrev-table))) |
| 39 | (should-not (string-equal (buffer-name) "*Backtrace*"))) | 52 | (should-not (string-equal (buffer-name) "*Backtrace*"))) |
| 40 | 53 | ||
| 54 | (ert-deftest kill-all-abbrevs-test () | ||
| 55 | "Test undefining all defined abbrevs" | ||
| 56 | (unless noninteractive | ||
| 57 | (ert-skip "Cannot test kill-all-abbrevs in interactive mode")) | ||
| 58 | |||
| 59 | (let ((num-tables 0)) | ||
| 60 | ;; ensure at least one abbrev exists | ||
| 61 | (should (abbrev-table-p (setup-test-abbrev-table))) | ||
| 62 | (setf num-tables (length abbrev-table-name-list)) | ||
| 63 | (kill-all-abbrevs) | ||
| 64 | |||
| 65 | ;; no tables should have been removed/added | ||
| 66 | (should (= num-tables (length abbrev-table-name-list))) | ||
| 67 | ;; number of empty tables should be the same as number of tables | ||
| 68 | (should (= num-tables (length (seq-filter | ||
| 69 | (lambda (table) | ||
| 70 | (abbrev-table-empty-p (symbol-value table))) | ||
| 71 | abbrev-table-name-list)))))) | ||
| 72 | |||
| 73 | (ert-deftest abbrev-table-name-test () | ||
| 74 | "Test returning name of abbrev-table" | ||
| 75 | (let ((ert-test-abbrevs (setup-test-abbrev-table)) | ||
| 76 | (no-such-table nil)) | ||
| 77 | (should (equal 'ert-test-abbrevs (abbrev-table-name ert-test-abbrevs))) | ||
| 78 | (should (equal nil (abbrev-table-name no-such-table))))) | ||
| 79 | |||
| 80 | (ert-deftest clear-abbrev-table-test () | ||
| 81 | "Test clearing single abbrev table" | ||
| 82 | (let ((ert-test-abbrevs (setup-test-abbrev-table))) | ||
| 83 | (should (equal "a-e-t" (symbol-name | ||
| 84 | (abbrev-symbol "a-e-t" ert-test-abbrevs)))) | ||
| 85 | (should (equal "abbrev-ert-test" (symbol-value | ||
| 86 | (abbrev-symbol "a-e-t" ert-test-abbrevs)))) | ||
| 87 | |||
| 88 | (clear-abbrev-table ert-test-abbrevs) | ||
| 89 | |||
| 90 | (should (equal "nil" (symbol-name | ||
| 91 | (abbrev-symbol "a-e-t" ert-test-abbrevs)))) | ||
| 92 | (should (equal nil (symbol-value | ||
| 93 | (abbrev-symbol "a-e-t" ert-test-abbrevs)))) | ||
| 94 | (should (equal t (abbrev-table-empty-p ert-test-abbrevs))))) | ||
| 95 | |||
| 41 | (provide 'abbrev-tests) | 96 | (provide 'abbrev-tests) |
| 42 | 97 | ||
| 43 | ;;; abbrev-tests.el ends here | 98 | ;;; abbrev-tests.el ends here |