aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorkobarity2022-05-28 18:51:01 +0200
committerLars Ingebrigtsen2022-05-28 18:51:01 +0200
commit1e66c8af402176e9f1b5f3fbdbf5f796fec79079 (patch)
tree9395a9e2a1e75c48be809b8f084f8f0f0716d47c /test/lisp/progmodes/python-tests.el
parent5d8b6ba89efdcddfd0189da77dd4099283466a05 (diff)
downloademacs-1e66c8af402176e9f1b5f3fbdbf5f796fec79079.tar.gz
emacs-1e66c8af402176e9f1b5f3fbdbf5f796fec79079.zip
Fix Python Hideshow problem with backslash escaped newlines
* lisp/progmodes/python.el (python-rx) (python-nav-beginning-of-defun-regexp): Allow python-nav-*-defun to handle backslash escaped newlines (bug#55690).
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 479d68a0623..8db0a07170d 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1861,6 +1861,22 @@ class C(object):
1861 (beginning-of-line) 1861 (beginning-of-line)
1862 (point)))))) 1862 (point))))))
1863 1863
1864(ert-deftest python-nav-beginning-of-defun-4 ()
1865 (python-tests-with-temp-buffer
1866 "
1867def \\
1868 a():
1869 return 0
1870"
1871 (python-tests-look-at "return 0")
1872 (should (= (save-excursion
1873 (python-nav-beginning-of-defun)
1874 (point))
1875 (save-excursion
1876 (python-tests-look-at "def \\" -1)
1877 (beginning-of-line)
1878 (point))))))
1879
1864(ert-deftest python-nav-end-of-defun-1 () 1880(ert-deftest python-nav-end-of-defun-1 ()
1865 (python-tests-with-temp-buffer 1881 (python-tests-with-temp-buffer
1866 " 1882 "
@@ -1964,6 +1980,20 @@ def decoratorFunctionWithArguments(arg1, arg2, arg3):
1964 (python-tests-look-at "return wrapped_f") 1980 (python-tests-look-at "return wrapped_f")
1965 (line-beginning-position)))))) 1981 (line-beginning-position))))))
1966 1982
1983(ert-deftest python-nav-end-of-defun-3 ()
1984 (python-tests-with-temp-buffer
1985 "
1986def \\
1987 a():
1988 return 0
1989"
1990 (should (= (save-excursion
1991 (python-tests-look-at "def \\")
1992 (python-nav-end-of-defun)
1993 (point))
1994 (save-excursion
1995 (point-max))))))
1996
1967(ert-deftest python-nav-backward-defun-1 () 1997(ert-deftest python-nav-backward-defun-1 ()
1968 (python-tests-with-temp-buffer 1998 (python-tests-with-temp-buffer
1969 " 1999 "
@@ -2062,6 +2092,18 @@ class A(object):
2062 (should (not (python-nav-backward-defun))) 2092 (should (not (python-nav-backward-defun)))
2063 (should (= point (point)))))) 2093 (should (= point (point))))))
2064 2094
2095(ert-deftest python-nav-backward-defun-4 ()
2096 (python-tests-with-temp-buffer
2097 "
2098def \\
2099 a():
2100 return 0
2101"
2102 (goto-char (point-max))
2103 (should (= (save-excursion (python-nav-backward-defun))
2104 (python-tests-look-at "def \\" -1)))
2105 (should (not (python-nav-backward-defun)))))
2106
2065(ert-deftest python-nav-forward-defun-1 () 2107(ert-deftest python-nav-forward-defun-1 ()
2066 (python-tests-with-temp-buffer 2108 (python-tests-with-temp-buffer
2067 " 2109 "
@@ -2160,6 +2202,18 @@ class A(object):
2160 (should (not (python-nav-forward-defun))) 2202 (should (not (python-nav-forward-defun)))
2161 (should (= point (point)))))) 2203 (should (= point (point))))))
2162 2204
2205(ert-deftest python-nav-forward-defun-4 ()
2206 (python-tests-with-temp-buffer
2207 "
2208def \\
2209 a():
2210 return 0
2211"
2212 (goto-char (point-min))
2213 (should (= (save-excursion (python-nav-forward-defun))
2214 (python-tests-look-at "():")))
2215 (should (not (python-nav-forward-defun)))))
2216
2163(ert-deftest python-nav-beginning-of-statement-1 () 2217(ert-deftest python-nav-beginning-of-statement-1 ()
2164 (python-tests-with-temp-buffer 2218 (python-tests-with-temp-buffer
2165 " 2219 "