diff options
author | kobarity <kobarity@gmail.com> | 2022-07-03 14:22:13 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-07-03 14:23:25 +0200 |
commit | 6e2f9dd3dd8b3c65608366039ce69666905d80cb (patch) | |
tree | 5231d795049ffc2314b0f5198ff773f6739caf3e /test/lisp/progmodes/python-tests.el | |
parent | c61c647f7272faf625b5584035d455e81d1ebd0e (diff) | |
download | emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.tar.gz emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.tar.bz2 emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.zip |
Fix `python-nav-beginning-of-defun' line continuation using backslash
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Allow
line continuation using backslash in defuns (bug#55702).
(python-info-looking-at-beginning-of-defun): Add CHECK-STATEMENT
argument.
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r-- | test/lisp/progmodes/python-tests.el | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index c59a2e79533..d7b3c102f2d 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1757,6 +1757,36 @@ def foo(x): (should (= (marker-position (mark-marker)) expected-mark-end-position))))) +(ert-deftest python-mark-defun-5 () + "Test `python-mark-defun' with point inside backslash escaped defun." + (python-tests-with-temp-buffer + " +def \\ + foo(x): + return x +" + (let ((transient-mark-mode t) + (expected-mark-beginning-position + (progn + (python-tests-look-at "def ") + (1- (line-beginning-position)))) + (expected-mark-end-position + (save-excursion + (python-tests-look-at "return x") + (forward-line) + (point)))) + (python-tests-look-at "def ") + (python-mark-defun 1) + (should (= (point) expected-mark-beginning-position)) + (should (= (marker-position (mark-marker)) + expected-mark-end-position)) + (deactivate-mark) + (python-tests-look-at "foo(x)") + (python-mark-defun 1) + (should (= (point) expected-mark-beginning-position)) + (should (= (marker-position (mark-marker)) + expected-mark-end-position))))) + ;;; Navigation @@ -1905,17 +1935,47 @@ class C(object): (ert-deftest python-nav-beginning-of-defun-4 () (python-tests-with-temp-buffer " +def a(): + pass + def \\ - a(): + b(): return 0 + +def c(): + pass " - (python-tests-look-at "return 0") + (python-tests-look-at "def c():") + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "def \\" -1) + (beginning-of-line) + (point)))) + (python-tests-look-at "return 0" -1) (should (= (save-excursion (python-nav-beginning-of-defun) (point)) (save-excursion (python-tests-look-at "def \\" -1) (beginning-of-line) + (point)))) + (python-tests-look-at "b():" -1) + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "def \\" -1) + (beginning-of-line) + (point)))) + (python-tests-look-at "def a():" -1) + (should (= (save-excursion + (python-nav-beginning-of-defun -1) + (point)) + (save-excursion + (python-tests-look-at "def \\") + (beginning-of-line) (point)))))) (ert-deftest python-nav-end-of-defun-1 () @@ -5242,6 +5302,23 @@ def decorat0r(deff): (python-tests-look-at "deff()") (should (not (python-info-looking-at-beginning-of-defun))))) +(ert-deftest python-info-looking-at-beginning-of-defun-2 () + (python-tests-with-temp-buffer + " +def \\ + foo(arg): + pass +" + (python-tests-look-at "def \\") + (should (python-info-looking-at-beginning-of-defun)) + (should (python-info-looking-at-beginning-of-defun nil t)) + (python-tests-look-at "foo(arg):") + (should (not (python-info-looking-at-beginning-of-defun))) + (should (python-info-looking-at-beginning-of-defun nil t)) + (python-tests-look-at "pass") + (should (not (python-info-looking-at-beginning-of-defun))) + (should (not (python-info-looking-at-beginning-of-defun nil t))))) + (ert-deftest python-info-current-line-comment-p-1 () (python-tests-with-temp-buffer " |