annotate src/testdir/test_perl.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents 6d11a0d5751d
children 04ef2ccf2519
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
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 CheckFeature perl
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
6 " 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
7 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
8
7655
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
9 func Test_change_buffer()
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
10 call setline(line('$'), ['1 line 1'])
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
11 perl VIM::DoCommand("normal /^1\n")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
12 perl $curline = VIM::Eval("line('.')")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
13 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
14 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
15 endfunc
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
16
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
17 func Test_evaluate_list()
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
18 call setline(line('$'), ['2 line 2'])
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
19 perl VIM::DoCommand("normal /^2\n")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
20 perl $curline = VIM::Eval("line('.')")
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
21 let l = ["abc", "def"]
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
22 perl << EOF
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
23 $l = VIM::Eval("l");
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
24 $curbuf->Append($curline, $l);
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
25 EOF
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
26 normal j
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
27 .perldo s|\n|/|g
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
28 call assert_equal('abc/def/', getline('$'))
94f34dc2f254 commit https://github.com/vim/vim/commit/021b593e7ed6c7111cbf189744ad1e5d6c4a7d79
Christian Brabandt <cb@256bit.org>
parents: 7651
diff changeset
29 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
15945
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
31 funct Test_VIM_Blob()
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
32 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
33 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
34 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
35 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
36 endfunc
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
37
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
38 func Test_buffer_Delete()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
39 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
40 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
41 perl $curbuf->Delete(7)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
42 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
43 perl $curbuf->Delete(10)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
44 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
45 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
46 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
47
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
48 func Test_buffer_Append()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
49 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
50 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
51 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
52 perl @l = ('5' ..'7')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
53 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
54 call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
55 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
56 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
57
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
58 func Test_buffer_Set()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
59 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
60 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
61 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
62 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
63 call assert_equal(['1', 'a', 'b', 'A', 'B'], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
64 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
65 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
66
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
67 func Test_buffer_Get()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
68 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
69 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
70 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
71 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
72 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
73
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
74 func Test_buffer_Count()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
75 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
76 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
77 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
78 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
79 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
80
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
81 func Test_buffer_Name()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
82 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
83 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
84 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
85 new Xfoo
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
86 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
87 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
88 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
89
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
90 func Test_buffer_Number()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
91 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
92 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
93
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
94 func Test_window_Cursor()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
95 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
96 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
97 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
98 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
99 " 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
100 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
101 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
102 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
103
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
104 func Test_window_SetHeight()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
105 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
106 perl $curwin->SetHeight(2)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
107 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
108 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
109 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
110
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
111 func Test_VIM_Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
112 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
113 " 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
114 perl $winnr = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
115 perl @winlist = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
116 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
117 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
118
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
119 " 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
120 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
121 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
122 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
123 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
124
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
125 func Test_VIM_Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
126 new Xbar
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
127 " 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
128 perl $nbuf = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
129 perl @buflist = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
130
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
131 " VIM::Buffers() with argument.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
132 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
133 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
134 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
135 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
136 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
137
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
138 func <SID>catch_peval(expr)
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 try
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 call perleval(a:expr)
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 catch
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 return v:exception
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 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
144 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
145 return ''
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
146 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
148 func Test_perleval()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 call assert_false(perleval('undef'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 " scalar
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 call assert_equal(0, perleval('0'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 call assert_equal(-2, perleval('-2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 if has('float')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 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
157 else
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 call assert_equal(2, perleval('2.5'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 end
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 sandbox call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 call assert_equal('abc', perleval('"abc"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 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
165
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 " ref
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call assert_equal([], perleval('[]'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 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
169
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 call assert_equal({}, perleval('{}'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 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
172
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 perl our %h; our @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 let a = perleval('[\(%h, %h, @a, @a)]')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 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
176 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
177 perl undef %h; undef @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 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
180 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
181 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
182
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 call assert_equal('*VIM', perleval('"*VIM"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)')
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
185 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
187 func Test_perldo()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 sp __TEST__
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 exe 'read ' g:testname
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 perldo s/perl/vieux_chameau/g
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 1
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 call assert_false(search('\Cperl'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 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
194
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
195 " 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
196 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
197 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
198 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
199 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
200
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
201 " 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
202 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
203 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
204 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
205 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
206 call assert_equal(wincount + 1, winnr('$'))
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
207 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
208 bwipe!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
209 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
211 func Test_VIM_package()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 perl VIM::DoCommand('let l:var = "foo"')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 call assert_equal(l:var, 'foo')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 set noet
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 perl VIM::SetOption('et')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 call assert_true(&et)
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
218 endfunc
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
219
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
220 func Test_stdio()
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
221 redir =>l:out
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
222 perl <<EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
223 VIM::Msg("&VIM::Msg");
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
224 print "STDOUT";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
225 print STDERR "STDERR";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
226 EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
227 redir END
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
228 call assert_equal(['&VIM::Msg', '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
229 endfunc
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
230
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
231 " 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
232 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
233 for i in range(8)
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
234 exec 'new X'.i
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
235 endfor
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
236 new t
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
237 perl <<--perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
238 #line 5 "Test_000_SvREFCNT()"
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
239 my ($b, $w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
240
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
241 my $num = 0;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
242 for ( 0 .. 100 ) {
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
243 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
244 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
245 $b = $curbuf;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
246 }
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
247
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
248 VIM::DoCommand("buffer t");
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
249
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
250 $b = $curbuf for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
251 $w = $curwin for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
252 () = VIM::Buffers for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
253 () = VIM::Windows for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
254
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
255 VIM::DoCommand('bw! t');
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
256 if (exists &Internals::SvREFCNT) {
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
257 my $cb = Internals::SvREFCNT($$b);
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
258 my $cw = Internals::SvREFCNT($$w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
259 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
260 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
261 my $strongref;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
262 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
263 VIM::DoCommand("%bw!");
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
264 my $c = Internals::SvREFCNT($_);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
265 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
266 $c = Internals::SvREFCNT($$_);
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
267 next if $c == 2 && !$strongref++;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
268 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
269 }
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
270 $cb = Internals::SvREFCNT($$curbuf);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
271 $cw = Internals::SvREFCNT($$curwin);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
272 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
273 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
274 }
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
275 VIM::Eval("assert_false($$b)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
276 VIM::Eval("assert_false($$w)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
277 --perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
278 %bw!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
279 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
280
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
281 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
282 " 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
283 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
284 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
285 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
286 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
287 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
288
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
289 " 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
290 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
291 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
292 endfunc