annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for Perl interface
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
3 source check.vim
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
4 source shared.vim
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
5 CheckFeature perl
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
7 " FIXME: RunTest don't see any error when Perl abort...
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
8 perl $SIG{__WARN__} = sub { die "Unexpected warnings from perl: @_" };
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
9
7655
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
10 func Test_change_buffer()
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
11 call setline(line('$'), ['1 line 1'])
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
12 perl VIM::DoCommand("normal /^1\n")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
13 perl $curline = VIM::Eval("line('.')")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
14 perl $curbuf->Set($curline, "1 changed line 1")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
15 call assert_equal('1 changed line 1', getline('$'))
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
16 endfunc
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
17
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
18 func Test_evaluate_list()
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
19 call setline(line('$'), ['2 line 2'])
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
20 perl VIM::DoCommand("normal /^2\n")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
21 perl $curline = VIM::Eval("line('.')")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
22 let l = ["abc", "def"]
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
23 perl << EOF
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
24 $l = VIM::Eval("l");
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
25 $curbuf->Append($curline, $l);
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
26 EOF
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
27 normal j
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
28 .perldo s|\n|/|g
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
29 call assert_equal('abc/def/', getline('$'))
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
30 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
15945
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
32 funct Test_VIM_Blob()
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
33 call assert_equal('0z', perleval('VIM::Blob("")'))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
34 call assert_equal('0z31326162', 'VIM::Blob("12ab")'->perleval())
15945
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
35 call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
36 call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
37 endfunc
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
38
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
39 func Test_buffer_Delete()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
40 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
41 call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
42 perl $curbuf->Delete(7)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
43 perl $curbuf->Delete(2, 5)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
44 perl $curbuf->Delete(10)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
45 call assert_equal(['a', 'f', 'h'], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
46 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
47 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
48
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
49 func Test_buffer_Append()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
50 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
51 perl $curbuf->Append(1, '1')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
52 perl $curbuf->Append(2, '2', '3', '4')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
53 perl @l = ('5' ..'7')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
54 perl $curbuf->Append(0, @l)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
55 call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
56
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
57 perl $curbuf->Append(0)
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
58 call assert_match('^Usage: VIBUF::Append(vimbuf, lnum, @lines) at .* line 1\.$',
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
59 \ GetMessages()[-1])
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
60
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
61 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
62 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
63
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
64 func Test_buffer_Set()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
65 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
66 call setline(1, ['1', '2', '3', '4', '5'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
67 perl $curbuf->Set(2, 'a', 'b', 'c')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
68 perl $curbuf->Set(4, 'A', 'B', 'C')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
69 call assert_equal(['1', 'a', 'b', 'A', 'B'], getline(1, '$'))
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
70
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
71 perl $curbuf->Set(0)
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
72 call assert_match('^Usage: VIBUF::Set(vimbuf, lnum, @lines) at .* line 1\.$',
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
73 \ GetMessages()[-1])
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
74
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
75 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
76 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
77
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
78 func Test_buffer_Get()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
79 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
80 call setline(1, ['1', '2', '3', '4'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
81 call assert_equal('2:3', perleval('join(":", $curbuf->Get(2, 3))'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
82 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
83 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
84
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
85 func Test_buffer_Count()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
86 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
87 call setline(1, ['a', 'b', 'c'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
88 call assert_equal(3, perleval('$curbuf->Count()'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
89 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
90 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
91
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
92 func Test_buffer_Name()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
93 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
94 call assert_equal('', perleval('$curbuf->Name()'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
95 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
96 new Xfoo
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
97 call assert_equal('Xfoo', perleval('$curbuf->Name()'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
98 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
99 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
100
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
101 func Test_buffer_Number()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
102 call assert_equal(bufnr('%'), perleval('$curbuf->Number()'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
103 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
104
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
105 func Test_window_Cursor()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
106 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
107 call setline(1, ['line1', 'line2'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
108 perl $curwin->Cursor(2, 3)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
109 call assert_equal('2:3', perleval('join(":", $curwin->Cursor())'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
110 " Col is numbered from 0 in Perl, and from 1 in Vim script.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
111 call assert_equal([0, 2, 4, 0], getpos('.'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
112 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
113 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
114
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
115 func Test_window_SetHeight()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
116 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
117 perl $curwin->SetHeight(2)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
118 call assert_equal(2, winheight(0))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
119 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
120 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
121
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
122 func Test_VIM_Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
123 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
124 " VIM::Windows() without argument in scalar and list context.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
125 perl $winnr = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
126 perl @winlist = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
127 perl $curbuf->Append(0, $winnr, scalar(@winlist))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
128 call assert_equal(['2', '2', ''], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
129
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
130 " VIM::Windows() with window number argument.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
131 perl VIM::Windows(VIM::Eval('winnr()'))->Buffer()->Set(1, 'bar')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
132 call assert_equal('bar', getline(1))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
133 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
134 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
135
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
136 func Test_VIM_Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
137 new Xbar
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
138 " VIM::Buffers() without argument in scalar and list context.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
139 perl $nbuf = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
140 perl @buflist = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
141
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
142 " VIM::Buffers() with argument.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
143 perl $mybuf = (VIM::Buffers('Xbar'))[0]
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
144 perl $mybuf->Append(0, $nbuf, scalar(@buflist))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
145 call assert_equal(['2', '2', ''], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
146 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
147 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
148
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
149 func <SID>catch_peval(expr)
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 try
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 call perleval(a:expr)
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 catch
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 return v:exception
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 endtry
11183
1c4ebbae41d2 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents: 10922
diff changeset
155 call assert_report('no exception for `perleval("'.a:expr.'")`')
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 return ''
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
157 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
159 func Test_perleval()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 call assert_false(perleval('undef'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 " scalar
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 call assert_equal(0, perleval('0'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 call assert_equal(-2, perleval('-2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 if has('float')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call assert_equal(2.5, perleval('2.5'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 else
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 call assert_equal(2, perleval('2.5'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 end
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 sandbox call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 call assert_equal('abc', perleval('"abc"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 call assert_equal("abc\ndef", perleval('"abc\0def"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 " ref
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 call assert_equal([], perleval('[]'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 call assert_equal(['word', 42, [42],{}], perleval('["word", 42, [42], {}]'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 call assert_equal({}, perleval('{}'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 call assert_equal({'foo': 'bar'}, perleval('{foo => "bar"}'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 perl our %h; our @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 let a = perleval('[\(%h, %h, @a, @a)]')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 call assert_true((a[0] is a[1]))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 call assert_true((a[2] is a[3]))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 perl undef %h; undef @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 call assert_true(<SID>catch_peval('{"" , 0}') =~ 'Malformed key Dictionary')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 call assert_true(<SID>catch_peval('{"\0" , 0}') =~ 'Malformed key Dictionary')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 call assert_true(<SID>catch_peval('{"foo\0bar" , 0}') =~ 'Malformed key Dictionary')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 call assert_equal('*VIM', perleval('"*VIM"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
23148
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
196
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
197 " typeglob
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
198 call assert_equal('*main::STDOUT', perleval('*STDOUT'))
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
199 '
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
200 call perleval("++-$foo")
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
201 let messages = split(execute('message'), "\n")
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
202 call assert_match("Can't modify negation", messages[-1])
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
203 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
205 func Test_perldo()
23148
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
206 new
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
207 " :perldo in empty buffer does nothing.
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
208 perldo ++$counter
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
209 call assert_equal(0, perleval("$counter"))
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
210
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 sp __TEST__
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 exe 'read ' g:testname
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 perldo s/perl/vieux_chameau/g
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 1
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 call assert_false(search('\Cperl'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 bw!
10759
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
217
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
218 " Check deleting lines does not trigger ml_get error.
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
219 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
220 call setline(1, ['one', 'two', 'three'])
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
221 perldo VIM::DoCommand("%d_")
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
222 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
223
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
224 " Check a Perl expression which gives an error.
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
225 new
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
226 call setline(1, 'one')
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
227 perldo 1/0
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
228 call assert_match('^Illegal division by zero at .* line 1\.$', GetMessages()[-1])
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
229 bwipe!
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
230
10759
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
231 " Check switching to another buffer does not trigger ml_get error.
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
232 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
233 let wincount = winnr('$')
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
234 call setline(1, ['one', 'two', 'three'])
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
235 perldo VIM::DoCommand("new")
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
236 call assert_equal(wincount + 1, winnr('$'))
23148
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
237 %bwipe!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
238 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
240 func Test_VIM_package()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 perl VIM::DoCommand('let l:var = "foo"')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 call assert_equal(l:var, 'foo')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 set noet
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 perl VIM::SetOption('et')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 call assert_true(&et)
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
247 endfunc
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
248
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
249 func Test_stdio()
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
250 redir =>l:out
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
251 perl << trim EOF
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
252 VIM::Msg("VIM::Msg");
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
253 VIM::Msg("VIM::Msg Error", "Error");
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
254 print "STDOUT";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
255 print STDERR "STDERR";
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
256 EOF
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
257 redir END
24616
ed4d7ab9dcdc patch 8.2.2847: Perl not tested sufficiently
Bram Moolenaar <Bram@vim.org>
parents: 23148
diff changeset
258 call assert_equal(['VIM::Msg', 'VIM::Msg Error', 'STDOUT', 'STDERR'], split(l:out, "\n"))
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
259 endfunc
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
260
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
261 " Run first to get a clean namespace
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
262 func Test_000_SvREFCNT()
14352
af9f7521cc73 patch 8.1.0191: Perl test fails in 24 line terminal
Christian Brabandt <cb@256bit.org>
parents: 14350
diff changeset
263 for i in range(8)
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
264 exec 'new X'.i
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
265 endfor
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
266 new t
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
267 perl <<--perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
268 #line 5 "Test_000_SvREFCNT()"
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
269 my ($b, $w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
270
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
271 my $num = 0;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
272 for ( 0 .. 100 ) {
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
273 if ( ++$num >= 8 ) { $num = 0 }
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
274 VIM::DoCommand("buffer X$num");
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
275 $b = $curbuf;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
276 }
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
277
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
278 VIM::DoCommand("buffer t");
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
279
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
280 $b = $curbuf for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
281 $w = $curwin for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
282 () = VIM::Buffers for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
283 () = VIM::Windows for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
284
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
285 VIM::DoCommand('bw! t');
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
286 if (exists &Internals::SvREFCNT) {
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
287 my $cb = Internals::SvREFCNT($$b);
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
288 my $cw = Internals::SvREFCNT($$w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
289 VIM::Eval("assert_equal(2, $cb, 'T1')");
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
290 VIM::Eval("assert_equal(2, $cw, 'T2')");
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
291 my $strongref;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
292 foreach ( VIM::Buffers, VIM::Windows ) {
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
293 VIM::DoCommand("%bw!");
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
294 my $c = Internals::SvREFCNT($_);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
295 VIM::Eval("assert_equal(2, $c, 'T3')");
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
296 $c = Internals::SvREFCNT($$_);
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
297 next if $c == 2 && !$strongref++;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
298 VIM::Eval("assert_equal(1, $c, 'T4')");
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
299 }
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
300 $cb = Internals::SvREFCNT($$curbuf);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
301 $cw = Internals::SvREFCNT($$curwin);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
302 VIM::Eval("assert_equal(3, $cb, 'T5')");
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
303 VIM::Eval("assert_equal(3, $cw, 'T6')");
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
304 }
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
305 VIM::Eval("assert_false($$b)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
306 VIM::Eval("assert_false($$w)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
307 --perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
308 %bw!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
309 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
310
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
311 func Test_set_cursor()
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
312 " Check that setting the cursor position works.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
313 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
314 call setline(1, ['first line', 'second line'])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
315 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
316 perldo $curwin->Cursor(1, 5)
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
317 call assert_equal([1, 6], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
318
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
319 " Check that movement after setting cursor position keeps current column.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
320 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
321 call assert_equal([2, 6], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
322 endfunc
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
323
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
324 " Test for various heredoc syntax
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
325 func Test_perl_heredoc()
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
326 perl << END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
327 VIM::DoCommand('let s = "A"')
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
328 END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
329 perl <<
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
330 VIM::DoCommand('let s ..= "B"')
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
331 .
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
332 perl << trim END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
333 VIM::DoCommand('let s ..= "C"')
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
334 END
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
335 perl << trim
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
336 VIM::DoCommand('let s ..= "D"')
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
337 .
20233
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
338 perl << trim eof
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
339 VIM::DoCommand('let s ..= "E"')
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
340 eof
5f9c2c7d3d73 patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents: 20045
diff changeset
341 call assert_equal('ABCDE', s)
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
342 endfunc
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
343
23148
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
344 func Test_perl_in_sandbox()
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
345 sandbox perl print 'test'
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
346 let messages = split(execute('message'), "\n")
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
347 call assert_match("'print' trapped by operation mask", messages[-1])
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
348 endfunc
4637f7a4c753 patch 8.2.2120: not all Perl functionality is tested
Bram Moolenaar <Bram@vim.org>
parents: 20233
diff changeset
349
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
350 " vim: shiftwidth=2 sts=2 expandtab