]> code.delx.au - gnu-emacs/blob - test/lisp/jit-lock-tests.el
26b97998a2c38d7b1b209a98ac9ee3f39d9a38f7
[gnu-emacs] / test / lisp / jit-lock-tests.el
1 ;;; jit-lock-tests.el --- tests for jit-lock
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; Author: Dmitry Gutov <dgutov@yandex.ru>
6
7 ;; This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22 ;;; Commentary:
23
24 ;;; Code:
25
26 (require 'jit-lock)
27 (require 'ert-x)
28
29 (defun jit-lock-tests--setup-buffer ()
30 (setq font-lock-defaults '(nil t))
31 (font-lock-mode))
32
33 (ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer ()
34 (ert-with-test-buffer (:name "xxx")
35 (jit-lock-tests--setup-buffer)
36 (insert "xyz")
37 (jit-lock-fontify-now (point-min) (point-max))
38 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
39
40 (ert-deftest jit-lock-fontify-mends-the-gaps ()
41 (ert-with-test-buffer (:name "xxx")
42 (jit-lock-tests--setup-buffer)
43 (insert "aaabbbcccddd")
44 (with-silent-modifications
45 (put-text-property 1 4 'fontified t)
46 (put-text-property 7 10 'fontified t))
47 (jit-lock-fontify-now (point-min) (point-max))
48 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
49
50 (ert-deftest jit-lock-does-not-refontify-unnecessarily ()
51 (ert-with-test-buffer (:name "xxx")
52 (setq font-lock-defaults
53 (list '(((lambda () (error "Don't call me")))) t))
54 (font-lock-mode)
55 (insert "aaa")
56 (with-silent-modifications
57 (put-text-property (point-min) (point-max) 'fontified t))
58 (jit-lock-fontify-now (point-min) (point-max))))