mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
vim-patch:8.1.0978: blob not tested with Perl
Problem: Blob not tested with Perl.
Solution: Add more test coverage. Fixes a crash. (Dominique Pelle,
closes vim/vim#4037)
2472ae81df
This commit is only to match test_perl.vim from Vim 8.1.0978
so that test_perl.vim patches are easier to port.
This commit is contained in:
@@ -4,6 +4,7 @@ if !has('perl') || has('win32')
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" FIXME: RunTest don't see any error when Perl abort...
|
||||||
perl $SIG{__WARN__} = sub { die "Unexpected warnings from perl: @_" };
|
perl $SIG{__WARN__} = sub { die "Unexpected warnings from perl: @_" };
|
||||||
|
|
||||||
func Test_change_buffer()
|
func Test_change_buffer()
|
||||||
@@ -23,11 +24,15 @@ func Test_evaluate_list()
|
|||||||
$l = VIM::Eval("l");
|
$l = VIM::Eval("l");
|
||||||
$curbuf->Append($curline, $l);
|
$curbuf->Append($curline, $l);
|
||||||
EOF
|
EOF
|
||||||
|
normal j
|
||||||
|
.perldo s|\n|/|g
|
||||||
|
" call assert_equal('abc/def/', getline('$'))
|
||||||
|
call assert_equal('def', getline('$'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
funct Test_VIM_Blob()
|
funct Test_VIM_Blob()
|
||||||
call assert_equal('0z', perleval('VIM::Blob("")'))
|
call assert_equal('0z', perleval('VIM::Blob("")'))
|
||||||
"call assert_equal('0z31326162', 'VIM::Blob("12ab")'->perleval())
|
call assert_equal('0z31326162', perleval('VIM::Blob("12ab")'))
|
||||||
call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
|
call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
|
||||||
call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
|
call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
|
||||||
endfunc
|
endfunc
|
||||||
@@ -46,7 +51,6 @@ func Test_buffer_Append()
|
|||||||
new
|
new
|
||||||
perl $curbuf->Append(1, '1')
|
perl $curbuf->Append(1, '1')
|
||||||
perl $curbuf->Append(2, '2', '3', '4')
|
perl $curbuf->Append(2, '2', '3', '4')
|
||||||
call assert_equal(['', '1', '2', '3', '4'], getline(1, '$'))
|
|
||||||
perl @l = ('5' ..'7')
|
perl @l = ('5' ..'7')
|
||||||
perl $curbuf->Append(0, @l)
|
perl $curbuf->Append(0, @l)
|
||||||
call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
|
call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
|
||||||
@@ -114,7 +118,7 @@ func Test_VIM_Windows()
|
|||||||
perl $curbuf->Append(0, $winnr, scalar(@winlist))
|
perl $curbuf->Append(0, $winnr, scalar(@winlist))
|
||||||
call assert_equal(['2', '2', ''], getline(1, '$'))
|
call assert_equal(['2', '2', ''], getline(1, '$'))
|
||||||
|
|
||||||
"" VIM::Windows() with window number argument.
|
" VIM::Windows() with window number argument.
|
||||||
perl (VIM::Windows(VIM::Eval('winnr()')))[0]->Buffer()->Set(1, 'bar')
|
perl (VIM::Windows(VIM::Eval('winnr()')))[0]->Buffer()->Set(1, 'bar')
|
||||||
call assert_equal('bar', getline(1))
|
call assert_equal('bar', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -133,10 +137,20 @@ func Test_VIM_Buffers()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func <SID>catch_peval(expr)
|
||||||
|
try
|
||||||
|
call perleval(a:expr)
|
||||||
|
catch
|
||||||
|
return v:exception
|
||||||
|
endtry
|
||||||
|
call assert_report('no exception for `perleval("'.a:expr.'")`')
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_perleval()
|
func Test_perleval()
|
||||||
call assert_false(perleval('undef'))
|
call assert_false(perleval('undef'))
|
||||||
|
|
||||||
"" scalar
|
" scalar
|
||||||
call assert_equal(0, perleval('0'))
|
call assert_equal(0, perleval('0'))
|
||||||
call assert_equal(2, perleval('2'))
|
call assert_equal(2, perleval('2'))
|
||||||
call assert_equal(-2, perleval('-2'))
|
call assert_equal(-2, perleval('-2'))
|
||||||
@@ -146,9 +160,12 @@ func Test_perleval()
|
|||||||
call assert_equal(2, perleval('2.5'))
|
call assert_equal(2, perleval('2.5'))
|
||||||
end
|
end
|
||||||
|
|
||||||
call assert_equal('abc', perleval('"abc"'))
|
" sandbox call assert_equal(2, perleval('2'))
|
||||||
|
|
||||||
"" ref
|
call assert_equal('abc', perleval('"abc"'))
|
||||||
|
" call assert_equal("abc\ndef", perleval('"abc\0def"'))
|
||||||
|
|
||||||
|
" ref
|
||||||
call assert_equal([], perleval('[]'))
|
call assert_equal([], perleval('[]'))
|
||||||
call assert_equal(['word', 42, [42],{}], perleval('["word", 42, [42], {}]'))
|
call assert_equal(['word', 42, [42],{}], perleval('["word", 42, [42], {}]'))
|
||||||
|
|
||||||
@@ -156,13 +173,19 @@ func Test_perleval()
|
|||||||
call assert_equal({'foo': 'bar'}, perleval('{foo => "bar"}'))
|
call assert_equal({'foo': 'bar'}, perleval('{foo => "bar"}'))
|
||||||
|
|
||||||
perl our %h; our @a;
|
perl our %h; our @a;
|
||||||
let a = perleval('[\%h, \%h, \@a, \@a]')
|
let a = perleval('[\(%h, %h, @a, @a)]')
|
||||||
echo a
|
" call assert_true((a[0] is a[1]))
|
||||||
call assert_equal(a[0], a[1])
|
call assert_equal(a[0], a[1])
|
||||||
|
" call assert_true((a[2] is a[3]))
|
||||||
call assert_equal(a[2], a[3])
|
call assert_equal(a[2], a[3])
|
||||||
perl undef %h; undef @a;
|
perl undef %h; undef @a;
|
||||||
|
|
||||||
|
" call assert_true(<SID>catch_peval('{"" , 0}') =~ 'Malformed key Dictionary')
|
||||||
|
" call assert_true(<SID>catch_peval('{"\0" , 0}') =~ 'Malformed key Dictionary')
|
||||||
|
" call assert_true(<SID>catch_peval('{"foo\0bar" , 0}') =~ 'Malformed key Dictionary')
|
||||||
|
|
||||||
call assert_equal('*VIM', perleval('"*VIM"'))
|
call assert_equal('*VIM', perleval('"*VIM"'))
|
||||||
|
" call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_perldo()
|
func Test_perldo()
|
||||||
@@ -179,7 +202,7 @@ func Test_perldo()
|
|||||||
perldo VIM::DoCommand("%d_")
|
perldo VIM::DoCommand("%d_")
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
"" Check switching to another buffer does not trigger ml_get error.
|
" Check switching to another buffer does not trigger ml_get error.
|
||||||
new
|
new
|
||||||
let wincount = winnr('$')
|
let wincount = winnr('$')
|
||||||
call setline(1, ['one', 'two', 'three'])
|
call setline(1, ['one', 'two', 'three'])
|
||||||
@@ -198,6 +221,69 @@ func Test_VIM_package()
|
|||||||
call assert_true(&et)
|
call assert_true(&et)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_stdio()
|
||||||
|
throw 'skipped: TODO: '
|
||||||
|
redir =>l:out
|
||||||
|
perl <<EOF
|
||||||
|
VIM::Msg("&VIM::Msg");
|
||||||
|
print "STDOUT";
|
||||||
|
print STDERR "STDERR";
|
||||||
|
EOF
|
||||||
|
redir END
|
||||||
|
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Run first to get a clean namespace
|
||||||
|
func Test_000_SvREFCNT()
|
||||||
|
throw 'skipped: TODO: '
|
||||||
|
for i in range(8)
|
||||||
|
exec 'new X'.i
|
||||||
|
endfor
|
||||||
|
new t
|
||||||
|
perl <<--perl
|
||||||
|
#line 5 "Test_000_SvREFCNT()"
|
||||||
|
my ($b, $w);
|
||||||
|
|
||||||
|
my $num = 0;
|
||||||
|
for ( 0 .. 100 ) {
|
||||||
|
if ( ++$num >= 8 ) { $num = 0 }
|
||||||
|
VIM::DoCommand("buffer X$num");
|
||||||
|
$b = $curbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIM::DoCommand("buffer t");
|
||||||
|
|
||||||
|
$b = $curbuf for 0 .. 100;
|
||||||
|
$w = $curwin for 0 .. 100;
|
||||||
|
() = VIM::Buffers for 0 .. 100;
|
||||||
|
() = VIM::Windows for 0 .. 100;
|
||||||
|
|
||||||
|
VIM::DoCommand('bw! t');
|
||||||
|
if (exists &Internals::SvREFCNT) {
|
||||||
|
my $cb = Internals::SvREFCNT($$b);
|
||||||
|
my $cw = Internals::SvREFCNT($$w);
|
||||||
|
VIM::Eval("assert_equal(2, $cb, 'T1')");
|
||||||
|
VIM::Eval("assert_equal(2, $cw, 'T2')");
|
||||||
|
my $strongref;
|
||||||
|
foreach ( VIM::Buffers, VIM::Windows ) {
|
||||||
|
VIM::DoCommand("%bw!");
|
||||||
|
my $c = Internals::SvREFCNT($_);
|
||||||
|
VIM::Eval("assert_equal(2, $c, 'T3')");
|
||||||
|
$c = Internals::SvREFCNT($$_);
|
||||||
|
next if $c == 2 && !$strongref++;
|
||||||
|
VIM::Eval("assert_equal(1, $c, 'T4')");
|
||||||
|
}
|
||||||
|
$cb = Internals::SvREFCNT($$curbuf);
|
||||||
|
$cw = Internals::SvREFCNT($$curwin);
|
||||||
|
VIM::Eval("assert_equal(3, $cb, 'T5')");
|
||||||
|
VIM::Eval("assert_equal(3, $cw, 'T6')");
|
||||||
|
}
|
||||||
|
VIM::Eval("assert_false($$b)");
|
||||||
|
VIM::Eval("assert_false($$w)");
|
||||||
|
--perl
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_set_cursor()
|
func Test_set_cursor()
|
||||||
" Check that setting the cursor position works.
|
" Check that setting the cursor position works.
|
||||||
new
|
new
|
||||||
|
Reference in New Issue
Block a user