further regression tests

This commit is contained in:
David Halter
2012-09-06 02:14:04 +02:00
parent a238985ed8
commit a5cb308d1f
2 changed files with 18 additions and 3 deletions

View File

@@ -62,6 +62,9 @@ class Completion(object):
def get_type(self):
return type(self.name.parent())
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.name)
class Definition(object):
def __init__(self, definition):
@@ -249,14 +252,13 @@ def get_definition(source, line, column, source_path):
scopes = set([f.parser.user_scope])
elif not goto_path:
op = f.get_operator_under_cursor()
scopes = set([keywords.get_operator(op)])
scopes = set([keywords.get_operator(op)] if op else [])
else:
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
# add keywords
scopes |= keywords.get_keywords(string=goto_path)
d = set([Definition(s) for s in scopes])
_clear_caches()
return d

View File

@@ -14,6 +14,9 @@ class TestRegression(unittest.TestCase):
def get_def(self, src, pos):
return functions.get_definition(src, pos[0], pos[1], '')
def complete(self, src, pos):
return functions.complete(src, pos[0], pos[1], '')
def test_get_definition_cursor(self):
s = ("class A():\n"
@@ -65,8 +68,18 @@ class TestRegression(unittest.TestCase):
def test_get_definition_at_zero(self):
assert self.get_def("a", (1,1)) == set()
##assert self.get_def("", (1,0)) == set()
s = self.get_def("str", (1,1))
assert len(s) == 1
assert list(s)[0].description == 'class str'
assert self.get_def("", (1,0)) == set()
def test_complete_at_zero(self):
s = self.complete("str", (1,3))
assert len(s) == 1
assert list(s)[0].word == 'str'
s = self.complete("", (1,0))
assert len(s) > 0
if __name__ == '__main__':