1 ;;; elisp-mode-tests.el --- Tests for emacs-lisp-mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
5 ;; Author: Dmitry Gutov <dgutov@yandex.ru>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 (defun elisp--test-completions ()
27 (let ((data (elisp-completion-at-point)))
28 (all-completions (buffer-substring (nth 0 data
) (nth 1 data
))
30 (plist-get (nthcdr 3 data
) :predicate
))))
32 (ert-deftest elisp-completes-functions
()
36 (let ((comps (elisp--test-completions)))
37 (should (member "backup-buffer" comps
))
38 (should-not (member "backup-inhibited" comps
)))))
40 (ert-deftest elisp-completes-variables
()
44 (let ((comps (elisp--test-completions)))
45 (should (member "backup-inhibited" comps
))
46 (should-not (member "backup-buffer" comps
)))))
48 (ert-deftest elisp-completes-anything-quoted
()
49 (dolist (text '("`(foo ba" "(foo 'ba"
50 "`(,foo ba" "`,(foo `ba"
55 (let ((comps (elisp--test-completions)))
56 (should (member "backup-inhibited" comps
))
57 (should (member "backup-buffer" comps
))
58 (should (member "backup" comps
))))))
60 (ert-deftest elisp-completes-variables-unquoted
()
61 (dolist (text '("`(foo ,ba" "`(,(foo ba" "`(,ba"))
65 (let ((comps (elisp--test-completions)))
66 (should (member "backup-inhibited" comps
))
67 (should-not (member "backup-buffer" comps
))))))
69 (ert-deftest elisp-completes-functions-in-special-macros
()
70 (dolist (text '("(declare-function ba" "(cl-callf2 ba"))
74 (let ((comps (elisp--test-completions)))
75 (should (member "backup-buffer" comps
))
76 (should-not (member "backup-inhibited" comps
))))))
78 (ert-deftest elisp-completes-local-variables
()
81 (insert "(let ((bar 1) baz) (foo ba")
82 (let ((comps (elisp--test-completions)))
83 (should (member "backup-inhibited" comps
))
84 (should (member "bar" comps
))
85 (should (member "baz" comps
)))))
87 (ert-deftest elisp-completest-variables-in-let-bindings
()
88 (dolist (text '("(let (ba" "(let* ((ba"))
92 (let ((comps (elisp--test-completions)))
93 (should (member "backup-inhibited" comps
))
94 (should-not (member "backup-buffer" comps
))))))
96 (ert-deftest elisp-completes-functions-after-let-bindings
()
99 (insert "(let ((bar 1) (baz 2)) (ba")
100 (let ((comps (elisp--test-completions)))
101 (should (member "backup-buffer" comps
))
102 (should-not (member "backup-inhibited" comps
)))))
104 (provide 'elisp-mode-tests
)
105 ;;; elisp-mode-tests.el ends here