To: vim_dev@googlegroups.com
Subject: Patch 7.3.659
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.659
Problem:    Recent Python changes are not tested.
Solution:   Add tests for Python bindings. (ZyX)
Files:	    src/testdir/test86.in, src/testdir/test86.ok,
	    src/testdir/test87.in, src/testdir/test87.ok


*** ../vim-7.3.658/src/testdir/test86.in	2012-06-29 12:54:32.000000000 +0200
--- src/testdir/test86.in	2012-09-05 19:11:36.000000000 +0200
***************
*** 176,203 ****
  :else
  :   $put ='[0.0, 0.0]'
  :endif
  :"
  :" pyeval()
  :let l=pyeval('range(3)')
  :$put =string(l)
  :let d=pyeval('{"a": "b", "c": 1, "d": ["e"]}')
  :$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')
  :   let f=pyeval('0.0')
  :   $put =string(f)
  :else
  :   $put ='0.0'
  :endif
  :endfun
  :"
  :call Test()
--- 176,237 ----
  :else
  :   $put ='[0.0, 0.0]'
  :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()
  :let l=pyeval('range(3)')
  :$put =string(l)
  :let d=pyeval('{"a": "b", "c": 1, "d": ["e"]}')
  :$put =sort(items(d))
  :if has('float')
  :   let f=pyeval('0.0')
  :   $put =string(f)
  :else
  :   $put ='0.0'
  :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
  :"
  :call Test()
*** ../vim-7.3.658/src/testdir/test86.ok	2012-06-29 12:54:32.000000000 +0200
--- src/testdir/test86.ok	2012-09-05 19:11:36.000000000 +0200
***************
*** 38,47 ****
  Vim(python):E725:
  Vim(python):E117:
  [0.0, 0.0]
  [0, 1, 2]
  ['a', 'b']
  ['c', 1]
  ['d', ['e']]
- Vim(let):E858:
- Vim(let):E859:
  0.0
--- 38,55 ----
  Vim(python):E725:
  Vim(python):E117:
  [0.0, 0.0]
+ IndexError
+ TypeError
+ TypeError
+ ValueError
+ TypeError
+ TypeError
  [0, 1, 2]
  ['a', 'b']
  ['c', 1]
  ['d', ['e']]
  0.0
+ "\0":	Vim(let):E859:
+ {"\0": 1}:	Vim(let):E859:
+ undefined_name:	Vim(let):E858:
+ vim:	Vim(let):E859:
*** ../vim-7.3.658/src/testdir/test87.in	2012-06-29 12:54:32.000000000 +0200
--- src/testdir/test87.in	2012-09-05 19:11:36.000000000 +0200
***************
*** 176,203 ****
  :else
  :   $put ='[0.0, 0.0]'
  :endif
  :"
  :" py3eval()
  :let l=py3eval('[0, 1, 2]')
  :$put =string(l)
  :let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}')
  :$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')
  :   let f=py3eval('0.0')
  :   $put =string(f)
  :else
  :   $put ='0.0'
  :endif
  :endfun
  :"
  :call Test()
--- 176,237 ----
  :else
  :   $put ='[0.0, 0.0]'
  :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()
  :let l=py3eval('[0, 1, 2]')
  :$put =string(l)
  :let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}')
  :$put =sort(items(d))
  :if has('float')
  :   let f=py3eval('0.0')
  :   $put =string(f)
  :else
  :   $put ='0.0'
  :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
  :"
  :call Test()
*** ../vim-7.3.658/src/testdir/test87.ok	2012-06-29 12:54:32.000000000 +0200
--- src/testdir/test87.ok	2012-09-05 19:11:36.000000000 +0200
***************
*** 38,47 ****
  Vim(py3):E725:
  Vim(py3):E117:
  [0.0, 0.0]
  [0, 1, 2]
  ['a', 'b']
  ['c', 1]
  ['d', ['e']]
- Vim(let):E860:
- Vim(let):E861:
  0.0
--- 38,55 ----
  Vim(py3):E725:
  Vim(py3):E117:
  [0.0, 0.0]
+ IndexError
+ TypeError
+ TypeError
+ ValueError
+ TypeError
+ TypeError
  [0, 1, 2]
  ['a', 'b']
  ['c', 1]
  ['d', ['e']]
  0.0
+ "\0":	Vim(let):E861:
+ {"\0": 1}:	Vim(let):E861:
+ undefined_name:	Vim(let):E860:
+ vim:	Vim(let):E861:
*** ../vim-7.3.658/src/version.c	2012-09-05 19:09:06.000000000 +0200
--- src/version.c	2012-09-05 19:16:52.000000000 +0200
***************
*** 721,722 ****
--- 721,724 ----
  {   /* Add new patch number below this line */
+ /**/
+     659,
  /**/

-- 
DEAD PERSON:  I don't want to go in the cart!
CUSTOMER:     Oh, don't be such a baby.
MORTICIAN:    I can't take him...
DEAD PERSON:  I feel fine!
CUSTOMER:     Oh, do us a favor...
MORTICIAN:    I can't.
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
