diff options
| author | Dmitry Gutov | 2016-05-08 02:00:25 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2016-05-08 02:00:25 +0300 |
| commit | 950c9a5d4a1cc09b8171b41fa7e1b2647fa98514 (patch) | |
| tree | 3f515559efe54c1602033895f4640c4498c1e27d | |
| parent | 97776f295d652aff97be91431ad53db5618ad2a2 (diff) | |
| download | emacs-950c9a5d4a1cc09b8171b41fa7e1b2647fa98514.tar.gz emacs-950c9a5d4a1cc09b8171b41fa7e1b2647fa98514.zip | |
* test/lisp/jit-lock-tests.el: New file.
| -rw-r--r-- | test/lisp/jit-lock-tests.el | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/lisp/jit-lock-tests.el b/test/lisp/jit-lock-tests.el new file mode 100644 index 00000000000..26b97998a2c --- /dev/null +++ b/test/lisp/jit-lock-tests.el | |||
| @@ -0,0 +1,58 @@ | |||
| 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)))) | ||