annotate src/testdir/test_perl.vim @ 15062:3a94f7918980 v8.1.0542

patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account commit https://github.com/vim/vim/commit/f951416a8396a54bbbe21de1a8b16716428549f2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 22 03:08:29 2018 +0100 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account Problem: shiftwidth() does not take 'vartabstop' into account. Solution: Use the cursor position or a position explicitly passed. Also make >> and << work better with 'vartabstop'. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Thu, 22 Nov 2018 03:15:10 +0100
parents 2d6703d4448a
children f0f8754e3bf5
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
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('perl')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 end
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
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
32 func Test_buffer_Delete()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
33 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
34 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
35 perl $curbuf->Delete(7)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
36 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
37 perl $curbuf->Delete(10)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
38 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
39 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
40 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
41
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
42 func Test_buffer_Append()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
43 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
44 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
45 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
46 perl @l = ('5' ..'7')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
47 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
48 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
49 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
50 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
51
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
52 func Test_buffer_Set()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
53 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
54 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
55 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
56 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
57 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
58 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
59 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
60
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
61 func Test_buffer_Get()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
62 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
63 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
64 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
65 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
66 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
67
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
68 func Test_buffer_Count()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
69 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
70 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
71 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
72 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
73 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
74
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
75 func Test_buffer_Name()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
76 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
77 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
78 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
79 new Xfoo
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
80 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
81 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
82 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
83
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
84 func Test_buffer_Number()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
85 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
86 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
87
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
88 func Test_window_Cursor()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
89 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
90 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
91 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
92 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
93 " 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
94 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
95 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
96 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
97
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
98 func Test_window_SetHeight()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
99 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
100 perl $curwin->SetHeight(2)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
101 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
102 bwipe!
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_VIM_Windows()
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 " 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
108 perl $winnr = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
109 perl @winlist = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
110 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
111 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
112
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
113 " 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
114 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
115 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
116 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
117 endfunc
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 func Test_VIM_Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
120 new Xbar
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
121 " 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
122 perl $nbuf = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
123 perl @buflist = VIM::Buffers()
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 " VIM::Buffers() with argument.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
126 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
127 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
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 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
130 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
131
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
132 func <SID>catch_peval(expr)
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 try
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 call perleval(a:expr)
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 catch
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 return v:exception
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 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
138 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
139 return ''
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
140 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
142 func Test_perleval()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 call assert_false(perleval('undef'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 " scalar
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 call assert_equal(0, perleval('0'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 call assert_equal(-2, perleval('-2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 if has('float')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 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
151 else
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 call assert_equal(2, perleval('2.5'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 end
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 sandbox call assert_equal(2, perleval('2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 call assert_equal('abc', perleval('"abc"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 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
159
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 " ref
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 call assert_equal([], perleval('[]'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 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
163
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 call assert_equal({}, perleval('{}'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 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
166
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 perl our %h; our @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 let a = perleval('[\(%h, %h, @a, @a)]')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 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
170 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
171 perl undef %h; undef @a;
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 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
174 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
175 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
176
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 call assert_equal('*VIM', perleval('"*VIM"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 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
179 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
181 func Test_perldo()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 sp __TEST__
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 exe 'read ' g:testname
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 perldo s/perl/vieux_chameau/g
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 1
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 call assert_false(search('\Cperl'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 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
188
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
189 " 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
190 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
191 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
192 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
193 bwipe!
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 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
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 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
198 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
199 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
200 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
201 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
202 bwipe!
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_VIM_package()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 perl VIM::DoCommand('let l:var = "foo"')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 call assert_equal(l:var, 'foo')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 set noet
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 perl VIM::SetOption('et')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 call assert_true(&et)
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
212 endfunc
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
213
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
214 func Test_stdio()
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
215 redir =>l:out
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
216 perl <<EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
217 VIM::Msg("&VIM::Msg");
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
218 print "STDOUT";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
219 print STDERR "STDERR";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
220 EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
221 redir END
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
222 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
223 endfunc
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
224
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
225 " 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
226 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
227 for i in range(8)
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
228 exec 'new X'.i
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
229 endfor
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
230 new t
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
231 perl <<--perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
232 #line 5 "Test_000_SvREFCNT()"
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
233 my ($b, $w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
234
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
235 my $num = 0;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
236 for ( 0 .. 100 ) {
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
237 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
238 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
239 $b = $curbuf;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
240 }
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
241
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
242 VIM::DoCommand("buffer t");
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
243
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
244 $b = $curbuf for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
245 $w = $curwin for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
246 () = VIM::Buffers for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
247 () = VIM::Windows for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
248
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
249 VIM::DoCommand('bw! t');
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
250 if (exists &Internals::SvREFCNT) {
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
251 my $cb = Internals::SvREFCNT($$b);
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
252 my $cw = Internals::SvREFCNT($$w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
253 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
254 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
255 my $strongref;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
256 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
257 VIM::DoCommand("%bw!");
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
258 my $c = Internals::SvREFCNT($_);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
259 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
260 $c = Internals::SvREFCNT($$_);
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
261 next if $c == 2 && !$strongref++;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
262 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
263 }
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
264 $cb = Internals::SvREFCNT($$curbuf);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
265 $cw = Internals::SvREFCNT($$curwin);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
266 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
267 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
268 }
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
269 VIM::Eval("assert_false($$b)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
270 VIM::Eval("assert_false($$w)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
271 --perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
272 %bw!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
273 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
274
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
275 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
276 " 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
277 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
278 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
279 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
280 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
281 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
282
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
283 " 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
284 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
285 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
286 endfunc