aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoah Friedman2015-08-17 13:00:36 -0700
committerNoah Friedman2015-08-17 13:00:36 -0700
commita84225d29c40a8cf3f860d2b58517102eef33436 (patch)
tree8c26150075a37ad5c141d0c5c7aa08eee9749814 /test
parentb892438d7a424e61f174d8b8a57e78077aa96a0c (diff)
parent62f65abf279da30e6fff4bcf3462b548aeb2dc97 (diff)
downloademacs-a84225d29c40a8cf3f860d2b58517102eef33436.tar.gz
emacs-a84225d29c40a8cf3f860d2b58517102eef33436.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
-rw-r--r--test/automated/elisp-mode-tests.el431
-rw-r--r--test/automated/ert-tests.el4
-rw-r--r--test/automated/seq-tests.el7
-rw-r--r--test/redisplay-testsuite.el40
4 files changed, 463 insertions, 19 deletions
diff --git a/test/automated/elisp-mode-tests.el b/test/automated/elisp-mode-tests.el
index 2581de46931..64b3f665a03 100644
--- a/test/automated/elisp-mode-tests.el
+++ b/test/automated/elisp-mode-tests.el
@@ -3,6 +3,7 @@
3;; Copyright (C) 2015 Free Software Foundation, Inc. 3;; Copyright (C) 2015 Free Software Foundation, Inc.
4 4
5;; Author: Dmitry Gutov <dgutov@yandex.ru> 5;; Author: Dmitry Gutov <dgutov@yandex.ru>
6;; Author: Stephen Leake <stephen_leake@member.fsf.org>
6 7
7;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
8 9
@@ -113,26 +114,420 @@
113 (should (member "backup-buffer" comps)) 114 (should (member "backup-buffer" comps))
114 (should-not (member "backup-inhibited" comps))))) 115 (should-not (member "backup-inhibited" comps)))))
115 116
116;;; Navigation 117;;; xref
117 118
118(ert-deftest elisp-xref-finds-both-function-and-variable () 119(defun xref-elisp-test-descr-to-target (xref)
119 ;; "system-name" is both: a variable and a function 120 "Return an appropriate `looking-at' match string for XREF."
120 (let ((defs (elisp-xref-find 'definitions "system-name"))) 121 (let* ((loc (xref-item-location xref))
121 (should (= (length defs) 2)) 122 (type (or (xref-elisp-location-type loc)
122 (should (string= (xref-item-summary (nth 0 defs)) 123 'defun)))
123 "(defun system-name)")) 124
124 (should (string= (xref-item-summary (nth 1 defs)) 125 (cl-case type
125 "(defvar system-name)"))) 126 (defalias
127 ;; summary: "(defalias xref)"
128 ;; target : "(defalias 'xref)"
129 (concat "(defalias '" (substring (xref-item-summary xref) 10 -1)))
130
131 (defun
132 (let ((summary (xref-item-summary xref))
133 (file (xref-elisp-location-file loc)))
134 (cond
135 ((string= "c" (file-name-extension file))
136 ;; summary: "(defun buffer-live-p)"
137 ;; target : "DEFUN (buffer-live-p"
138 (concat
139 (upcase (substring summary 1 6))
140 " (\""
141 (substring summary 7 -1)
142 "\""))
143
144 (t
145 (substring summary 0 -1))
146 )))
147
148 (defvar
149 (let ((summary (xref-item-summary xref))
150 (file (xref-elisp-location-file loc)))
151 (cond
152 ((string= "c" (file-name-extension file))
153 ;; summary: "(defvar system-name)"
154 ;; target : "DEFVAR_LISP ("system-name", "
155 ;; summary: "(defvar abbrev-mode)"
156 ;; target : DEFVAR_PER_BUFFER ("abbrev-mode"
157 (concat
158 (upcase (substring summary 1 7))
159 (if (bufferp (variable-binding-locus (xref-elisp-location-symbol loc)))
160 "_PER_BUFFER (\""
161 "_LISP (\"")
162 (substring summary 8 -1)
163 "\""))
164
165 (t
166 (substring summary 0 -1))
167 )))
168
169 (feature
170 ;; summary: "(feature xref)"
171 ;; target : "(provide 'xref)"
172 (concat "(provide '" (substring (xref-item-summary xref) 9 -1)))
173
174 (otherwise
175 (substring (xref-item-summary xref) 0 -1))
176 )))
177
178
179(defun xref-elisp-test-run (xrefs expected-xrefs)
180 (should (= (length xrefs) (length expected-xrefs)))
181 (while xrefs
182 (let ((xref (pop xrefs))
183 (expected (pop expected-xrefs)))
184
185 (should (equal xref
186 (or (when (consp expected) (car expected)) expected)))
187
188 (xref--goto-location (xref-item-location xref))
189 (should (looking-at (or (when (consp expected) (cdr expected))
190 (xref-elisp-test-descr-to-target expected)))))
191 ))
192
193(defmacro xref-elisp-deftest (name computed-xrefs expected-xrefs)
194 "Define an ert test for an xref-elisp feature.
195COMPUTED-XREFS and EXPECTED-XREFS are lists of xrefs, except if
196an element of EXPECTED-XREFS is a cons (XREF . TARGET), TARGET is
197matched to the found location; otherwise, match
198to (xref-elisp-test-descr-to-target xref)."
199 (declare (indent defun)
200 (debug (symbolp "name")))
201 `(ert-deftest ,(intern (concat "xref-elisp-test-" (symbol-name name))) ()
202 (xref-elisp-test-run ,computed-xrefs ,expected-xrefs)
203 ))
204
205;; When tests are run from the Makefile, 'default-directory' is $HOME,
206;; so we must provide this dir to expand-file-name in the expected
207;; results. This also allows running these tests from other
208;; directories.
209(defconst emacs-test-dir (file-name-directory (or load-file-name (buffer-file-name))))
210
211;; alphabetical by test name
212
213;; FIXME: autoload
214
215;; FIXME: defalias-defun-c cmpl-prefix-entry-head
216;; FIXME: defalias-defvar-el allout-mode-map
217
218(xref-elisp-deftest find-defs-constructor
219 (elisp--xref-find-definitions 'xref-make-elisp-location)
220 ;; 'xref-make-elisp-location' is just a name for the default
221 ;; constructor created by the cl-defstruct, so the location is the
222 ;; cl-defstruct location.
223 (list
224 (cons
225 (xref-make "(cl-defstruct (xref-elisp-location (:constructor xref-make-elisp-location)))"
226 (xref-make-elisp-location
227 'xref-elisp-location 'define-type
228 (expand-file-name "../../lisp/progmodes/elisp-mode.el" emacs-test-dir)))
229 ;; It's not worth adding another special case to `xref-elisp-test-descr-to-target' for this
230 "(cl-defstruct (xref-elisp-location")
231 ))
232
233(xref-elisp-deftest find-defs-defalias-defun-el
234 (elisp--xref-find-definitions 'Buffer-menu-sort)
235 (list
236 (xref-make "(defalias Buffer-menu-sort)"
237 (xref-make-elisp-location
238 'Buffer-menu-sort 'defalias
239 (expand-file-name "../../lisp/buff-menu.elc" emacs-test-dir)))
240 (xref-make "(defun tabulated-list-sort)"
241 (xref-make-elisp-location
242 'tabulated-list-sort nil
243 (expand-file-name "../../lisp/emacs-lisp/tabulated-list.el" emacs-test-dir)))
244 ))
245
246;; FIXME: defconst
247
248;; FIXME: eieio defclass
249
250;; Possible ways of defining the default method implementation for a
251;; generic function. We declare these here, so we know we cover all
252;; cases, and we don't rely on other code not changing.
253;;
254;; When the generic and default method are declared in the same place,
255;; elisp--xref-find-definitions only returns one.
256
257(cl-defstruct (xref-elisp-root-type)
258 slot-1)
259
260(cl-defgeneric xref-elisp-generic-no-methods ()
261 "doc string no-methods"
262 ;; No default implementation, no methods, but fboundp is true for
263 ;; this symbol; it calls cl-no-applicable-method
264 )
265
266(cl-defmethod xref-elisp-generic-no-default ((this xref-elisp-root-type))
267 "doc string no-default xref-elisp-root-type"
268 "non-default for no-default")
269
270;; defgeneric after defmethod in file to ensure the fallback search
271;; method of just looking for the function name will fail.
272(cl-defgeneric xref-elisp-generic-no-default ()
273 "doc string no-default generic"
274 ;; No default implementation; this function calls the cl-generic
275 ;; dispatching code.
276 )
277
278(cl-defgeneric xref-elisp-generic-co-located-default ()
279 "doc string co-located-default generic"
280 "co-located default")
281
282(cl-defmethod xref-elisp-generic-co-located-default ((this xref-elisp-root-type))
283 "doc string co-located-default xref-elisp-root-type"
284 "non-default for co-located-default")
285
286(cl-defgeneric xref-elisp-generic-separate-default ()
287 "doc string separate-default generic"
288 ;; default implementation provided separately
289 )
290
291(cl-defmethod xref-elisp-generic-separate-default ()
292 "doc string separate-default default"
293 "separate default")
294
295(cl-defmethod xref-elisp-generic-separate-default ((this xref-elisp-root-type))
296 "doc string separate-default xref-elisp-root-type"
297 "non-default for separate-default")
298
299(cl-defmethod xref-elisp-generic-implicit-generic ()
300 "doc string implicit-generic default"
301 "default for implicit generic")
302
303(cl-defmethod xref-elisp-generic-implicit-generic ((this xref-elisp-root-type))
304 "doc string implicit-generic xref-elisp-root-type"
305 "non-default for implicit generic")
306
307
308(xref-elisp-deftest find-defs-defgeneric-no-methods
309 (elisp--xref-find-definitions 'xref-elisp-generic-no-methods)
310 (list
311 (xref-make "(cl-defgeneric xref-elisp-generic-no-methods)"
312 (xref-make-elisp-location
313 'xref-elisp-generic-no-methods 'cl-defgeneric
314 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
315 ))
316
317(xref-elisp-deftest find-defs-defgeneric-no-default
318 (elisp--xref-find-definitions 'xref-elisp-generic-no-default)
319 (list
320 (xref-make "(cl-defgeneric xref-elisp-generic-no-default)"
321 (xref-make-elisp-location
322 'xref-elisp-generic-no-default 'cl-defgeneric
323 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
324 (xref-make "(cl-defmethod xref-elisp-generic-no-default ((this xref-elisp-root-type)))"
325 (xref-make-elisp-location
326 '(xref-elisp-generic-no-default xref-elisp-root-type) 'cl-defmethod
327 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
328 ))
329
330(xref-elisp-deftest find-defs-defgeneric-co-located-default
331 (elisp--xref-find-definitions 'xref-elisp-generic-co-located-default)
332 (list
333 (xref-make "(cl-defgeneric xref-elisp-generic-co-located-default)"
334 (xref-make-elisp-location
335 'xref-elisp-generic-co-located-default 'cl-defgeneric
336 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
337 (xref-make "(cl-defmethod xref-elisp-generic-co-located-default ((this xref-elisp-root-type)))"
338 (xref-make-elisp-location
339 '(xref-elisp-generic-co-located-default xref-elisp-root-type) 'cl-defmethod
340 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
341 ))
342
343(xref-elisp-deftest find-defs-defgeneric-separate-default
344 (elisp--xref-find-definitions 'xref-elisp-generic-separate-default)
345 (list
346 (xref-make "(cl-defgeneric xref-elisp-generic-separate-default)"
347 (xref-make-elisp-location
348 'xref-elisp-generic-separate-default 'cl-defgeneric
349 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
350 (xref-make "(cl-defmethod xref-elisp-generic-separate-default ())"
351 (xref-make-elisp-location
352 '(xref-elisp-generic-separate-default) 'cl-defmethod
353 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
354
355 (xref-make "(cl-defmethod xref-elisp-generic-separate-default ((this xref-elisp-root-type)))"
356 (xref-make-elisp-location
357 '(xref-elisp-generic-separate-default xref-elisp-root-type) 'cl-defmethod
358 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
359 ))
360
361(xref-elisp-deftest find-defs-defgeneric-implicit-generic
362 (elisp--xref-find-definitions 'xref-elisp-generic-implicit-generic)
363 (list
364 (xref-make "(cl-defmethod xref-elisp-generic-implicit-generic ())"
365 (xref-make-elisp-location
366 '(xref-elisp-generic-implicit-generic) 'cl-defmethod
367 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
368 (xref-make "(cl-defmethod xref-elisp-generic-implicit-generic ((this xref-elisp-root-type)))"
369 (xref-make-elisp-location
370 '(xref-elisp-generic-implicit-generic xref-elisp-root-type) 'cl-defmethod
371 (expand-file-name "elisp-mode-tests.el" emacs-test-dir)))
372 ))
373
374;; Test that we handle more than one method
375
376;; When run from the Makefile, etags is not loaded at compile time,
377;; but it is by the time this test is run. interactively; don't fail
378;; for that.
379(require 'etags)
380(xref-elisp-deftest find-defs-defgeneric-el
381 (elisp--xref-find-definitions 'xref-location-marker)
382 (list
383 (xref-make "(cl-defgeneric xref-location-marker)"
384 (xref-make-elisp-location
385 'xref-location-marker 'cl-defgeneric
386 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
387 (xref-make "(cl-defmethod xref-location-marker ((l xref-elisp-location)))"
388 (xref-make-elisp-location
389 '(xref-location-marker xref-elisp-location) 'cl-defmethod
390 (expand-file-name "../../lisp/progmodes/elisp-mode.el" emacs-test-dir)))
391 (xref-make "(cl-defmethod xref-location-marker ((l xref-file-location)))"
392 (xref-make-elisp-location
393 '(xref-location-marker xref-file-location) 'cl-defmethod
394 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
395 (xref-make "(cl-defmethod xref-location-marker ((l xref-buffer-location)))"
396 (xref-make-elisp-location
397 '(xref-location-marker xref-buffer-location) 'cl-defmethod
398 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
399 (xref-make "(cl-defmethod xref-location-marker ((l xref-bogus-location)))"
400 (xref-make-elisp-location
401 '(xref-location-marker xref-bogus-location) 'cl-defmethod
402 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
403 (xref-make "(cl-defmethod xref-location-marker ((l xref-etags-location)))"
404 (xref-make-elisp-location
405 '(xref-location-marker xref-etags-location) 'cl-defmethod
406 (expand-file-name "../../lisp/progmodes/etags.el" emacs-test-dir)))
407 ))
408
409(xref-elisp-deftest find-defs-defgeneric-eval
410 (elisp--xref-find-definitions (eval '(cl-defgeneric stephe-leake-cl-defgeneric ())))
411 nil)
412
413(xref-elisp-deftest find-defs-defun-el
414 (elisp--xref-find-definitions 'xref-find-definitions)
415 (list
416 (xref-make "(defun xref-find-definitions)"
417 (xref-make-elisp-location
418 'xref-find-definitions nil
419 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))))
420
421(xref-elisp-deftest find-defs-defun-eval
422 (elisp--xref-find-definitions (eval '(defun stephe-leake-defun ())))
423 nil)
424
425(xref-elisp-deftest find-defs-defun-c
426 (elisp--xref-find-definitions 'buffer-live-p)
427 (list
428 (xref-make "(defun buffer-live-p)"
429 (xref-make-elisp-location 'buffer-live-p nil "src/buffer.c"))))
430
431;; FIXME: deftype
432
433(xref-elisp-deftest find-defs-defun-c-defvar-c
434 (elisp-xref-find 'definitions "system-name")
435 (list
436 (xref-make "(defvar system-name)"
437 (xref-make-elisp-location 'system-name 'defvar "src/editfns.c"))
438 (xref-make "(defun system-name)"
439 (xref-make-elisp-location 'system-name nil "src/editfns.c")))
440 )
441
442(xref-elisp-deftest find-defs-defun-el-defvar-c
443 (elisp-xref-find 'definitions "abbrev-mode")
126 ;; It's a minor mode, but the variable is defined in buffer.c 444 ;; It's a minor mode, but the variable is defined in buffer.c
127 (let ((defs (elisp-xref-find 'definitions "abbrev-mode"))) 445 (list
128 (should (= (length defs) 2)))) 446 (xref-make "(defvar abbrev-mode)"
129 447 (xref-make-elisp-location 'abbrev-mode 'defvar "src/buffer.c"))
130(ert-deftest elisp-xref-finds-only-function-for-minor-mode () 448 (cons
131 ;; Both variable and function are defined in the same place. 449 (xref-make "(defun abbrev-mode)"
132 (let ((defs (elisp-xref-find 'definitions "visible-mode"))) 450 (xref-make-elisp-location
133 (should (= (length defs) 1)) 451 'abbrev-mode nil
134 (should (string= (xref-item-summary (nth 0 defs)) 452 (expand-file-name "../../lisp/abbrev.el" emacs-test-dir)))
135 "(defun visible-mode)")))) 453 "(define-minor-mode abbrev-mode"))
454 )
455
456;; Source for both variable and defun is "(define-minor-mode
457;; compilation-minor-mode". There is no way to tell that directly from
458;; the symbol, but we can use (memq sym minor-mode-list) to detect
459;; that the symbol is a minor mode. See `elisp--xref-find-definitions'
460;; for more comments.
461;;
462;; IMPROVEME: return defvar instead of defun if source near starting
463;; point indicates the user is searching for a variable, not a
464;; function.
465(require 'compile) ;; not loaded by default at test time
466(xref-elisp-deftest find-defs-defun-defvar-el
467 (elisp--xref-find-definitions 'compilation-minor-mode)
468 (list
469 (cons
470 (xref-make "(defun compilation-minor-mode)"
471 (xref-make-elisp-location
472 'compilation-minor-mode nil
473 (expand-file-name "../../lisp/progmodes/compile.el" emacs-test-dir)))
474 "(define-minor-mode compilation-minor-mode")
475 ))
476
477(xref-elisp-deftest find-defs-defvar-el
478 (elisp--xref-find-definitions 'xref--marker-ring)
479 (list
480 (xref-make "(defvar xref--marker-ring)"
481 (xref-make-elisp-location
482 'xref--marker-ring 'defvar
483 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
484 ))
485
486(xref-elisp-deftest find-defs-defvar-c
487 (elisp--xref-find-definitions 'default-directory)
488 (list
489 (cons
490 (xref-make "(defvar default-directory)"
491 (xref-make-elisp-location 'default-directory 'defvar "src/buffer.c"))
492 ;; IMPROVEME: we might be able to compute this target
493 "DEFVAR_PER_BUFFER (\"default-directory\"")))
494
495(xref-elisp-deftest find-defs-defvar-eval
496 (elisp--xref-find-definitions (eval '(defvar stephe-leake-defvar nil)))
497 nil)
498
499(xref-elisp-deftest find-defs-face-el
500 (elisp--xref-find-definitions 'font-lock-keyword-face)
501 ;; 'font-lock-keyword-face is both a face and a var
502 (list
503 (xref-make "(defvar font-lock-keyword-face)"
504 (xref-make-elisp-location
505 'font-lock-keyword-face 'defvar
506 (expand-file-name "../../lisp/font-lock.el" emacs-test-dir)))
507 (xref-make "(defface font-lock-keyword-face)"
508 (xref-make-elisp-location
509 'font-lock-keyword-face 'defface
510 (expand-file-name "../../lisp/font-lock.el" emacs-test-dir)))
511 ))
512
513(xref-elisp-deftest find-defs-face-eval
514 (elisp--xref-find-definitions (eval '(defface stephe-leake-defface nil "")))
515 nil)
516
517(xref-elisp-deftest find-defs-feature-el
518 (elisp--xref-find-definitions 'xref)
519 (list
520 (cons
521 (xref-make "(feature xref)"
522 (xref-make-elisp-location
523 'xref 'feature
524 (expand-file-name "../../lisp/progmodes/xref.el" emacs-test-dir)))
525 ";;; Code:")
526 ))
527
528(xref-elisp-deftest find-defs-feature-eval
529 (elisp--xref-find-definitions (eval '(provide 'stephe-leake-feature)))
530 nil)
136 531
137(provide 'elisp-mode-tests) 532(provide 'elisp-mode-tests)
138;;; elisp-mode-tests.el ends here 533;;; elisp-mode-tests.el ends here
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el
index fcfc7ee4823..5382c400962 100644
--- a/test/automated/ert-tests.el
+++ b/test/automated/ert-tests.el
@@ -345,6 +345,10 @@ This macro is used to test if macroexpansion in `should' works."
345 (should (equal actual-condition expected-condition))))))) 345 (should (equal actual-condition expected-condition)))))))
346 346
347(ert-deftest ert-test-deftest () 347(ert-deftest ert-test-deftest ()
348 ;; FIXME: These tests don't look very good. What is their intent, i.e. what
349 ;; are they really testing? The precise generated code shouldn't matter, so
350 ;; we should either test the behavior of the code, or else try to express the
351 ;; kind of efficiency guarantees we're looking for.
348 (should (equal (macroexpand '(ert-deftest abc () "foo" :tags '(bar))) 352 (should (equal (macroexpand '(ert-deftest abc () "foo" :tags '(bar)))
349 '(progn 353 '(progn
350 (ert-set-test 'abc 354 (ert-set-test 'abc
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index 3643ce53cb0..74c0700759e 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -187,7 +187,12 @@ Evaluate BODY for each created sequence.
187 (should-not (seq-subseq '(1 2 3) 3)) 187 (should-not (seq-subseq '(1 2 3) 3))
188 (should (seq-subseq '(1 2 3) -3)) 188 (should (seq-subseq '(1 2 3) -3))
189 (should-error (seq-subseq '(1 2 3) 1 4)) 189 (should-error (seq-subseq '(1 2 3) 1 4))
190 (should (seq-subseq '(1 2 3) 1 3))) 190 (should (seq-subseq '(1 2 3) 1 3))
191 (should-error (seq-subseq '() -1))
192 (should-error (seq-subseq [] -1))
193 (should-error (seq-subseq "" -1))
194 (should-not (seq-subseq '() 0))
195 (should-error(seq-subseq '() 0 -1)))
191 196
192(ert-deftest test-seq-concatenate () 197(ert-deftest test-seq-concatenate ()
193 (with-test-sequences (seq '(2 4 6)) 198 (with-test-sequences (seq '(2 4 6))
diff --git a/test/redisplay-testsuite.el b/test/redisplay-testsuite.el
index 357ab08bf84..332eeb1cc9f 100644
--- a/test/redisplay-testsuite.el
+++ b/test/redisplay-testsuite.el
@@ -251,6 +251,45 @@ static unsigned char x_bits[] = {0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xbd, 0x81, 0xff
251 (str "ABC")) 251 (str "ABC"))
252 (put-text-property 1 2 'invisible 'test-redisplay--ellipsis-invis str) 252 (put-text-property 1 2 'invisible 'test-redisplay--ellipsis-invis str)
253 (overlay-put ov 'display str))) 253 (overlay-put ov 'display str)))
254 ;; Overlay string over invisible text and non-default face.
255 (insert "\n Expected: ..." (propertize "ABC" 'face 'highlight) "XYZ")
256 (insert "\n Result: ")
257 (insert (propertize "foo" 'invisible 'test-redisplay--ellipsis-invis))
258 (let ((ov (make-overlay (point) (point))))
259 (overlay-put ov 'invisible t)
260 (overlay-put ov 'window (selected-window))
261 (overlay-put ov 'after-string
262 (propertize "ABC" 'face 'highlight)))
263 (insert "XYZ\n")
264 ;; Overlay strings with partial `invisibility' property and with a
265 ;; display property on the before-string.
266 (insert "\n Expected: ..."
267 (propertize "DEF" 'display '(image :type xpm :file "close.xpm"))
268 (propertize "ABC" 'face 'highlight) "XYZ")
269 (insert "\n Result: ")
270 (insert (propertize "foo" 'invisible 'test-redisplay--ellipsis-invis))
271 (let ((ov (make-overlay (point) (point))))
272 (overlay-put ov 'invisible t)
273 (overlay-put ov 'window (selected-window))
274 (overlay-put ov 'after-string
275 (propertize "ABC" 'face 'highlight))
276 (overlay-put ov 'before-string
277 (propertize "DEF"
278 'display '(image :type xpm :file "close.xpm"))))
279 (insert "XYZ\n")
280
281 ;; Overlay string with 2 adjacent and different invisible
282 ;; properties. This caused an infloop before Emacs 25.
283 (insert "\n Expected: ABC")
284 (insert "\n Result: ")
285 (let ((opoint (point)))
286 (insert "ABC\n")
287 (let ((ov (make-overlay (1+ opoint) (+ 2 opoint)))
288 (str (concat (propertize "X"
289 'invisible 'test-redisplay--simple-invis)
290 (propertize "Y"
291 'invisible 'test-redisplay--simple-invis2))))
292 (overlay-put ov 'after-string str)))
254 293
255 (insert "\n")) 294 (insert "\n"))
256 295
@@ -264,6 +303,7 @@ static unsigned char x_bits[] = {0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xbd, 0x81, 0xff
264 (erase-buffer) 303 (erase-buffer)
265 (setq buffer-invisibility-spec 304 (setq buffer-invisibility-spec
266 '(test-redisplay--simple-invis 305 '(test-redisplay--simple-invis
306 test-redisplay--simple-invis2
267 (test-redisplay--ellipsis-invis . t))) 307 (test-redisplay--ellipsis-invis . t)))
268 (test-redisplay-1) 308 (test-redisplay-1)
269 (test-redisplay-2) 309 (test-redisplay-2)