diff options
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 8db0a07170d..e17bc0df925 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -1736,6 +1736,27 @@ class C: | |||
| 1736 | (should (= (marker-position (mark-marker)) | 1736 | (should (= (marker-position (mark-marker)) |
| 1737 | expected-mark-end-position))))) | 1737 | expected-mark-end-position))))) |
| 1738 | 1738 | ||
| 1739 | (ert-deftest python-mark-defun-4 () | ||
| 1740 | "Test `python-mark-defun' with nested functions." | ||
| 1741 | (python-tests-with-temp-buffer | ||
| 1742 | " | ||
| 1743 | def foo(x): | ||
| 1744 | def bar(): | ||
| 1745 | return x | ||
| 1746 | if True: | ||
| 1747 | return bar | ||
| 1748 | " | ||
| 1749 | (let ((expected-mark-beginning-position | ||
| 1750 | (progn | ||
| 1751 | (python-tests-look-at "def foo(x):") | ||
| 1752 | (1- (line-beginning-position)))) | ||
| 1753 | (expected-mark-end-position (point-max))) | ||
| 1754 | (python-tests-look-at "return bar") | ||
| 1755 | (python-mark-defun 1) | ||
| 1756 | (should (= (point) expected-mark-beginning-position)) | ||
| 1757 | (should (= (marker-position (mark-marker)) | ||
| 1758 | expected-mark-end-position))))) | ||
| 1759 | |||
| 1739 | 1760 | ||
| 1740 | ;;; Navigation | 1761 | ;;; Navigation |
| 1741 | 1762 | ||
| @@ -1762,12 +1783,20 @@ def decoratorFunctionWithArguments(arg1, arg2, arg3): | |||
| 1762 | return wrapped_f | 1783 | return wrapped_f |
| 1763 | return wwrap | 1784 | return wwrap |
| 1764 | " | 1785 | " |
| 1765 | (python-tests-look-at "return wrap") | 1786 | (python-tests-look-at "return wwrap") |
| 1766 | (should (= (save-excursion | 1787 | (should (= (save-excursion |
| 1767 | (python-nav-beginning-of-defun) | 1788 | (python-nav-beginning-of-defun) |
| 1768 | (point)) | 1789 | (point)) |
| 1769 | (save-excursion | 1790 | (save-excursion |
| 1770 | (python-tests-look-at "def wrapped_f(*args):" -1) | 1791 | (python-tests-look-at "def decoratorFunctionWithArguments" -1) |
| 1792 | (beginning-of-line) | ||
| 1793 | (point)))) | ||
| 1794 | (python-tests-look-at "return wrap" -1) | ||
| 1795 | (should (= (save-excursion | ||
| 1796 | (python-nav-beginning-of-defun) | ||
| 1797 | (point)) | ||
| 1798 | (save-excursion | ||
| 1799 | (python-tests-look-at "def wwrap(f):" -1) | ||
| 1771 | (beginning-of-line) | 1800 | (beginning-of-line) |
| 1772 | (point)))) | 1801 | (point)))) |
| 1773 | (python-tests-look-at "def wrapped_f(*args):" -1) | 1802 | (python-tests-look-at "def wrapped_f(*args):" -1) |
| @@ -1801,6 +1830,9 @@ class C(object): | |||
| 1801 | def a(): | 1830 | def a(): |
| 1802 | pass | 1831 | pass |
| 1803 | 1832 | ||
| 1833 | if True: | ||
| 1834 | return a | ||
| 1835 | |||
| 1804 | def c(self): | 1836 | def c(self): |
| 1805 | pass | 1837 | pass |
| 1806 | " | 1838 | " |
| @@ -1813,6 +1845,15 @@ class C(object): | |||
| 1813 | (python-tests-look-at "def m(self):" -1) | 1845 | (python-tests-look-at "def m(self):" -1) |
| 1814 | (beginning-of-line) | 1846 | (beginning-of-line) |
| 1815 | (point)))) | 1847 | (point)))) |
| 1848 | ;; Nested defuns shuld be skipped. | ||
| 1849 | (python-tests-look-at "return a" -1) | ||
| 1850 | (should (= (save-excursion | ||
| 1851 | (python-nav-beginning-of-defun) | ||
| 1852 | (point)) | ||
| 1853 | (save-excursion | ||
| 1854 | (python-tests-look-at "def m(self):" -1) | ||
| 1855 | (beginning-of-line) | ||
| 1856 | (point)))) | ||
| 1816 | ;; Defuns on same levels should be respected. | 1857 | ;; Defuns on same levels should be respected. |
| 1817 | (python-tests-look-at "def a():" -1) | 1858 | (python-tests-look-at "def a():" -1) |
| 1818 | (should (= (save-excursion | 1859 | (should (= (save-excursion |