aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorkobarity2023-03-05 17:06:26 +0900
committerEli Zaretskii2023-03-09 12:12:27 +0200
commitf175141aeade5d6795d22d40c1eb001c6ba49025 (patch)
treea829f2e2e9700d91a4bacb0cb2b098aeab53cdab /test/lisp/progmodes/python-tests.el
parent7e1012765c40a10a8a051c39566778913dc7e224 (diff)
downloademacs-f175141aeade5d6795d22d40c1eb001c6ba49025.tar.gz
emacs-f175141aeade5d6795d22d40c1eb001c6ba49025.zip
Fix searching for end of string in python-nav-end-of-statement
* lisp/progmodes/python.el (python-nav-end-of-statement): Add searching for corresponding string-quote. * test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-3) (python-nav-end-of-statement-4, python-info-current-defun-4): New tests. (Bug#58780)
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 6928e313dc4..7e2f66e9095 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -2955,6 +2955,36 @@ string
2955 "'\n''\n" 2955 "'\n''\n"
2956 (python-nav-end-of-statement))) 2956 (python-nav-end-of-statement)))
2957 2957
2958(ert-deftest python-nav-end-of-statement-3 ()
2959 "Test unmatched quotes (Bug#58780)."
2960 (python-tests-with-temp-buffer
2961 "
2962' \"\"\"
2963v = 1
2964"
2965 (python-tests-look-at "v =")
2966 (should (= (save-excursion
2967 (python-nav-end-of-statement)
2968 (point))
2969 (save-excursion
2970 (point-max))))))
2971
2972(ert-deftest python-nav-end-of-statement-4 ()
2973 (python-tests-with-temp-buffer
2974 "
2975abc = 'a\\
2976b\\
2977c'
2978d = '''d'''
2979"
2980 (python-tests-look-at "b\\")
2981 (should (= (save-excursion
2982 (python-nav-end-of-statement)
2983 (point))
2984 (save-excursion
2985 (python-tests-look-at "c'")
2986 (pos-eol))))))
2987
2958(ert-deftest python-nav-forward-statement-1 () 2988(ert-deftest python-nav-forward-statement-1 ()
2959 (python-tests-with-temp-buffer 2989 (python-tests-with-temp-buffer
2960 " 2990 "
@@ -5221,6 +5251,20 @@ def decoratorFunctionWithArguments(arg1, arg2, arg3):
5221 (should (string= (python-info-current-defun t) 5251 (should (string= (python-info-current-defun t)
5222 "def decoratorFunctionWithArguments")))) 5252 "def decoratorFunctionWithArguments"))))
5223 5253
5254(ert-deftest python-info-current-defun-4 ()
5255 "Ensure unmatched quotes do not cause hang (Bug#58780)."
5256 (python-tests-with-temp-buffer
5257 "
5258def func():
5259 ' \"\"\"
5260 v = 1
5261"
5262 (python-tests-look-at "v = 1")
5263 (should (string= (python-info-current-defun)
5264 "func"))
5265 (should (string= (python-info-current-defun t)
5266 "def func"))))
5267
5224(ert-deftest python-info-current-symbol-1 () 5268(ert-deftest python-info-current-symbol-1 ()
5225 (python-tests-with-temp-buffer 5269 (python-tests-with-temp-buffer
5226 " 5270 "