test/completion/operators.py -> precedence.py

This commit is contained in:
Dave Halter
2014-04-20 12:14:07 +02:00
parent 7682f204fb
commit 6f17000fa8

View File

@@ -0,0 +1,84 @@
"""
Test Jedi's operation understanding. Jedi should understand simple additions,
multiplications, etc.
"""
# -----------------
# numbers
# -----------------
x = [1, 'a', 1.0]
#? int() str() float()
x[12]
#? float()
x[1 + 1]
index = 0 + 1
#? str()
x[index]
#? int()
x[1 + (-1)]
def calculate(number):
return number + constant
constant = 1
#? float()
x[calculate(1)]
def calculate(number):
return number + constant
# -----------------
# strings
# -----------------
x = 'upp' + 'e'
#? str.upper
getattr(str, x + 'r')
# -----------------
# assignments
# -----------------
x = [1, 'a', 1.0]
i = 0
i += 1
i += 1
#? float()
x[i]
i = 1
i += 1
i -= 3
i += 1
#? int()
x[i]
# -----------------
# for flow assignments
# -----------------
class FooBar(object):
fuu = 0.1
raboof = 'fourtytwo'
# targets should be working
target = ''
for char in ['f', 'u', 'u']:
target += char
#? float()
getattr(FooBar, target)
# github #24
target = u''
for char in reversed(['f', 'o', 'o', 'b', 'a', 'r']):
target += char
#? str()
getattr(FooBar, target)