0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1151: insufficient test coverage for Python

Problem:    Insufficient test coverage for Python.
Solution:   Add more test cases. (Yegappan Lakshmanan, closes #6415)
This commit is contained in:
Bram Moolenaar
2020-07-07 20:50:39 +02:00
parent bb790dcc46
commit 0ab55d6201
3 changed files with 52 additions and 0 deletions

View File

@@ -623,6 +623,9 @@ func Test_python_slice_assignment()
py l = vim.bindeval('l') py l = vim.bindeval('l')
py l[2:2:1] = () py l[2:2:1] = ()
call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l) call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l)
call AssertException(["py x = l[10:11:0]"],
\ "Vim(python):ValueError: slice step cannot be zero")
endfunc endfunc
" Locked variables " Locked variables
@@ -809,6 +812,10 @@ func Test_python_vim_bindeval()
call assert_equal(0, pyeval("vim.bindeval('v:false')")) call assert_equal(0, pyeval("vim.bindeval('v:false')"))
call assert_equal(v:none, pyeval("vim.bindeval('v:null')")) call assert_equal(v:none, pyeval("vim.bindeval('v:null')"))
call assert_equal(v:none, pyeval("vim.bindeval('v:none')")) call assert_equal(v:none, pyeval("vim.bindeval('v:none')"))
" channel/job
call assert_equal(v:none, pyeval("vim.bindeval('test_null_channel()')"))
call assert_equal(v:none, pyeval("vim.bindeval('test_null_job()')"))
endfunc endfunc
" threading " threading
@@ -1402,6 +1409,20 @@ func Test_python_buffer()
call assert_equal([], pyeval('b[2:0]')) call assert_equal([], pyeval('b[2:0]'))
call assert_equal([], pyeval('b[10:12]')) call assert_equal([], pyeval('b[10:12]'))
call assert_equal([], pyeval('b[-10:-8]')) call assert_equal([], pyeval('b[-10:-8]'))
call AssertException(["py x = b[0:3:0]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py b[0:3:0] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py x = b[{}]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'dict'")
call AssertException(["py b[{}] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'dict'")
" Test for getting lines using a range
call AssertException(["py x = b.range(0,3)[0:2:0]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py b.range(0,3)[0:2:0] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
" Tests BufferAppend and BufferItem " Tests BufferAppend and BufferItem
py cb.append(b[0]) py cb.append(b[0])
@@ -1512,6 +1533,9 @@ func Test_python_buffer()
py vim.current.buffer[:] = [] py vim.current.buffer[:] = []
call assert_equal([''], getline(1, '$')) call assert_equal([''], getline(1, '$'))
" Test for buffer marks
call assert_equal(v:none, pyeval("vim.current.buffer.mark('r')"))
" Test for modifying a 'nomodifiable' buffer " Test for modifying a 'nomodifiable' buffer
setlocal nomodifiable setlocal nomodifiable
call AssertException(["py vim.current.buffer[0] = 'abc'"], call AssertException(["py vim.current.buffer[0] = 'abc'"],
@@ -2408,6 +2432,7 @@ func Test_python_chdir()
call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir', call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir',
\ 'Xfile'], getline(2, '$')) \ 'Xfile'], getline(2, '$'))
close! close!
call AssertException(["py vim.chdir(None)"], "Vim(python):TypeError:")
endfunc endfunc
" Test errors " Test errors

View File

@@ -798,6 +798,9 @@ func Test_python3_slice_assignment()
py3 l = vim.bindeval('l') py3 l = vim.bindeval('l')
py3 l[2:2:1] = () py3 l[2:2:1] = ()
call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l) call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l)
call AssertException(["py3 x = l[10:11:0]"],
\ "Vim(py3):ValueError: slice step cannot be zero")
endfunc endfunc
" Locked variables " Locked variables
@@ -987,6 +990,10 @@ func Test_python3_vim_bindeval()
call assert_equal(0, py3eval("vim.bindeval('v:false')")) call assert_equal(0, py3eval("vim.bindeval('v:false')"))
call assert_equal(v:none, py3eval("vim.bindeval('v:null')")) call assert_equal(v:none, py3eval("vim.bindeval('v:null')"))
call assert_equal(v:none, py3eval("vim.bindeval('v:none')")) call assert_equal(v:none, py3eval("vim.bindeval('v:none')"))
" channel/job
call assert_equal(v:none, py3eval("vim.bindeval('test_null_channel()')"))
call assert_equal(v:none, py3eval("vim.bindeval('test_null_job()')"))
endfunc endfunc
" threading " threading
@@ -1580,6 +1587,20 @@ func Test_python3_buffer()
call assert_equal([], py3eval('b[2:0]')) call assert_equal([], py3eval('b[2:0]'))
call assert_equal([], py3eval('b[10:12]')) call assert_equal([], py3eval('b[10:12]'))
call assert_equal([], py3eval('b[-10:-8]')) call assert_equal([], py3eval('b[-10:-8]'))
call AssertException(["py3 x = b[0:3:0]"],
\ 'Vim(py3):ValueError: slice step cannot be zero')
call AssertException(["py3 b[0:3:0] = 'abc'"],
\ 'Vim(py3):ValueError: slice step cannot be zero')
call AssertException(["py3 x = b[{}]"],
\ 'Vim(py3):TypeError: index must be int or slice, not dict')
call AssertException(["py3 b[{}] = 'abc'"],
\ 'Vim(py3):TypeError: index must be int or slice, not dict')
" Test for getting lines using a range
call AssertException(["py3 x = b.range(0,3)[0:2:0]"],
\ "Vim(py3):ValueError: slice step cannot be zero")
call AssertException(["py3 b.range(0,3)[0:2:0] = 'abc'"],
\ "Vim(py3):ValueError: slice step cannot be zero")
" Tests BufferAppend and BufferItem " Tests BufferAppend and BufferItem
py3 cb.append(b[0]) py3 cb.append(b[0])
@@ -1690,6 +1711,9 @@ func Test_python3_buffer()
py3 vim.current.buffer[:] = [] py3 vim.current.buffer[:] = []
call assert_equal([''], getline(1, '$')) call assert_equal([''], getline(1, '$'))
" Test for buffer marks
call assert_equal(v:none, py3eval("vim.current.buffer.mark('r')"))
" Test for modifying a 'nomodifiable' buffer " Test for modifying a 'nomodifiable' buffer
setlocal nomodifiable setlocal nomodifiable
call AssertException(["py3 vim.current.buffer[0] = 'abc'"], call AssertException(["py3 vim.current.buffer[0] = 'abc'"],
@@ -2578,6 +2602,7 @@ func Test_python3_chdir()
call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile', call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile',
\"b'testdir'", 'Xfile'], getline(2, '$')) \"b'testdir'", 'Xfile'], getline(2, '$'))
close! close!
call AssertException(["py3 vim.chdir(None)"], "Vim(py3):TypeError:")
endfunc endfunc
" Test errors " Test errors

View File

@@ -754,6 +754,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 */
/**/
1151,
/**/ /**/
1150, 1150,
/**/ /**/