mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.0.0350: not enough test coverage for Perl
Problem: Not enough test coverage for Perl. Solution: Add more Perl tests. (Dominique Perl, closes #1500)
This commit is contained in:
@@ -26,7 +26,107 @@ EOF
|
|||||||
call assert_equal('abc/def/', getline('$'))
|
call assert_equal('abc/def/', getline('$'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
fu <SID>catch_peval(expr)
|
func Test_buffer_Delete()
|
||||||
|
new
|
||||||
|
call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
|
||||||
|
perl $curbuf->Delete(7)
|
||||||
|
perl $curbuf->Delete(2, 5)
|
||||||
|
perl $curbuf->Delete(10)
|
||||||
|
call assert_equal(['a', 'f', 'h'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Append()
|
||||||
|
new
|
||||||
|
perl $curbuf->Append(1, '1')
|
||||||
|
perl $curbuf->Append(2, '2', '3', '4')
|
||||||
|
perl @l = ('5' ..'7')
|
||||||
|
perl $curbuf->Append(0, @l)
|
||||||
|
call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Set()
|
||||||
|
new
|
||||||
|
call setline(1, ['1', '2', '3', '4', '5'])
|
||||||
|
perl $curbuf->Set(2, 'a', 'b', 'c')
|
||||||
|
perl $curbuf->Set(4, 'A', 'B', 'C')
|
||||||
|
call assert_equal(['1', 'a', 'b', 'A', 'B'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Get()
|
||||||
|
new
|
||||||
|
call setline(1, ['1', '2', '3', '4'])
|
||||||
|
call assert_equal('2:3', perleval('join(":", $curbuf->Get(2, 3))'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Count()
|
||||||
|
new
|
||||||
|
call setline(1, ['a', 'b', 'c'])
|
||||||
|
call assert_equal(3, perleval('$curbuf->Count()'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Name()
|
||||||
|
new
|
||||||
|
call assert_equal('', perleval('$curbuf->Name()'))
|
||||||
|
bwipe!
|
||||||
|
new Xfoo
|
||||||
|
call assert_equal('Xfoo', perleval('$curbuf->Name()'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_buffer_Number()
|
||||||
|
call assert_equal(bufnr('%'), perleval('$curbuf->Number()'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_Cursor()
|
||||||
|
new
|
||||||
|
call setline(1, ['line1', 'line2'])
|
||||||
|
perl $curwin->Cursor(2, 3)
|
||||||
|
call assert_equal('2:3', perleval('join(":", $curwin->Cursor())'))
|
||||||
|
" Col is numbered from 0 in Perl, and from 1 in Vim script.
|
||||||
|
call assert_equal([0, 2, 4, 0], getpos('.'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_SetHeight()
|
||||||
|
new
|
||||||
|
perl $curwin->SetHeight(2)
|
||||||
|
call assert_equal(2, winheight(0))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_VIM_Windows()
|
||||||
|
new
|
||||||
|
" VIM::Windows() without argument in scalar and list context.
|
||||||
|
perl $winnr = VIM::Windows()
|
||||||
|
perl @winlist = VIM::Windows()
|
||||||
|
perl $curbuf->Append(0, $winnr, scalar(@winlist))
|
||||||
|
call assert_equal(['2', '2', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
" VIM::Windows() with window number argument.
|
||||||
|
perl VIM::Windows(VIM::Eval('winnr()'))->Buffer()->Set(1, 'bar')
|
||||||
|
call assert_equal('bar', getline(1))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_VIM_Buffers()
|
||||||
|
new Xbar
|
||||||
|
" VIM::Buffers() without argument in scalar and list context.
|
||||||
|
perl $nbuf = VIM::Buffers()
|
||||||
|
perl @buflist = VIM::Buffers()
|
||||||
|
|
||||||
|
" VIM::Buffers() with argument.
|
||||||
|
perl $mybuf = (VIM::Buffers('Xbar'))[0]
|
||||||
|
perl $mybuf->Append(0, $nbuf, scalar(@buflist))
|
||||||
|
call assert_equal(['2', '2', ''], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func <SID>catch_peval(expr)
|
||||||
try
|
try
|
||||||
call perleval(a:expr)
|
call perleval(a:expr)
|
||||||
catch
|
catch
|
||||||
@@ -36,7 +136,7 @@ fu <SID>catch_peval(expr)
|
|||||||
return ''
|
return ''
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_perleval()
|
func Test_perleval()
|
||||||
call assert_false(perleval('undef'))
|
call assert_false(perleval('undef'))
|
||||||
|
|
||||||
" scalar
|
" scalar
|
||||||
@@ -75,7 +175,7 @@ function Test_perleval()
|
|||||||
call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
|
call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_perldo()
|
func Test_perldo()
|
||||||
sp __TEST__
|
sp __TEST__
|
||||||
exe 'read ' g:testname
|
exe 'read ' g:testname
|
||||||
perldo s/perl/vieux_chameau/g
|
perldo s/perl/vieux_chameau/g
|
||||||
@@ -99,7 +199,7 @@ function Test_perldo()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_VIM_package()
|
func Test_VIM_package()
|
||||||
perl VIM::DoCommand('let l:var = "foo"')
|
perl VIM::DoCommand('let l:var = "foo"')
|
||||||
call assert_equal(l:var, 'foo')
|
call assert_equal(l:var, 'foo')
|
||||||
|
|
||||||
@@ -108,7 +208,7 @@ function Test_VIM_package()
|
|||||||
call assert_true(&et)
|
call assert_true(&et)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_stdio()
|
func Test_stdio()
|
||||||
redir =>l:out
|
redir =>l:out
|
||||||
perl <<EOF
|
perl <<EOF
|
||||||
VIM::Msg("&VIM::Msg");
|
VIM::Msg("&VIM::Msg");
|
||||||
@@ -119,7 +219,7 @@ EOF
|
|||||||
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
|
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_SvREFCNT()
|
func Test_SvREFCNT()
|
||||||
new t
|
new t
|
||||||
perl <<--perl
|
perl <<--perl
|
||||||
my ($b, $w);
|
my ($b, $w);
|
||||||
|
@@ -764,6 +764,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 */
|
||||||
|
/**/
|
||||||
|
350,
|
||||||
/**/
|
/**/
|
||||||
349,
|
349,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user