1 ;;; abbrev-tests.el --- Test suite for abbrevs -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
5 ;; Author: Eli Zaretskii <eliz@gnu.org>
8 ;; This file is part of GNU Emacs.
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.
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.
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/>.
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))))
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))))
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))))
60 (ert-deftest copy-abbrev-table-test ()
61 (defvar foo-abbrev-table nil) ; Avoid compiler warning
62 (define-abbrev-table 'foo-abbrev-table
64 (should (abbrev-table-p foo-abbrev-table))
66 (let ((new-foo-abbrev-table
68 (copy-abbrev-table foo-abbrev-table)
70 (should (abbrev-table-p new-foo-abbrev-table)))
71 (should-not (string-equal (buffer-name) "*Backtrace*")))
73 (provide 'abbrev-tests)
74 ;;; abbrev-tests.el ends here