1
0
forked from VimPlug/jedi

changed many tests from old completion tests to type tests, which brings more security

This commit is contained in:
David Halter
2012-07-06 01:29:50 +02:00
parent fdfd475d40
commit 8d26cff54b
3 changed files with 91 additions and 117 deletions

View File

@@ -2,127 +2,103 @@
# basic array lookups
# -----------------
#? ['imag']
[1,""][0].imag
#? []
[1,""][1].imag
#? int()
[1,""][0]
#? str()
[1,""][1]
a = list()
#? ['append']
[a][0].append
#? list()
[a][0]
#? ['append']
[[a,a,a]][2][100].append
#? list()
[[a,a,a]][2][100]
c = [[a,""]]
#? []
c[0][1].append
#? ['upper']
c[0][1].upper
#? str()
c[0][1]
b = [6,7]
#? ['real']
b[8-7].real
#? int() int()
b[8-7]
#? ['append']
b[8:].append
#? list()
b[8:]
# -----------------
# tuple assignments
# -----------------
a1, b1 = (1, "")
#? ['real']
a1.real
#? ['lower']
b1.lower
#? []
b1.real
#? int()
a1
#? str()
b1
(a2, b2) = (1, "")
#? ['imag']
a2.imag
#? ['upper']
b2.upper
#? int()
a2
#? str()
b2
# list assignment
[list1, list2] = (1, "")
#? []
list1.index
#? ['real']
list1.real
#? []
list1.lower
#? ['lower']
list2.lower
#? []
list2.real
#? int()
list1
#? str()
list2
[list3, list4] = [1, ""]
#? ['real']
list3.real
#? ['lower']
list4.lower
#? []
list4.real
#? int()
list3
#? str()
list4
# -----------------
# subtuple assignment
# -----------------
(a3, (b3, c3)) = (1, ("", list))
#? ['append']
c3.append
#? []
c3.upper
#? []
c3.real
#? list
c3
a4, (b4, c4) = (1, ("", list))
#? ['append']
c4.append
#? []
c4.upper
#? []
c4.real
#? ['real']
a4.real
#? ['upper']
b4.upper
#? list
c4
#? int()
a4
#? str()
b4
# -----------------
# unnessecary braces
# -----------------
#? ['real']
(1).real
#? ['real']
((1)).real
#? ['real']
((1)+1).real
#? int()
(1)
#? int()
((1))
#? int() int()
((1)+1)
u, v = 1, ""
#? ['real']
u.real
#? []
u.upper
#? int()
u
((u1, v1)) = 1, ""
#? ['real']
u1.real
#? ['real']
(u1).real
#? []
u1.upper
#? int()
u1
#? int()
(u1)
# -----------------
# should fail (return nothing)
# -----------------
(f, g) = (1,)
#? ['imag']
f.imag
#? int()
f
#? []
g.upper
g.
(f1, g1) = 1
#? []
@@ -134,12 +110,11 @@ g1.
# dicts
# -----------------
dic2 = {'asdf': 3, 'b': 'str'}
#? ['real']
dic2['asdf'].real
#? []
dic2['asdf'].upper
#? int()
dic2['asdf']
# string literal
#? ['real']
dic2[r'asdf'].real
#? []
dic2[r'asdf'].upper
#? int()
dic2[r'asdf']
#? int()
dic2[r'asdf']

View File

@@ -31,12 +31,12 @@ def fu(a, b, c, *args, **kwargs):
exe = fu(list, c=set, b=3, d='')
#? ['append']
exe[0].append
#? ['real']
exe[1].real
#? ['union']
exe[2].union
#? list()
exe[0]
#? int()
exe[1]
#? set
exe[2]
#? str()
exe[4]['d']

View File

@@ -11,8 +11,8 @@ func = array
#? []
func.first_param
#? ['append']
array().append
#? list()
array()
#? ['array']
arr
@@ -21,22 +21,22 @@ arr
def inputs(param):
return param
#? ['append']
inputs(list).append
#? list()
inputs(list)
def variable_middle():
var = 3
return var
#? ['real']
variable_middle().real
#? int()
variable_middle()
def variable_rename(param):
var = param
return var
#? ['imag']
variable_rename(1).imag
#? int()
variable_rename(1)
# -----------------
# double execution
@@ -44,8 +44,8 @@ variable_rename(1).imag
def double_exe(param):
return param
#? ['upper']
variable_rename(double_exe)("").upper
#? str()
variable_rename(double_exe)("")
# -> shouldn't work (and throw no error)
#? []
@@ -116,13 +116,12 @@ func(1.0)[1]
def a():
l = 3
def func_b():
#? ['real']
l.real
#? str()
l = ''
#? ['func_b']
func_b
#? ['real']
l.real
#? int()
l
# -----------------
# *args
@@ -167,8 +166,8 @@ def kwargs_func(**kwargs):
return kwargs
exe = kwargs_func(a=3,b=4)
#? ['items']
exe.items
#? dict()
exe
# -----------------
# *args / ** kwargs
@@ -179,16 +178,16 @@ def fu(a=1, b="", *args, **kwargs):
exe = fu(list, 1, "", c=set, d="")
#? ['append']
exe[0].append
#? ['real']
exe[1].real
#? ['index']
exe[2].index
#? ['upper']
exe[2][0].upper
#? ['items']
exe[3].items
#? list()
exe[0]
#? int()
exe[1]
#? tuple()
exe[2]
#? str()
exe[2][0]
#? dict()
exe[3]
#? set()
exe[3]['c']