annotate test/redisplay-testsuite.el @ 108079:216b6ef76da7

Support `display' text properties and overlays. xdisp.c (pop_it): When the stack is popped after displaying from a string, bidi-iterate to exit from the text portion covered by the `display' property or overlay. (Bug#5988, bug#5920)
author Eli Zaretskii <eliz@gnu.org>
date Fri, 23 Apr 2010 18:05:23 +0300
parents 1d1d5d9bd884
children b262a4f49bf3 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
103698
01395a3c52c8 Fix comment.
Juri Linkov <juri@jurta.org>
parents: 103689
diff changeset
1 ;;; redisplay-testsuite.el --- Test suite for redisplay.
103593
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 103698
diff changeset
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
103593
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Chong Yidong <cyd@stupidchicken.com>
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Keywords: internal
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Human-Keywords: internal
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; (at your option) any later version.
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Type M-x test-redisplay RET to generate the test buffer.
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;; Code:
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 (defun test-insert-overlay (text &rest props)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 (let ((opoint (point))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 overlay)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 (insert text)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 (setq overlay (make-overlay opoint (point)))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 (while props
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (overlay-put overlay (car props) (cadr props))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 (setq props (cddr props)))))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (defun test-redisplay-1 ()
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (insert "Test 1: Displaying adjacent and overlapping overlays:\n\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (insert " Expected: gnu emacs\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (insert " Results: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (test-insert-overlay "n" 'before-string "g" 'after-string "u ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (test-insert-overlay "ma" 'before-string "e" 'after-string "cs")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (insert "\n\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 (insert " Expected: gnu emacs\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (insert " Results: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (test-insert-overlay "u" 'before-string "gn")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (test-insert-overlay "ma" 'before-string " e" 'after-string "cs")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (insert "\n\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (insert " Expected: gnu emacs\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (insert " Results: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 (test-insert-overlay "XXX" 'display "u "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 'before-string "gn" 'after-string "em")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (test-insert-overlay "a" 'after-string "cs")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (insert "\n\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (insert " Expected: gnu emacs\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (insert " Results: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (test-insert-overlay "u " 'before-string "gn" 'after-string "em")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (test-insert-overlay "XXX" 'display "a" 'after-string "cs")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (insert "\n\n"))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 (defun test-redisplay-2 ()
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (insert "Test 2: Mouse highlighting. Move your mouse over the letters XXX:\n\n")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 (insert " Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (propertize "xxxXXXxxx" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 "...---...\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 (test-insert-overlay "XXX" 'before-string "xxx" 'after-string "xxx"
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 'mouse-face 'highlight )
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (test-insert-overlay "---" 'before-string "..." 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 (propertize "xxxXXX" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 "...---...\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 (test-insert-overlay "XXX" 'before-string "xxx" 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (test-insert-overlay "---" 'before-string "..." 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (propertize "XXX" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 "...---...\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (test-insert-overlay "..." 'display "XXX" 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (test-insert-overlay "---" 'before-string "..." 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (propertize "XXXxxx" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "...\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (test-insert-overlay "..." 'display "XXX" 'after-string "xxx"
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (test-insert-overlay "error" 'display "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 "---..."
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (propertize "xxxXXX" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 "\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (test-insert-overlay "xxx" 'display "---" 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (test-insert-overlay "error" 'before-string "xxx" 'display "XXX"
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 "...---..."
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (propertize "xxxXXXxxx" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 "\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (test-insert-overlay "---" 'before-string "..." 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (test-insert-overlay "XXX" 'before-string "xxx" 'after-string "xxx"
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 "..."
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (propertize "XXX" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 "...\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (test-insert-overlay "---"
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 'display (propertize "XXX" 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 'before-string "..."
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 'after-string "...")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (insert "\n\n Expected: "
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (propertize "XXX\n" 'face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 "\n Test: ")
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (test-insert-overlay "XXX\n" 'mouse-face 'highlight)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (insert "\n"))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (defun test-redisplay ()
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (interactive)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (pop-to-buffer (generate-new-buffer "*Redisplay Test*"))
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (test-redisplay-1)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (test-redisplay-2)
3acb65a2fdd5 * redisplay-testsuite.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (goto-char (point-min)))
103689
3666f62113ed Add arch tagline
Miles Bader <miles@gnu.org>
parents: 103593
diff changeset
121
3666f62113ed Add arch tagline
Miles Bader <miles@gnu.org>
parents: 103593
diff changeset
122 ;; arch-tag: fcee53c8-024f-403d-9154-61ae3ce0bfb8