tests and error catching for double executions

This commit is contained in:
David Halter
2012-04-25 10:01:53 +02:00
parent 3780e44603
commit e466508b4d
3 changed files with 26 additions and 13 deletions

View File

@@ -115,6 +115,9 @@ class Execution(Exec):
else: else:
# set the callback function to get the params # set the callback function to get the params
self.base.param_cb = self.get_params self.base.param_cb = self.get_params
# don't do this with exceptions, as usual, because some deeper
# exceptions could be catched - and I wouldn't know what happened.
if hasattr(self.base, 'returns'):
ret = self.base.returns ret = self.base.returns
for s in ret: for s in ret:
#temp, s.parent = s.parent, self #temp, s.parent = s.parent, self
@@ -432,11 +435,15 @@ def follow_call(scope, call):
else: else:
# TODO add better care for int/unicode, now str/float are just used # TODO add better care for int/unicode, now str/float are just used
# instead # instead
not_name_part = not isinstance(current, parsing.NamePart) if not isinstance(current, parsing.NamePart):
if not_name_part and current.type == parsing.Call.STRING: if current.type == parsing.Call.STRING:
scopes = get_scopes_for_name(builtin.Builtin.scope, 'str') scopes = get_scopes_for_name(builtin.Builtin.scope, 'str')
elif not_name_part and current.type == parsing.Call.NUMBER: elif current.type == parsing.Call.NUMBER:
scopes = get_scopes_for_name(builtin.Builtin.scope, 'float') scopes = get_scopes_for_name(builtin.Builtin.scope, 'float')
else:
debug.warning('unknown type:', current.type, current)
# make instances of those number/string objects
scopes = [Instance(s) for s in scopes]
else: else:
scopes = get_scopes_for_name(scope, current, search_global=True) scopes = get_scopes_for_name(scope, current, search_global=True)
result = strip_imports(scopes) result = strip_imports(scopes)

View File

@@ -98,7 +98,7 @@ u1.real
u1.upper u1.upper
# ----------------- # -----------------
# should fail # should fail (return nothing)
# ----------------- # -----------------
(f, g) = (1,) (f, g) = (1,)
#? ['imag'] #? ['imag']

View File

@@ -38,3 +38,9 @@ def variable_rename(param):
#? ['imag'] #? ['imag']
variable_rename(1).imag variable_rename(1).imag
# double execution -> shouldn't work (and throw no error)
#? []
variable_rename(list())().
#? []
variable_rename(1)().