0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

updated for version 7.3.659

Problem:    Recent Python changes are not tested.
Solution:   Add tests for Python bindings. (ZyX)
This commit is contained in:
Bram Moolenaar 2012-09-05 19:17:42 +02:00
parent afa6b9af86
commit c11073c9aa
5 changed files with 110 additions and 24 deletions

View File

@ -176,28 +176,62 @@ STARTTEST
:else :else
: $put ='[0.0, 0.0]' : $put ='[0.0, 0.0]'
:endif :endif
:let messages=[]
:py <<EOF
d=vim.bindeval('{}')
m=vim.bindeval('messages')
try:
d['abc']
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['abc']="\0"
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['abc']=vim
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d[b'a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
EOF
:$put =messages
:" :"
:" pyeval() :" pyeval()
:let l=pyeval('range(3)') :let l=pyeval('range(3)')
:$put =string(l) :$put =string(l)
:let d=pyeval('{"a": "b", "c": 1, "d": ["e"]}') :let d=pyeval('{"a": "b", "c": 1, "d": ["e"]}')
:$put =sort(items(d)) :$put =sort(items(d))
:try
: let undef=pyeval('undefined_name')
:catch
: $put =v:exception[:13]
:endtry
:try
: let vim=pyeval('vim')
:catch
: $put =v:exception[:13]
:endtry
:if has('float') :if has('float')
: let f=pyeval('0.0') : let f=pyeval('0.0')
: $put =string(f) : $put =string(f)
:else :else
: $put ='0.0' : $put ='0.0'
:endif :endif
:" Invalid values:
:for e in ['"\0"', '{"\0": 1}', 'undefined_name', 'vim']
: try
: let v=pyeval(e)
: catch
: let toput=e.":\t".v:exception[:13]
: $put =toput
: endtry
:endfor
:endfun :endfun
:" :"
:call Test() :call Test()

View File

@ -38,10 +38,18 @@ Vim(put):E684:
Vim(python):E725: Vim(python):E725:
Vim(python):E117: Vim(python):E117:
[0.0, 0.0] [0.0, 0.0]
IndexError
TypeError
TypeError
ValueError
TypeError
TypeError
[0, 1, 2] [0, 1, 2]
['a', 'b'] ['a', 'b']
['c', 1] ['c', 1]
['d', ['e']] ['d', ['e']]
Vim(let):E858:
Vim(let):E859:
0.0 0.0
"\0": Vim(let):E859:
{"\0": 1}: Vim(let):E859:
undefined_name: Vim(let):E858:
vim: Vim(let):E859:

View File

@ -176,28 +176,62 @@ STARTTEST
:else :else
: $put ='[0.0, 0.0]' : $put ='[0.0, 0.0]'
:endif :endif
:let messages=[]
:py3 <<EOF
d=vim.bindeval('{}')
m=vim.bindeval('messages')
try:
d['abc']
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['abc']="\0"
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['abc']=vim
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d[b'a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
EOF
:$put =messages
:" :"
:" py3eval() :" py3eval()
:let l=py3eval('[0, 1, 2]') :let l=py3eval('[0, 1, 2]')
:$put =string(l) :$put =string(l)
:let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}') :let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}')
:$put =sort(items(d)) :$put =sort(items(d))
:try
: let undef=py3eval('undefined_name')
:catch
: $put =v:exception[:13]
:endtry
:try
: let vim=py3eval('vim')
:catch
: $put =v:exception[:13]
:endtry
:if has('float') :if has('float')
: let f=py3eval('0.0') : let f=py3eval('0.0')
: $put =string(f) : $put =string(f)
:else :else
: $put ='0.0' : $put ='0.0'
:endif :endif
:" Invalid values:
:for e in ['"\0"', '{"\0": 1}', 'undefined_name', 'vim']
: try
: let v=py3eval(e)
: catch
: let toput=e.":\t".v:exception[:13]
: $put =toput
: endtry
:endfor
:endfun :endfun
:" :"
:call Test() :call Test()

View File

@ -38,10 +38,18 @@ Vim(put):E684:
Vim(py3):E725: Vim(py3):E725:
Vim(py3):E117: Vim(py3):E117:
[0.0, 0.0] [0.0, 0.0]
IndexError
TypeError
TypeError
ValueError
TypeError
TypeError
[0, 1, 2] [0, 1, 2]
['a', 'b'] ['a', 'b']
['c', 1] ['c', 1]
['d', ['e']] ['d', ['e']]
Vim(let):E860:
Vim(let):E861:
0.0 0.0
"\0": Vim(let):E861:
{"\0": 1}: Vim(let):E861:
undefined_name: Vim(let):E860:
vim: Vim(let):E861:

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
659,
/**/ /**/
658, 658,
/**/ /**/