summaryrefslogtreecommitdiff
path: root/test/lisp/thingatpt-tests.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-09-15 09:20:32 -0700
committerGlenn Morris <rgm@gnu.org>2018-09-15 09:20:32 -0700
commit9e79d59790809387707852e6d1b691d1bfbf2327 (patch)
treeb18125d7befbcdad78f2cafb805d0db45c030318 /test/lisp/thingatpt-tests.el
parentffbe561ee5acb0b9edc5f4c995c287fb2485c315 (diff)
parente133b630625d6e5791c8b491c1cf3252cdb97080 (diff)
downloademacs-9e79d59790809387707852e6d1b691d1bfbf2327.tar.gz
Merge from origin/emacs-26
e133b63 (origin/emacs-26) Avoid adverse side effects of fixing bug#21824 cc8f334 Document changes called out in NEWS 20ecc52 ; * etc/NEWS: Document recent change in 'thing-at-point'. 1fc5283 ; INSTALL: Fix a typo in the last commit. 24f240d Tiny doc updates re yum/dnf etc 41c2d25 Remove unused variable 1e3b3fa Fix (thing-at-point 'list) regression (Bug#31772) 219893a Clarify meaning of '*' 41cdda2 * etc/PROBLEMS: Document Ubuntu 16.04 issue. 1c22f03 Increase default value for imenu-auto-rescan-maxout ee84389 Improve recent change to ELisp manual ff374e4 * doc/lispref/display.texi (SVG Images): Improve wording. 3a0caf6 * doc/lispref/display.texi (SVG Images): Fix a typo. (Bug#32... Conflicts: doc/lispref/lists.texi etc/NEWS
Diffstat (limited to 'test/lisp/thingatpt-tests.el')
-rw-r--r--test/lisp/thingatpt-tests.el72
1 files changed, 37 insertions, 35 deletions
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el
index b4a5fd90ce4..aa29924ac1a 100644
--- a/test/lisp/thingatpt-tests.el
+++ b/test/lisp/thingatpt-tests.el
@@ -87,41 +87,43 @@ position to retrieve THING.")
(goto-char (nth 1 test))
(should (equal (thing-at-point (nth 2 test)) (nth 3 test))))))
-;; These tests reflect the actual behavior of
-;; `thing-at-point-bounds-of-list-at-point'.
-(ert-deftest thing-at-point-bug24627 ()
- "Test for https://debbugs.gnu.org/24627 ."
- (let ((string-result '(("(a \"b\" c)" . (a "b" c))
- (";(a \"b\" c)")
- ("(a \"b\" c\n)" . (a "b" c))
- ("\"(a b c)\"")
- ("(a ;(b c d)\ne)" . (a e))
- ("(foo\n(a ;(b c d)\ne) bar)" . (a e))
- ("(foo\na ;(b c d)\ne bar)" . (foo a e bar))
- ("(foo\n(a \"(b c d)\"\ne) bar)" . (a "(b c d)" e))
- ("(b\n(a ;(foo c d)\ne) bar)" . (a e))
- ("(princ \"(a b c)\")" . (princ "(a b c)"))
- ("(defun foo ()\n \"Test function.\"\n ;;(a b)\n nil)" . (defun foo nil "Test function." nil))))
- (file
- (expand-file-name "lisp/thingatpt.el" source-directory))
- buf)
- ;; Test for `thing-at-point'.
- (when (file-exists-p file)
- (unwind-protect
- (progn
- (setq buf (find-file file))
- (goto-char (point-max))
- (forward-line -1)
- (should-not (thing-at-point 'list)))
- (kill-buffer buf)))
- ;; Tests for `list-at-point'.
- (dolist (str-res string-result)
- (with-temp-buffer
- (emacs-lisp-mode)
- (insert (car str-res))
- (re-search-backward "\\((a\\|^a\\)")
- (should (equal (list-at-point)
- (cdr str-res)))))))
+;; See bug#24627 and bug#31772.
+(ert-deftest thing-at-point-bounds-of-list-at-point ()
+ (cl-macrolet ((with-test-buffer (str &rest body)
+ `(with-temp-buffer
+ (emacs-lisp-mode)
+ (insert ,str)
+ (search-backward "|")
+ (delete-char 1)
+ ,@body)))
+ (let ((tests1
+ '(("|(a \"b\" c)" (a "b" c))
+ (";|(a \"b\" c)" (a "b" c) nil)
+ ("|(a \"b\" c\n)" (a "b" c))
+ ("\"|(a b c)\"" (a b c) nil)
+ ("|(a ;(b c d)\ne)" (a e))
+ ("(foo\n|(a ;(b c d)\ne) bar)" (foo (a e) bar))
+ ("(foo\n|a ;(b c d)\ne bar)" (foo a e bar))
+ ("(foo\n|(a \"(b c d)\"\ne) bar)" (foo (a "(b c d)" e) bar))
+ ("(b\n|(a ;(foo c d)\ne) bar)" (b (a e) bar))
+ ("(princ \"|(a b c)\")" (a b c) (princ "(a b c)"))
+ ("(defun foo ()\n \"Test function.\"\n ;;|(a b)\n nil)"
+ (defun foo nil "Test function." nil)
+ (defun foo nil "Test function." nil))))
+ (tests2
+ '(("|list-at-point" . "list-at-point")
+ ("list-|at-point" . "list-at-point")
+ ("list-at-point|" . nil)
+ ("|(a b c)" . "(a b c)")
+ ("(a b c)|" . nil))))
+ (dolist (test tests1)
+ (with-test-buffer (car test)
+ (should (equal (list-at-point) (cl-second test)))
+ (when (cddr test)
+ (should (equal (list-at-point t) (cl-third test))))))
+ (dolist (test tests2)
+ (with-test-buffer (car test)
+ (should (equal (thing-at-point 'list) (cdr test))))))))
(ert-deftest thing-at-point-url-in-comment ()
(with-temp-buffer