mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
fixed mostly wrong lambda tests (and a few lambda improvements as well)
This commit is contained in:
@@ -829,7 +829,7 @@ class Array(use_metaclass(cache.CachedMetaClass, parsing.Base)):
|
|||||||
return builtin.Builtin.scope
|
return builtin.Builtin.scope
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name not in ['type', 'start_pos']:
|
if name not in ['type', 'start_pos', 'get_only_subelement']:
|
||||||
raise AttributeError('Strange access: %s.' % name)
|
raise AttributeError('Strange access: %s.' % name)
|
||||||
return getattr(self._array, name)
|
return getattr(self._array, name)
|
||||||
|
|
||||||
@@ -1373,9 +1373,11 @@ def follow_call_list(call_list):
|
|||||||
# comprehensions
|
# comprehensions
|
||||||
result += follow_statement(stmt)
|
result += follow_statement(stmt)
|
||||||
else:
|
else:
|
||||||
|
if isinstance(call, (parsing.Lambda)):
|
||||||
|
result.append(Function(call))
|
||||||
# With things like params, these can also be functions...
|
# With things like params, these can also be functions...
|
||||||
if isinstance(call, (parsing.Lambda, Function, Class,
|
elif isinstance(call, (Function, Class, Instance,
|
||||||
Instance, dynamic.ArrayInstance)):
|
dynamic.ArrayInstance)):
|
||||||
result.append(call)
|
result.append(call)
|
||||||
# The string tokens are just operations (+, -, etc.)
|
# The string tokens are just operations (+, -, etc.)
|
||||||
elif not isinstance(call, (str, unicode)):
|
elif not isinstance(call, (str, unicode)):
|
||||||
|
|||||||
@@ -445,6 +445,10 @@ class Lambda(Function):
|
|||||||
string = "lambda %s:" % params
|
string = "lambda %s:" % params
|
||||||
return string + super(Function, self).get_code(indention=indention)
|
return string + super(Function, self).get_code(indention=indention)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s @%s (%s-%s)>" % (type(self).__name__, self.start_pos[0],
|
||||||
|
self.start_pos[1], self.end_pos[1])
|
||||||
|
|
||||||
|
|
||||||
class Flow(Scope):
|
class Flow(Scope):
|
||||||
"""
|
"""
|
||||||
@@ -1551,6 +1555,7 @@ class PyFuzzyParser(object):
|
|||||||
if ret is not None:
|
if ret is not None:
|
||||||
ret.parent = lambd
|
ret.parent = lambd
|
||||||
lambd.returns.append(ret)
|
lambd.returns.append(ret)
|
||||||
|
lambd.end_pos = ret.end_pos
|
||||||
lambd.parent = self.scope
|
lambd.parent = self.scope
|
||||||
tok_list[-1] = lambd
|
tok_list[-1] = lambd
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -373,11 +373,11 @@ a(0)
|
|||||||
|
|
||||||
arg_l = lambda x, y: y, x
|
arg_l = lambda x, y: y, x
|
||||||
#? float()
|
#? float()
|
||||||
argl[0]('', 1.0)
|
arg_l[0]('', 1.0)
|
||||||
#? list()
|
#? list()
|
||||||
arg_l[1]
|
arg_l[1]
|
||||||
|
|
||||||
arg_l = lambda x, y: y, x
|
arg_l = lambda x, y: (y, x)
|
||||||
args = 1,""
|
args = 1,""
|
||||||
result = arg_l(*args)
|
result = arg_l(*args)
|
||||||
#? tuple()
|
#? tuple()
|
||||||
@@ -395,9 +395,11 @@ with_lambda(arg_l, 1.0)[1]
|
|||||||
#? float()
|
#? float()
|
||||||
with_lambda(arg_l, 1.0)[0]
|
with_lambda(arg_l, 1.0)[0]
|
||||||
#? float()
|
#? float()
|
||||||
with_lambda(arg_l, x=1.0)[0]
|
with_lambda(arg_l, y=1.0)[0]
|
||||||
|
#? int()
|
||||||
|
with_lambda(lambda x: x)
|
||||||
#? float()
|
#? float()
|
||||||
with_lambda(lambda x: x, x=1.0)[0]
|
with_lambda(lambda x, y: y, y=1.0)
|
||||||
|
|
||||||
arg_func = lambda *args, **kwargs: args[0], kwargs['a']
|
arg_func = lambda *args, **kwargs: args[0], kwargs['a']
|
||||||
#? int()
|
#? int()
|
||||||
|
|||||||
Reference in New Issue
Block a user