diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-06-22 15:55:19 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-06-22 16:03:46 +0200 |
commit | 47374d44167ce7a20d78c3c544434f389e0d726e (patch) | |
tree | dce8c8f0439c312353872822035559c5e0b8b671 /test/lisp/misc-tests.el | |
parent | 55c2102560751ae05c98fd04120abcf4595d2a57 (diff) | |
download | emacs-47374d44167ce7a20d78c3c544434f389e0d726e.tar.gz emacs-47374d44167ce7a20d78c3c544434f389e0d726e.tar.bz2 emacs-47374d44167ce7a20d78c3c544434f389e0d726e.zip |
duplicate-line: fix optional argument and add test (bug#46621)
The test assumes that the current semantics are intended and desired,
which may or may not be true, but it's better than not having any at
all.
* lisp/misc.el (duplicate-line): Don't crash if called with no argument.
* test/lisp/misc-tests.el (misc--duplicate-line): New test.
Diffstat (limited to 'test/lisp/misc-tests.el')
-rw-r--r-- | test/lisp/misc-tests.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el index 236223ef493..a56feaa0495 100644 --- a/test/lisp/misc-tests.el +++ b/test/lisp/misc-tests.el @@ -80,5 +80,21 @@ (backward-to-word 3) (should (equal (point) 1)))) +(ert-deftest misc--duplicate-line () + ;; Duplicate a line (twice). + (with-temp-buffer + (insert "abc\ndefg\nh\n") + (goto-char 7) + (duplicate-line 2) + (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n")) + (should (equal (point) 7))) + ;; Duplicate a non-terminated line. + (with-temp-buffer + (insert "abc") + (goto-char 2) + (duplicate-line) + (should (equal (buffer-string) "abc\nabc\n")) + (should (equal (point) 2)))) + (provide 'misc-tests) ;;; misc-tests.el ends here |