aboutsummaryrefslogtreecommitdiffstats
path: root/test/automated/python-tests.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2013-08-13 13:36:32 -0300
committerFabián Ezequiel Gallina2013-08-13 13:36:32 -0300
commitad75644970a5deccb1d40465e20087f5806ed3df (patch)
tree8dc0ba2c980d3f6a3abc98918912b71c7141f363 /test/automated/python-tests.el
parent866c710eeb75ce47767442952028d79b76c1606a (diff)
downloademacs-ad75644970a5deccb1d40465e20087f5806ed3df.tar.gz
emacs-ad75644970a5deccb1d40465e20087f5806ed3df.zip
* lisp/progmodes/python.el (python-imenu--build-tree)
(python-imenu--put-parent): Simplify and Fix (GH bug 146). * test/automated/python-tests.el (python-imenu-create-index-4) (python-imenu-create-flat-index-2): New tests.
Diffstat (limited to 'test/automated/python-tests.el')
-rw-r--r--test/automated/python-tests.el52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index fdae235ad38..ef1c0155ab5 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -1792,6 +1792,34 @@ class Foo(object):
1792 (cons "foo2 (def)" (copy-marker 77))))) 1792 (cons "foo2 (def)" (copy-marker 77)))))
1793 (python-imenu-create-index))))) 1793 (python-imenu-create-index)))))
1794 1794
1795(ert-deftest python-imenu-create-index-4 ()
1796 (python-tests-with-temp-buffer
1797 "
1798class Foo(object):
1799 class Bar(object):
1800 def __init__(self):
1801 pass
1802
1803 def __str__(self):
1804 pass
1805
1806 def __init__(self):
1807 pass
1808"
1809 (goto-char (point-max))
1810 (should (equal
1811 (list
1812 (list
1813 "Foo (class)"
1814 (cons "*class definition*" (copy-marker 2))
1815 (list
1816 "Bar (class)"
1817 (cons "*class definition*" (copy-marker 21))
1818 (cons "__init__ (def)" (copy-marker 44))
1819 (cons "__str__ (def)" (copy-marker 90)))
1820 (cons "__init__ (def)" (copy-marker 135))))
1821 (python-imenu-create-index)))))
1822
1795(ert-deftest python-imenu-create-flat-index-1 () 1823(ert-deftest python-imenu-create-flat-index-1 ()
1796 (python-tests-with-temp-buffer 1824 (python-tests-with-temp-buffer
1797 " 1825 "
@@ -1851,6 +1879,30 @@ class Baz(object):
1851 (cons "Baz.Frob.c" (copy-marker 626))) 1879 (cons "Baz.Frob.c" (copy-marker 626)))
1852 (python-imenu-create-flat-index))))) 1880 (python-imenu-create-flat-index)))))
1853 1881
1882(ert-deftest python-imenu-create-flat-index-2 ()
1883 (python-tests-with-temp-buffer
1884 "
1885class Foo(object):
1886 class Bar(object):
1887 def __init__(self):
1888 pass
1889
1890 def __str__(self):
1891 pass
1892
1893 def __init__(self):
1894 pass
1895"
1896 (goto-char (point-max))
1897 (should (equal
1898 (list
1899 (cons "Foo" (copy-marker 2))
1900 (cons "Foo.Bar" (copy-marker 21))
1901 (cons "Foo.Bar.__init__" (copy-marker 44))
1902 (cons "Foo.Bar.__str__" (copy-marker 90))
1903 (cons "Foo.__init__" (copy-marker 135)))
1904 (python-imenu-create-flat-index)))))
1905
1854 1906
1855;;; Misc helpers 1907;;; Misc helpers
1856 1908