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

View File

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

View File

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