* lisp/progmodes/python.el (python-imenu--build-tree): Fix corner case

in nested defuns.

* test/automated/python-tests.el (python-imenu-create-index-2)
(python-imenu-create-index-3): New tests.
This commit is contained in:
Fabián Ezequiel Gallina 2013-07-12 22:55:58 -03:00
parent deee89ff66
commit 1f0480d4cd
4 changed files with 64 additions and 2 deletions

View file

@ -1745,6 +1745,53 @@ class Baz(object):
(cons "c (def)" (copy-marker 626)))))
(python-imenu-create-index)))))
(ert-deftest python-imenu-create-index-2 ()
(python-tests-with-temp-buffer
"
class Foo(object):
def foo(self):
def foo1():
pass
def foobar(self):
pass
"
(goto-char (point-max))
(should (equal
(list
(list
"Foo (class)"
(cons "*class definition*" (copy-marker 2))
(list
"foo (def)"
(cons "*function definition*" (copy-marker 21))
(cons "foo1 (def)" (copy-marker 40)))
(cons "foobar (def)" (copy-marker 78))))
(python-imenu-create-index)))))
(ert-deftest python-imenu-create-index-3 ()
(python-tests-with-temp-buffer
"
class Foo(object):
def foo(self):
def foo1():
pass
def foo2():
pass
"
(goto-char (point-max))
(should (equal
(list
(list
"Foo (class)"
(cons "*class definition*" (copy-marker 2))
(list
"foo (def)"
(cons "*function definition*" (copy-marker 21))
(cons "foo1 (def)" (copy-marker 40))
(cons "foo2 (def)" (copy-marker 77)))))
(python-imenu-create-index)))))
(ert-deftest python-imenu-create-flat-index-1 ()
(python-tests-with-temp-buffer
"