annotate src/testdir/test_perl.vim @ 16249:67e43b01497f v8.1.1129

patch 8.1.1129: when making a new screendump test have to create the file commit https://github.com/vim/vim/commit/2d7260d66575052124b76c8b97b957319111bfef Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 6 20:51:52 2019 +0200 patch 8.1.1129: when making a new screendump test have to create the file Problem: When making a new screendump test have to create the file. Solution: Continue creating the failed screendump, so it can be moved once it is correct.
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Apr 2019 21:00:05 +0200
parents f0f8754e3bf5
children f38fcbf343ce
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
15945
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
32 funct Test_VIM_Blob()
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
33 call assert_equal('0z', perleval('VIM::Blob("")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
34 call assert_equal('0z31326162', perleval('VIM::Blob("12ab")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
35 call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
36 call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
37 endfunc
f0f8754e3bf5 patch 8.1.0978: blob not tested with Perl
Bram Moolenaar <Bram@vim.org>
parents: 14441
diff changeset
38
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
39 func Test_buffer_Delete()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
40 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
41 call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
42 perl $curbuf->Delete(7)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
43 perl $curbuf->Delete(2, 5)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
44 perl $curbuf->Delete(10)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
45 call assert_equal(['a', 'f', 'h'], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
46 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
47 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
48
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
49 func Test_buffer_Append()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
50 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
51 perl $curbuf->Append(1, '1')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
52 perl $curbuf->Append(2, '2', '3', '4')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
53 perl @l = ('5' ..'7')
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
54 perl $curbuf->Append(0, @l)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
55 call assert_equal(['5', '6', '7', '', '1', '2', '3', '4'], getline(1, '$'))
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
56 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
57 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
58
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
59 func Test_buffer_Set()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
60 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
61 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
62 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
63 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
64 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
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_Get()
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, ['1', '2', '3', '4'])
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
71 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
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_Count()
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 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
78 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
79 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
80 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
81
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
82 func Test_buffer_Name()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
83 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
84 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
85 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
86 new Xfoo
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
87 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
88 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
89 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
90
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
91 func Test_buffer_Number()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
92 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
93 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
94
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
95 func Test_window_Cursor()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
96 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
97 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
98 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
99 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
100 " 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
101 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
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_window_SetHeight()
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 perl $curwin->SetHeight(2)
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
108 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
109 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
110 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
111
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
112 func Test_VIM_Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
113 new
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
114 " 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
115 perl $winnr = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
116 perl @winlist = VIM::Windows()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
117 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
118 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
119
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
120 " 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
121 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
122 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
123 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
124 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
125
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
126 func Test_VIM_Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
127 new Xbar
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
128 " 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
129 perl $nbuf = VIM::Buffers()
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
130 perl @buflist = VIM::Buffers()
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 " VIM::Buffers() with argument.
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
133 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
134 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
135 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
136 bwipe!
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
137 endfunc
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
138
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
139 func <SID>catch_peval(expr)
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 try
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 call perleval(a:expr)
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 catch
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 return v:exception
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 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
145 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
146 return ''
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
147 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
149 func Test_perleval()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 call assert_false(perleval('undef'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 " scalar
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 call assert_equal(0, perleval('0'))
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 call assert_equal(-2, perleval('-2'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 if has('float')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 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
158 else
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 call assert_equal(2, perleval('2.5'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 end
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 sandbox call assert_equal(2, perleval('2'))
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('abc', perleval('"abc"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 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
166
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 " ref
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 call assert_equal([], perleval('[]'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 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
170
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 call assert_equal({}, perleval('{}'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 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
173
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 perl our %h; our @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 let a = perleval('[\(%h, %h, @a, @a)]')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 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
177 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
178 perl undef %h; undef @a;
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179
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}') =~ '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('{"\0" , 0}') =~ 'Malformed key Dictionary')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 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
183
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 call assert_equal('*VIM', perleval('"*VIM"'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 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
186 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
188 func Test_perldo()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 sp __TEST__
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 exe 'read ' g:testname
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 perldo s/perl/vieux_chameau/g
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 1
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 call assert_false(search('\Cperl'))
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 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
195
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
196 " 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
197 new
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("%d_")
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
200 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
201
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
202 " 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
203 new
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
204 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
205 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
206 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
207 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
208 bwipe!
4267f8904d47 patch 8.0.0269: may get ml_get error when :perldo deletes lines
Christian Brabandt <cb@256bit.org>
parents: 8919
diff changeset
209 bwipe!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
210 endfunc
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
212 func Test_VIM_package()
7651
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 perl VIM::DoCommand('let l:var = "foo"')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 call assert_equal(l:var, 'foo')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 set noet
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 perl VIM::SetOption('et')
c7575b07de98 commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 call assert_true(&et)
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
219 endfunc
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
220
10922
2cc7e86bdada patch 8.0.0350: not enough test coverage for Perl
Christian Brabandt <cb@256bit.org>
parents: 10759
diff changeset
221 func Test_stdio()
8885
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
222 redir =>l:out
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
223 perl <<EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
224 VIM::Msg("&VIM::Msg");
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
225 print "STDOUT";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
226 print STDERR "STDERR";
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
227 EOF
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
228 redir END
54a380c74547 commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents: 7655
diff changeset
229 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
230 endfunc
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
231
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
232 " 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
233 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
234 for i in range(8)
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
235 exec 'new X'.i
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
236 endfor
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
237 new t
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
238 perl <<--perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
239 #line 5 "Test_000_SvREFCNT()"
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
240 my ($b, $w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
241
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
242 my $num = 0;
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
243 for ( 0 .. 100 ) {
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
244 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
245 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
246 $b = $curbuf;
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
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
249 VIM::DoCommand("buffer t");
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
250
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
251 $b = $curbuf for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
252 $w = $curwin for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
253 () = VIM::Buffers for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
254 () = VIM::Windows for 0 .. 100;
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
255
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
256 VIM::DoCommand('bw! t');
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
257 if (exists &Internals::SvREFCNT) {
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
258 my $cb = Internals::SvREFCNT($$b);
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
259 my $cw = Internals::SvREFCNT($$w);
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
260 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
261 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
262 my $strongref;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
263 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
264 VIM::DoCommand("%bw!");
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
265 my $c = Internals::SvREFCNT($_);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
266 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
267 $c = Internals::SvREFCNT($$_);
14441
2d6703d4448a patch 8.1.0234: incorrect reference counting in Perl interface
Christian Brabandt <cb@256bit.org>
parents: 14395
diff changeset
268 next if $c == 2 && !$strongref++;
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
269 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
270 }
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
271 $cb = Internals::SvREFCNT($$curbuf);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
272 $cw = Internals::SvREFCNT($$curwin);
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
273 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
274 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
275 }
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
276 VIM::Eval("assert_false($$b)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
277 VIM::Eval("assert_false($$w)");
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
278 --perl
14350
142c0083b3b8 patch 8.1.0190: Perl refcounts are wrong
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
279 %bw!
8919
240ad5a78199 commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents: 8885
diff changeset
280 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
281
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
282 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
283 " 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
284 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
285 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
286 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
287 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
288 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
289
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
290 " 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
291 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14352
diff changeset
292 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
293 endfunc