Mercurial > vim
comparison src/testdir/test_perl.vim @ 24616:ed4d7ab9dcdc v8.2.2847
patch 8.2.2847: Perl not tested sufficiently
Commit: https://github.com/vim/vim/commit/588cf7547bafaff46a82bc125d05d24a1cedf827
Author: Dominique Pelle <dominique.pelle@gmail.com>
Date: Mon May 10 23:49:39 2021 +0200
patch 8.2.2847: Perl not tested sufficiently
Problem: Perl not tested sufficiently.
Solution: Add test. Also test W17. (Dominique Pell?, closes https://github.com/vim/vim/issues/8193)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 11 May 2021 00:00:09 +0200 |
parents | 4637f7a4c753 |
children | 91b2386b9d9e |
comparison
equal
deleted
inserted
replaced
24615:ae9123ea11af | 24616:ed4d7ab9dcdc |
---|---|
1 " Tests for Perl interface | 1 " Tests for Perl interface |
2 | 2 |
3 source check.vim | 3 source check.vim |
4 source shared.vim | |
4 CheckFeature perl | 5 CheckFeature perl |
5 | 6 |
6 " FIXME: RunTest don't see any error when Perl abort... | 7 " FIXME: RunTest don't see any error when Perl abort... |
7 perl $SIG{__WARN__} = sub { die "Unexpected warnings from perl: @_" }; | 8 perl $SIG{__WARN__} = sub { die "Unexpected warnings from perl: @_" }; |
8 | 9 |
50 perl $curbuf->Append(1, '1') | 51 perl $curbuf->Append(1, '1') |
51 perl $curbuf->Append(2, '2', '3', '4') | 52 perl $curbuf->Append(2, '2', '3', '4') |
52 perl @l = ('5' ..'7') | 53 perl @l = ('5' ..'7') |
53 perl $curbuf->Append(0, @l) | 54 perl $curbuf->Append(0, @l) |
54 call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$')) | 55 call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$')) |
56 | |
57 perl $curbuf->Append(0) | |
58 call assert_match('^Usage: VIBUF::Append(vimbuf, lnum, @lines) at .* line 1\.$', | |
59 \ GetMessages()[-1]) | |
60 | |
55 bwipe! | 61 bwipe! |
56 endfunc | 62 endfunc |
57 | 63 |
58 func Test_buffer_Set() | 64 func Test_buffer_Set() |
59 new | 65 new |
60 call setline(1, ['1', '2', '3', '4', '5']) | 66 call setline(1, ['1', '2', '3', '4', '5']) |
61 perl $curbuf->Set(2, 'a', 'b', 'c') | 67 perl $curbuf->Set(2, 'a', 'b', 'c') |
62 perl $curbuf->Set(4, 'A', 'B', 'C') | 68 perl $curbuf->Set(4, 'A', 'B', 'C') |
63 call assert_equal(['1', 'a', 'b', 'A', 'B'], getline(1, '$')) | 69 call assert_equal(['1', 'a', 'b', 'A', 'B'], getline(1, '$')) |
70 | |
71 perl $curbuf->Set(0) | |
72 call assert_match('^Usage: VIBUF::Set(vimbuf, lnum, @lines) at .* line 1\.$', | |
73 \ GetMessages()[-1]) | |
74 | |
64 bwipe! | 75 bwipe! |
65 endfunc | 76 endfunc |
66 | 77 |
67 func Test_buffer_Get() | 78 func Test_buffer_Get() |
68 new | 79 new |
208 new | 219 new |
209 call setline(1, ['one', 'two', 'three']) | 220 call setline(1, ['one', 'two', 'three']) |
210 perldo VIM::DoCommand("%d_") | 221 perldo VIM::DoCommand("%d_") |
211 bwipe! | 222 bwipe! |
212 | 223 |
224 " Check a Perl expression which gives an error. | |
225 new | |
226 call setline(1, 'one') | |
227 perldo 1/0 | |
228 call assert_match('^Illegal division by zero at .* line 1\.$', GetMessages()[-1]) | |
229 bwipe! | |
230 | |
213 " Check switching to another buffer does not trigger ml_get error. | 231 " Check switching to another buffer does not trigger ml_get error. |
214 new | 232 new |
215 let wincount = winnr('$') | 233 let wincount = winnr('$') |
216 call setline(1, ['one', 'two', 'three']) | 234 call setline(1, ['one', 'two', 'three']) |
217 perldo VIM::DoCommand("new") | 235 perldo VIM::DoCommand("new") |
229 endfunc | 247 endfunc |
230 | 248 |
231 func Test_stdio() | 249 func Test_stdio() |
232 redir =>l:out | 250 redir =>l:out |
233 perl << trim EOF | 251 perl << trim EOF |
234 VIM::Msg("&VIM::Msg"); | 252 VIM::Msg("VIM::Msg"); |
253 VIM::Msg("VIM::Msg Error", "Error"); | |
235 print "STDOUT"; | 254 print "STDOUT"; |
236 print STDERR "STDERR"; | 255 print STDERR "STDERR"; |
237 EOF | 256 EOF |
238 redir END | 257 redir END |
239 call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n")) | 258 call assert_equal(['VIM::Msg', 'VIM::Msg Error', 'STDOUT', 'STDERR'], split(l:out, "\n")) |
240 endfunc | 259 endfunc |
241 | 260 |
242 " Run first to get a clean namespace | 261 " Run first to get a clean namespace |
243 func Test_000_SvREFCNT() | 262 func Test_000_SvREFCNT() |
244 for i in range(8) | 263 for i in range(8) |