tests added / error catch

This commit is contained in:
David Halter
2012-04-25 09:48:31 +02:00
parent 1ea2954c0e
commit 3780e44603
6 changed files with 36 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ follow_statement -> follow_call -> follow_paths -> follow_path
TODO include super classes
TODO nonlocal statement
TODO doc
TODO list comprehensions, priority?
"""
from _compatibility import next
@@ -347,7 +348,10 @@ def assign_tuples(tup, results, seek_name):
def eval_results(index):
types = []
for r in results:
if hasattr(r, "get_exact_index_types"):
types += r.get_exact_index_types(index)
else:
debug.warning("assign tuples: invalid tuple lookup")
return types
result = []

View File

@@ -198,7 +198,8 @@ def complete(source, row, column, source_path):
completions = []
debug.dbg('possible scopes', 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):
completions += s.get_defined_names()

View File

@@ -128,13 +128,14 @@ if True or a:
import time
class c1():
c2,c5 = c1(), c1().c3()
def c3(self):
def c3(self, daeparam):
import os as c4 #from parsing import Scope as c4
c5 = 1
c5 = c4(
if 1:
print 1
return c5+'asdf'
#return c5+'asdf'
return daeparam
(c1().c2.\
c, 1, c3()) [0].pop()
c = u"asdf".join([1,2])
@@ -154,7 +155,6 @@ def globalfunc():
global globalvar, globalvar2
globalvar = 3
for abcde, efgh in [(1,"")]:
abcde.real
abcde.
c1().c3(1).

View File

@@ -96,3 +96,19 @@ u1.real
(u1).real
#? []
u1.upper
# -----------------
# should fail
# -----------------
(f, g) = (1,)
#? ['imag']
f.imag
#? []
g.upper
(f1, g1) = 1
#? []
f1.
#? []
g1.

View File

@@ -10,6 +10,9 @@ class TestClass(object):
#? ['var_class', 'var_inst', 'var_local']
self.var_
def ret(self, a1):
return a1
inst = TestClass(1)
#? ['var_class', 'var_inst', 'var_local']
@@ -17,3 +20,6 @@ inst.var
#? ['var_class']
TestClass.var_class
#? ['real']
TestClass().ret(1).real

View File

@@ -35,7 +35,7 @@ def completion_test(source):
completions = functions.complete(source, line_nr, 999,
completion_test_dir)
except:
print 'test: %s' % line
print 'test @%s: %s' % (line_nr, line)
print traceback.format_exc()
fails += 1
else:
@@ -43,7 +43,7 @@ def completion_test(source):
# TODO remove set! duplicates should not be normal
comp_str = str(sorted(set([str(c) for c in completions])))
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)
#print [(c.name, c.name.parent) for c in completions]
fails += 1