aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-09-24 13:23:20 +0300
committerEli Zaretskii2016-09-24 13:23:20 +0300
commit0123d567384fd69c137fcecc181dbb5a65e043b4 (patch)
tree6517ad90c08be0fe8135b2f498773ef916514f62 /test/src
parent7f287b7f780849ca32cddaf69dac83a435f92300 (diff)
downloademacs-0123d567384fd69c137fcecc181dbb5a65e043b4.tar.gz
emacs-0123d567384fd69c137fcecc181dbb5a65e043b4.zip
; * Move test/lisp/legacy/textprop-tests.el to test/src/.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/textprop-tests.el69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/src/textprop-tests.el b/test/src/textprop-tests.el
new file mode 100644
index 00000000000..397ef28c035
--- /dev/null
+++ b/test/src/textprop-tests.el
@@ -0,0 +1,69 @@
1;;; textprop-tests.el --- Test suite for text properties.
2
3;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
4
5;; Author: Wolfgang Jenkner <wjenkner@inode.at>
6;; Keywords: internal
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;;; Code:
24
25(require 'ert)
26
27(ert-deftest textprop-tests-format ()
28 "Test `format' with text properties."
29 ;; See Bug#21351.
30 (should (equal-including-properties
31 (format #("mouse-1, RET: %s -- w: copy %s"
32 12 20 (face minibuffer-prompt)
33 21 30 (face minibuffer-prompt))
34 "visit" "link")
35 #("mouse-1, RET: visit -- w: copy link"
36 12 23 (face minibuffer-prompt)
37 24 35 (face minibuffer-prompt)))))
38
39(ert-deftest textprop-tests-font-lock--remove-face-from-text-property ()
40 "Test `font-lock--remove-face-from-text-property'."
41 (let* ((string "foobar")
42 (stack (list string))
43 (faces '(bold (:foreground "red") underline)))
44 ;; Build each string in `stack' by adding a face to the previous
45 ;; string.
46 (let ((faces (reverse faces)))
47 (push (copy-sequence (car stack)) stack)
48 (put-text-property 0 3 'font-lock-face (pop faces) (car stack))
49 (push (copy-sequence (car stack)) stack)
50 (put-text-property 3 6 'font-lock-face (pop faces) (car stack))
51 (push (copy-sequence (car stack)) stack)
52 (font-lock-prepend-text-property 2 5
53 'font-lock-face (pop faces) (car stack)))
54 ;; Check that removing the corresponding face from each string
55 ;; yields the previous string in `stack'.
56 (while faces
57 ;; (message "%S" (car stack))
58 (should (equal-including-properties
59 (progn
60 (font-lock--remove-face-from-text-property 0 6
61 'font-lock-face
62 (pop faces)
63 (car stack))
64 (pop stack))
65 (car stack))))
66 ;; Sanity check.
67 ;; (message "%S" (car stack))
68 (should (and (equal-including-properties (pop stack) string)
69 (null stack)))))