Permalink
Browse files

further regression tests

  • Loading branch information...
1 parent a238985 commit a5cb308d1fc5e5e7165c12906176817f8e1e2d27 @davidhalter committed Sep 6, 2012
Showing with 19 additions and 4 deletions.
  1. +4 −2 functions.py
  2. +15 −2 test/regression.py
View
@@ -62,6 +62,9 @@ def doc(self):
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
@@ -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 @@ def test_operator_doc(self):
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__':

0 comments on commit a5cb308

Please sign in to comment.