summaryrefslogtreecommitdiff
path: root/test/lisp/dabbrev-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/dabbrev-tests.el')
-rw-r--r--test/lisp/dabbrev-tests.el41
1 files changed, 35 insertions, 6 deletions
diff --git a/test/lisp/dabbrev-tests.el b/test/lisp/dabbrev-tests.el
index ca1d00ab352..278a59c015c 100644
--- a/test/lisp/dabbrev-tests.el
+++ b/test/lisp/dabbrev-tests.el
@@ -1,6 +1,6 @@
-;;; dabbrev-tests.el --- Test suite for dabbrev.
+;;; dabbrev-tests.el --- Test suite for dabbrev. -*- lexical-binding:t -*-
-;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2022 Free Software Foundation, Inc.
;; Author: Alan Third <alan@idiocy.org>
;; Keywords: dabbrev
@@ -29,14 +29,43 @@
(ert-deftest dabbrev-expand-test ()
"Test for bug#1948.
-When DABBREV-ELIMINATE-NEWLINES is non-nil (the default),
-repeated calls to DABBREV-EXPAND can result in the source of
+When `dabbrev-eliminate-newlines' is non-nil (the default),
+repeated calls to `dabbrev-expand' can result in the source of
first expansion being replaced rather than the destination."
(with-temp-buffer
(insert "ab x\na\nab y")
(goto-char 8)
(save-window-excursion
(set-window-buffer nil (current-buffer))
- ;; M-/ SPC M-/ M-/
- (execute-kbd-macro "\257 \257\257"))
+ (execute-kbd-macro (kbd "M-/ SPC M-/ M-/")))
(should (string= (buffer-string) "ab x\nab y\nab y"))))
+
+(ert-deftest dabbrev-completion-test ()
+ "Test for bug#17899.
+dabbrev-completion should not look for expansions in other
+buffers unless a prefix argument is used."
+ (with-temp-buffer
+ (insert "axy")
+ (with-temp-buffer
+ (insert "abc\na")
+ (goto-char 6)
+ (save-window-excursion
+ (set-window-buffer nil (current-buffer))
+ (execute-kbd-macro (kbd "C-M-/")))
+ (should (string= (buffer-string) "abc\nabc")))))
+
+(ert-deftest dabbrev-completion-test-with-argument ()
+ "Test for bug#17899.
+dabbrev-completion should not complete because it has found
+multiple expansions."
+ (with-temp-buffer
+ (insert "axy")
+ (with-temp-buffer
+ (insert "abc\na")
+ (goto-char 6)
+ (save-window-excursion
+ (set-window-buffer nil (current-buffer))
+ (execute-kbd-macro (kbd "C-u C-u C-M-/")))
+ (should (string= (buffer-string) "abc\na")))))
+
+;;; dabbrev-tests.el ends here