mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-28 07:56:51 +08:00
tests added / error catch
This commit is contained in:
@@ -7,6 +7,7 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
|||||||
TODO include super classes
|
TODO include super classes
|
||||||
TODO nonlocal statement
|
TODO nonlocal statement
|
||||||
TODO doc
|
TODO doc
|
||||||
|
TODO list comprehensions, priority?
|
||||||
"""
|
"""
|
||||||
from _compatibility import next
|
from _compatibility import next
|
||||||
|
|
||||||
@@ -347,7 +348,10 @@ def assign_tuples(tup, results, seek_name):
|
|||||||
def eval_results(index):
|
def eval_results(index):
|
||||||
types = []
|
types = []
|
||||||
for r in results:
|
for r in results:
|
||||||
|
if hasattr(r, "get_exact_index_types"):
|
||||||
types += r.get_exact_index_types(index)
|
types += r.get_exact_index_types(index)
|
||||||
|
else:
|
||||||
|
debug.warning("assign tuples: invalid tuple lookup")
|
||||||
return types
|
return types
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|||||||
@@ -198,7 +198,8 @@ def complete(source, row, column, source_path):
|
|||||||
completions = []
|
completions = []
|
||||||
debug.dbg('possible scopes', scopes)
|
debug.dbg('possible scopes', scopes)
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
# TODO is this reall the right way, just ignore the functions?
|
# TODO is this reall the right way? just ignore the functions? \
|
||||||
|
# do the magic functions first? and then recheck here?
|
||||||
if not isinstance(s, parsing.Function):
|
if not isinstance(s, parsing.Function):
|
||||||
completions += s.get_defined_names()
|
completions += s.get_defined_names()
|
||||||
|
|
||||||
|
|||||||
10
parsetest.py
10
parsetest.py
@@ -128,13 +128,14 @@ if True or a:
|
|||||||
import time
|
import time
|
||||||
class c1():
|
class c1():
|
||||||
c2,c5 = c1(), c1().c3()
|
c2,c5 = c1(), c1().c3()
|
||||||
def c3(self):
|
def c3(self, daeparam):
|
||||||
import os as c4 #from parsing import Scope as c4
|
import os as c4 #from parsing import Scope as c4
|
||||||
c5 = 1
|
c5 = 1
|
||||||
c5 = c4(
|
c5 = c4(
|
||||||
if 1:
|
if 1:
|
||||||
print 1
|
print 1
|
||||||
return c5+'asdf'
|
#return c5+'asdf'
|
||||||
|
return daeparam
|
||||||
(c1().c2.\
|
(c1().c2.\
|
||||||
c, 1, c3()) [0].pop()
|
c, 1, c3()) [0].pop()
|
||||||
c = u"asdf".join([1,2])
|
c = u"asdf".join([1,2])
|
||||||
@@ -154,7 +155,6 @@ def globalfunc():
|
|||||||
global globalvar, globalvar2
|
global globalvar, globalvar2
|
||||||
globalvar = 3
|
globalvar = 3
|
||||||
|
|
||||||
for abcde, efgh in [(1,"")]:
|
|
||||||
abcde.real
|
|
||||||
|
|
||||||
abcde.
|
|
||||||
|
c1().c3(1).
|
||||||
|
|||||||
@@ -96,3 +96,19 @@ u1.real
|
|||||||
(u1).real
|
(u1).real
|
||||||
#? []
|
#? []
|
||||||
u1.upper
|
u1.upper
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# should fail
|
||||||
|
# -----------------
|
||||||
|
(f, g) = (1,)
|
||||||
|
#? ['imag']
|
||||||
|
f.imag
|
||||||
|
#? []
|
||||||
|
g.upper
|
||||||
|
|
||||||
|
(f1, g1) = 1
|
||||||
|
#? []
|
||||||
|
f1.
|
||||||
|
#? []
|
||||||
|
g1.
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class TestClass(object):
|
|||||||
#? ['var_class', 'var_inst', 'var_local']
|
#? ['var_class', 'var_inst', 'var_local']
|
||||||
self.var_
|
self.var_
|
||||||
|
|
||||||
|
def ret(self, a1):
|
||||||
|
return a1
|
||||||
|
|
||||||
inst = TestClass(1)
|
inst = TestClass(1)
|
||||||
|
|
||||||
#? ['var_class', 'var_inst', 'var_local']
|
#? ['var_class', 'var_inst', 'var_local']
|
||||||
@@ -17,3 +20,6 @@ inst.var
|
|||||||
|
|
||||||
#? ['var_class']
|
#? ['var_class']
|
||||||
TestClass.var_class
|
TestClass.var_class
|
||||||
|
|
||||||
|
#? ['real']
|
||||||
|
TestClass().ret(1).real
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ def completion_test(source):
|
|||||||
completions = functions.complete(source, line_nr, 999,
|
completions = functions.complete(source, line_nr, 999,
|
||||||
completion_test_dir)
|
completion_test_dir)
|
||||||
except:
|
except:
|
||||||
print 'test: %s' % line
|
print 'test @%s: %s' % (line_nr, line)
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
fails += 1
|
fails += 1
|
||||||
else:
|
else:
|
||||||
@@ -43,7 +43,7 @@ def completion_test(source):
|
|||||||
# TODO remove set! duplicates should not be normal
|
# TODO remove set! duplicates should not be normal
|
||||||
comp_str = str(sorted(set([str(c) for c in completions])))
|
comp_str = str(sorted(set([str(c) for c in completions])))
|
||||||
if comp_str != correct:
|
if comp_str != correct:
|
||||||
print 'Solution on %s not correct, received %s, wanted %s'\
|
print 'Solution on @%s not correct, received %s, wanted %s'\
|
||||||
% (line_nr, comp_str, correct)
|
% (line_nr, comp_str, correct)
|
||||||
#print [(c.name, c.name.parent) for c in completions]
|
#print [(c.name, c.name.parent) for c in completions]
|
||||||
fails += 1
|
fails += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user