mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
more detailed tests and implementation of array indexing in the interpreter
This commit is contained in:
@@ -106,12 +106,16 @@ class CompiledObject(Base):
|
||||
else:
|
||||
try:
|
||||
new = self.obj[typ.obj]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
except (KeyError, IndexError, TypeError, AttributeError):
|
||||
pass # just try, we don't care if it fails.
|
||||
else:
|
||||
result.append(CompiledObject(new))
|
||||
if not result:
|
||||
pass
|
||||
try:
|
||||
for obj in self.obj:
|
||||
result.append(CompiledObject(obj))
|
||||
except TypeError:
|
||||
pass # self.obj maynot have an __iter__ method.
|
||||
return result
|
||||
|
||||
@property
|
||||
|
||||
@@ -51,3 +51,15 @@ class TestInterpreterAPI(TestCase):
|
||||
self.check_interpreter_complete('array[0].real',
|
||||
locals(),
|
||||
[])
|
||||
|
||||
# something different, no index given, still just return the right
|
||||
self.check_interpreter_complete('array[int].real',
|
||||
locals(),
|
||||
['real'])
|
||||
self.check_interpreter_complete('array[int()].real',
|
||||
locals(),
|
||||
['real'])
|
||||
# inexistent index
|
||||
self.check_interpreter_complete('array[2].upper',
|
||||
locals(),
|
||||
['upper'])
|
||||
|
||||
Reference in New Issue
Block a user