]> code.delx.au - gnu-emacs/blob - test/lisp/abbrev-tests.el
Rename all test files to reflect source layout.
[gnu-emacs] / test / lisp / abbrev-tests.el
1 ;;; abbrev-tests.el --- Test suite for abbrevs -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5 ;; Author: Eli Zaretskii <eliz@gnu.org>
6 ;; Keywords: abbrevs
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
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/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (require 'ert)
28 (require 'abbrev)
29
30 (ert-deftest abbrev-table-p-test ()
31 (should-not (abbrev-table-p 42))
32 (should-not (abbrev-table-p "aoeu"))
33 (should-not (abbrev-table-p '()))
34 (should-not (abbrev-table-p []))
35 ;; Missing :abbrev-table-modiff counter:
36 (should-not (abbrev-table-p (obarray-make)))
37 (let* ((table (obarray-make)))
38 (abbrev-table-put table :abbrev-table-modiff 42)
39 (should (abbrev-table-p table))))
40
41 (ert-deftest abbrev-make-abbrev-table-test ()
42 ;; Table without properties:
43 (let ((table (make-abbrev-table)))
44 (should (abbrev-table-p table))
45 (should (= (length table) obarray-default-size)))
46 ;; Table with one property 'foo with value 'bar:
47 (let ((table (make-abbrev-table '(foo bar))))
48 (should (abbrev-table-p table))
49 (should (= (length table) obarray-default-size))
50 (should (eq (abbrev-table-get table 'foo) 'bar))))
51
52 (ert-deftest abbrev-table-get-put-test ()
53 (let ((table (make-abbrev-table)))
54 (should-not (abbrev-table-get table 'foo))
55 (should (= (abbrev-table-put table 'foo 42) 42))
56 (should (= (abbrev-table-get table 'foo) 42))
57 (should (eq (abbrev-table-put table 'foo 'bar) 'bar))
58 (should (eq (abbrev-table-get table 'foo) 'bar))))
59
60 (ert-deftest copy-abbrev-table-test ()
61 (defvar foo-abbrev-table nil) ; Avoid compiler warning
62 (define-abbrev-table 'foo-abbrev-table
63 '())
64 (should (abbrev-table-p foo-abbrev-table))
65 ;; Bug 21828
66 (let ((new-foo-abbrev-table
67 (condition-case nil
68 (copy-abbrev-table foo-abbrev-table)
69 (error nil))))
70 (should (abbrev-table-p new-foo-abbrev-table)))
71 (should-not (string-equal (buffer-name) "*Backtrace*")))
72
73 (provide 'abbrev-tests)
74 ;;; abbrev-tests.el ends here