annotate src/testdir/test_functions.vim @ 13092:d5647746c267 v8.0.1421

patch 8.0.1421: accessing invalid memory with overlong byte sequence commit https://github.com/vim/vim/commit/e6640ad44e2186bd3642b972115496d347cd1fdd Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 22 21:06:56 2017 +0100 patch 8.0.1421: accessing invalid memory with overlong byte sequence Problem: Accessing invalid memory with overlong byte sequence. Solution: Check for NUL character. (test by Dominique Pelle, closes https://github.com/vim/vim/issues/2485)
author Christian Brabandt <cb@256bit.org>
date Fri, 22 Dec 2017 21:15:05 +0100
parents 17720967656c
children 4064f342bea4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for various functions.
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
3 " Must be done first, since the alternate buffer must be unset.
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
4 func Test_00_bufexists()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
5 call assert_equal(0, bufexists('does_not_exist'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
6 call assert_equal(1, bufexists(bufnr('%')))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
7 call assert_equal(0, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
8 new Xfoo
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
9 let bn = bufnr('%')
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
10 call assert_equal(1, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
11 call assert_equal(1, bufexists('Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
12 call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
13 call assert_equal(1, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
14 bw
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
15 call assert_equal(0, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
16 call assert_equal(0, bufexists('Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
17 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
18
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
19 func Test_empty()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
20 call assert_equal(1, empty(''))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
21 call assert_equal(0, empty('a'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
22
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
23 call assert_equal(1, empty(0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
24 call assert_equal(1, empty(-0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
25 call assert_equal(0, empty(1))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
26 call assert_equal(0, empty(-1))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
27
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
28 call assert_equal(1, empty(0.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
29 call assert_equal(1, empty(-0.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
30 call assert_equal(0, empty(1.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
31 call assert_equal(0, empty(-1.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
32 call assert_equal(0, empty(1.0/0.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
33 call assert_equal(0, empty(0.0/0.0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
34
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
35 call assert_equal(1, empty([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
36 call assert_equal(0, empty(['a']))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
37
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
38 call assert_equal(1, empty({}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
39 call assert_equal(0, empty({'a':1}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
40
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
41 call assert_equal(1, empty(v:null))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
42 call assert_equal(1, empty(v:none))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
43 call assert_equal(1, empty(v:false))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
44 call assert_equal(0, empty(v:true))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
45
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
46 if has('channel')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
47 call assert_equal(1, empty(test_null_channel()))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
48 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
49 if has('job')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
50 call assert_equal(1, empty(test_null_job()))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
51 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
52
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
53 call assert_equal(0, empty(function('Test_empty')))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
54 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
55
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
56 func Test_len()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
57 call assert_equal(1, len(0))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
58 call assert_equal(2, len(12))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
59
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
60 call assert_equal(0, len(''))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
61 call assert_equal(2, len('ab'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
62
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
63 call assert_equal(0, len([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
64 call assert_equal(2, len([2, 1]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
65
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
66 call assert_equal(0, len({}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
67 call assert_equal(2, len({'a': 1, 'b': 2}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
68
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
69 call assert_fails('call len(v:none)', 'E701:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
70 call assert_fails('call len({-> 0})', 'E701:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
71 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
72
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
73 func Test_max()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
74 call assert_equal(0, max([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
75 call assert_equal(2, max([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
76 call assert_equal(2, max([1, 2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
77 call assert_equal(2, max([1, 2, v:null]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
78
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
79 call assert_equal(0, max({}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
80 call assert_equal(2, max({'a':1, 'b':2}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
81
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
82 call assert_fails('call max(1)', 'E712:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
83 call assert_fails('call max(v:none)', 'E712:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
84 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
85
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
86 func Test_min()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
87 call assert_equal(0, min([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
88 call assert_equal(2, min([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
89 call assert_equal(1, min([1, 2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
90 call assert_equal(0, min([1, 2, v:null]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
91
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
92 call assert_equal(0, min({}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
93 call assert_equal(1, min({'a':1, 'b':2}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
94
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
95 call assert_fails('call min(1)', 'E712:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
96 call assert_fails('call min(v:none)', 'E712:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
97 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
98
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 func Test_str2nr()
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 call assert_equal(0, str2nr(''))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 call assert_equal(1, str2nr('1'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 call assert_equal(1, str2nr(' 1 '))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 call assert_equal(1, str2nr('+1'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 call assert_equal(1, str2nr('+ 1'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 call assert_equal(1, str2nr(' + 1 '))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 call assert_equal(-1, str2nr('-1'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 call assert_equal(-1, str2nr('- 1'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 call assert_equal(-1, str2nr(' - 1 '))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call assert_equal(123456789, str2nr('123456789'))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 call assert_equal(-123456789, str2nr('-123456789'))
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
114
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
115 call assert_equal(5, str2nr('101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
116 call assert_equal(5, str2nr('0b101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
117 call assert_equal(5, str2nr('0B101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
118 call assert_equal(-5, str2nr('-101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
119 call assert_equal(-5, str2nr('-0b101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
120 call assert_equal(-5, str2nr('-0B101', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
121
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
122 call assert_equal(65, str2nr('101', 8))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
123 call assert_equal(65, str2nr('0101', 8))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
124 call assert_equal(-65, str2nr('-101', 8))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
125 call assert_equal(-65, str2nr('-0101', 8))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
126
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
127 call assert_equal(11259375, str2nr('abcdef', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
128 call assert_equal(11259375, str2nr('ABCDEF', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
129 call assert_equal(-11259375, str2nr('-ABCDEF', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
130 call assert_equal(11259375, str2nr('0xabcdef', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
131 call assert_equal(11259375, str2nr('0Xabcdef', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
132 call assert_equal(11259375, str2nr('0XABCDEF', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
133 call assert_equal(-11259375, str2nr('-0xABCDEF', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
134
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
135 call assert_equal(0, str2nr('0x10'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
136 call assert_equal(0, str2nr('0b10'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
137 call assert_equal(1, str2nr('12', 2))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
138 call assert_equal(1, str2nr('18', 8))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
139 call assert_equal(1, str2nr('1g', 16))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
140
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
141 call assert_equal(0, str2nr(v:null))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
142 call assert_equal(0, str2nr(v:none))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
143
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
144 call assert_fails('call str2nr([])', 'E730:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
145 call assert_fails('call str2nr({->2})', 'E729:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
146 call assert_fails('call str2nr(1.2)', 'E806:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
147 call assert_fails('call str2nr(10, [])', 'E474:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
148 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
149
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
150 func Test_strftime()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
151 if !exists('*strftime')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
152 return
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
153 endif
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
154 " Format of strftime() depends on system. We assume
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
155 " that basic formats tested here are available and
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
156 " identical on all systems which support strftime().
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
157 "
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
158 " The 2nd parameter of strftime() is a local time, so the output day
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
159 " of strftime() can be 17 or 18, depending on timezone.
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
160 call assert_match('^2017-01-1[78]$', strftime('%Y-%m-%d', 1484695512))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
161 "
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
162 call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', strftime('%Y-%m-%d %H:%M:%S'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
163
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
164 call assert_fails('call strftime([])', 'E730:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
165 call assert_fails('call strftime("%Y", [])', 'E745:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
166 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
167
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
168 func Test_simplify()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
169 call assert_equal('', simplify(''))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
170 call assert_equal('/', simplify('/'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
171 call assert_equal('/', simplify('/.'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
172 call assert_equal('/', simplify('/..'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
173 call assert_equal('/...', simplify('/...'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
174 call assert_equal('./dir/file', simplify('./dir/file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
175 call assert_equal('./dir/file', simplify('.///dir//file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
176 call assert_equal('./dir/file', simplify('./dir/./file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
177 call assert_equal('./file', simplify('./dir/../file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
178 call assert_equal('../dir/file', simplify('dir/../../dir/file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
179 call assert_equal('./file', simplify('dir/.././file'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
180
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
181 call assert_fails('call simplify({->0})', 'E729:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
182 call assert_fails('call simplify([])', 'E730:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
183 call assert_fails('call simplify({})', 'E731:')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
184 call assert_fails('call simplify(1.2)', 'E806:')
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 endfunc
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
186
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
187 func Test_strpart()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
188 call assert_equal('de', strpart('abcdefg', 3, 2))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
189 call assert_equal('ab', strpart('abcdefg', -2, 4))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
190 call assert_equal('abcdefg', strpart('abcdefg', -2))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
191 call assert_equal('fg', strpart('abcdefg', 5, 4))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
192 call assert_equal('defg', strpart('abcdefg', 3))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
193
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
194 if has('multi_byte')
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
195 call assert_equal('lép', strpart('éléphant', 2, 4))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
196 call assert_equal('léphant', strpart('éléphant', 2))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
197 endif
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
198 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
199
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
200 func Test_tolower()
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
201 call assert_equal("", tolower(""))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
202
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
203 " Test with all printable ASCII characters.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
204 call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
205 \ tolower(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
206
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
207 if !has('multi_byte')
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
208 return
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
209 endif
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
210
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
211 " Test with a few uppercase diacritics.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
212 call assert_equal("aàáâãäåāăąǎǟǡả", tolower("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
213 call assert_equal("bḃḇ", tolower("BḂḆ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
214 call assert_equal("cçćĉċč", tolower("CÇĆĈĊČ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
215 call assert_equal("dďđḋḏḑ", tolower("DĎĐḊḎḐ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
216 call assert_equal("eèéêëēĕėęěẻẽ", tolower("EÈÉÊËĒĔĖĘĚẺẼ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
217 call assert_equal("fḟ ", tolower("FḞ "))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
218 call assert_equal("gĝğġģǥǧǵḡ", tolower("GĜĞĠĢǤǦǴḠ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
219 call assert_equal("hĥħḣḧḩ", tolower("HĤĦḢḦḨ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
220 call assert_equal("iìíîïĩīĭįiǐỉ", tolower("IÌÍÎÏĨĪĬĮİǏỈ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
221 call assert_equal("jĵ", tolower("JĴ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
222 call assert_equal("kķǩḱḵ", tolower("KĶǨḰḴ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
223 call assert_equal("lĺļľŀłḻ", tolower("LĹĻĽĿŁḺ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
224 call assert_equal("mḿṁ", tolower("MḾṀ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
225 call assert_equal("nñńņňṅṉ", tolower("NÑŃŅŇṄṈ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
226 call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
227 call assert_equal("pṕṗ", tolower("PṔṖ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
228 call assert_equal("q", tolower("Q"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
229 call assert_equal("rŕŗřṙṟ", tolower("RŔŖŘṘṞ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
230 call assert_equal("sśŝşšṡ", tolower("SŚŜŞŠṠ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
231 call assert_equal("tţťŧṫṯ", tolower("TŢŤŦṪṮ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
232 call assert_equal("uùúûüũūŭůűųưǔủ", tolower("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
233 call assert_equal("vṽ", tolower("VṼ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
234 call assert_equal("wŵẁẃẅẇ", tolower("WŴẀẂẄẆ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
235 call assert_equal("xẋẍ", tolower("XẊẌ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
236 call assert_equal("yýŷÿẏỳỷỹ", tolower("YÝŶŸẎỲỶỸ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
237 call assert_equal("zźżžƶẑẕ", tolower("ZŹŻŽƵẐẔ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
238
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
239 " Test with a few lowercase diacritics, which should remain unchanged.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
240 call assert_equal("aàáâãäåāăąǎǟǡả", tolower("aàáâãäåāăąǎǟǡả"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
241 call assert_equal("bḃḇ", tolower("bḃḇ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
242 call assert_equal("cçćĉċč", tolower("cçćĉċč"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
243 call assert_equal("dďđḋḏḑ", tolower("dďđḋḏḑ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
244 call assert_equal("eèéêëēĕėęěẻẽ", tolower("eèéêëēĕėęěẻẽ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
245 call assert_equal("fḟ", tolower("fḟ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
246 call assert_equal("gĝğġģǥǧǵḡ", tolower("gĝğġģǥǧǵḡ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
247 call assert_equal("hĥħḣḧḩẖ", tolower("hĥħḣḧḩẖ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
248 call assert_equal("iìíîïĩīĭįǐỉ", tolower("iìíîïĩīĭįǐỉ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
249 call assert_equal("jĵǰ", tolower("jĵǰ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
250 call assert_equal("kķǩḱḵ", tolower("kķǩḱḵ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
251 call assert_equal("lĺļľŀłḻ", tolower("lĺļľŀłḻ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
252 call assert_equal("mḿṁ ", tolower("mḿṁ "))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
253 call assert_equal("nñńņňʼnṅṉ", tolower("nñńņňʼnṅṉ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
254 call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("oòóôõöøōŏőơǒǫǭỏ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
255 call assert_equal("pṕṗ", tolower("pṕṗ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
256 call assert_equal("q", tolower("q"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
257 call assert_equal("rŕŗřṙṟ", tolower("rŕŗřṙṟ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
258 call assert_equal("sśŝşšṡ", tolower("sśŝşšṡ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
259 call assert_equal("tţťŧṫṯẗ", tolower("tţťŧṫṯẗ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
260 call assert_equal("uùúûüũūŭůűųưǔủ", tolower("uùúûüũūŭůűųưǔủ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
261 call assert_equal("vṽ", tolower("vṽ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
262 call assert_equal("wŵẁẃẅẇẘ", tolower("wŵẁẃẅẇẘ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
263 call assert_equal("ẋẍ", tolower("ẋẍ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
264 call assert_equal("yýÿŷẏẙỳỷỹ", tolower("yýÿŷẏẙỳỷỹ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
265 call assert_equal("zźżžƶẑẕ", tolower("zźżžƶẑẕ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
266
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
267 " According to https://twitter.com/jifa/status/625776454479970304
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
268 " Ⱥ (U+023A) and Ⱦ (U+023E) are the *only* code points to increase
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
269 " in length (2 to 3 bytes) when lowercased. So let's test them.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
270 call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ"))
13092
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
271
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
272 " This call to tolower with invalid utf8 sequence used to cause access to
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
273 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
274 call tolower("\xC0\x80\xC0")
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
275 call tolower("123\xC0\x80\xC0")
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
276 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
277
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
278 func Test_toupper()
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
279 call assert_equal("", toupper(""))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
280
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
281 " Test with all printable ASCII characters.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
282 call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~',
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
283 \ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
284
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
285 if !has('multi_byte')
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
286 return
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
287 endif
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
288
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
289 " Test with a few lowercase diacritics.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
290 call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
291 call assert_equal("BḂḆ", toupper("bḃḇ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
292 call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
293 call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
294 call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("eèéêëēĕėęěẻẽ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
295 call assert_equal("FḞ", toupper("fḟ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
296 call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("gĝğġģǥǧǵḡ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
297 call assert_equal("HĤĦḢḦḨẖ", toupper("hĥħḣḧḩẖ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
298 call assert_equal("IÌÍÎÏĨĪĬĮǏỈ", toupper("iìíîïĩīĭįǐỉ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
299 call assert_equal("JĴǰ", toupper("jĵǰ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
300 call assert_equal("KĶǨḰḴ", toupper("kķǩḱḵ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
301 call assert_equal("LĹĻĽĿŁḺ", toupper("lĺļľŀłḻ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
302 call assert_equal("MḾṀ ", toupper("mḿṁ "))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
303 call assert_equal("NÑŃŅŇʼnṄṈ", toupper("nñńņňʼnṅṉ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
304 call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("oòóôõöøōŏőơǒǫǭỏ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
305 call assert_equal("PṔṖ", toupper("pṕṗ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
306 call assert_equal("Q", toupper("q"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
307 call assert_equal("RŔŖŘṘṞ", toupper("rŕŗřṙṟ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
308 call assert_equal("SŚŜŞŠṠ", toupper("sśŝşšṡ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
309 call assert_equal("TŢŤŦṪṮẗ", toupper("tţťŧṫṯẗ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
310 call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("uùúûüũūŭůűųưǔủ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
311 call assert_equal("VṼ", toupper("vṽ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
312 call assert_equal("WŴẀẂẄẆẘ", toupper("wŵẁẃẅẇẘ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
313 call assert_equal("ẊẌ", toupper("ẋẍ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
314 call assert_equal("YÝŸŶẎẙỲỶỸ", toupper("yýÿŷẏẙỳỷỹ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
315 call assert_equal("ZŹŻŽƵẐẔ", toupper("zźżžƶẑẕ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
316
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
317 " Test that uppercase diacritics, which should remain unchanged.
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
318 call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
319 call assert_equal("BḂḆ", toupper("BḂḆ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
320 call assert_equal("CÇĆĈĊČ", toupper("CÇĆĈĊČ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
321 call assert_equal("DĎĐḊḎḐ", toupper("DĎĐḊḎḐ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
322 call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("EÈÉÊËĒĔĖĘĚẺẼ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
323 call assert_equal("FḞ ", toupper("FḞ "))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
324 call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("GĜĞĠĢǤǦǴḠ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
325 call assert_equal("HĤĦḢḦḨ", toupper("HĤĦḢḦḨ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
326 call assert_equal("IÌÍÎÏĨĪĬĮİǏỈ", toupper("IÌÍÎÏĨĪĬĮİǏỈ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
327 call assert_equal("JĴ", toupper("JĴ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
328 call assert_equal("KĶǨḰḴ", toupper("KĶǨḰḴ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
329 call assert_equal("LĹĻĽĿŁḺ", toupper("LĹĻĽĿŁḺ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
330 call assert_equal("MḾṀ", toupper("MḾṀ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
331 call assert_equal("NÑŃŅŇṄṈ", toupper("NÑŃŅŇṄṈ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
332 call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
333 call assert_equal("PṔṖ", toupper("PṔṖ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
334 call assert_equal("Q", toupper("Q"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
335 call assert_equal("RŔŖŘṘṞ", toupper("RŔŖŘṘṞ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
336 call assert_equal("SŚŜŞŠṠ", toupper("SŚŜŞŠṠ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
337 call assert_equal("TŢŤŦṪṮ", toupper("TŢŤŦṪṮ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
338 call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
339 call assert_equal("VṼ", toupper("VṼ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
340 call assert_equal("WŴẀẂẄẆ", toupper("WŴẀẂẄẆ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
341 call assert_equal("XẊẌ", toupper("XẊẌ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
342 call assert_equal("YÝŶŸẎỲỶỸ", toupper("YÝŶŸẎỲỶỸ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
343 call assert_equal("ZŹŻŽƵẐẔ", toupper("ZŹŻŽƵẐẔ"))
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
344
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
345 call assert_equal("Ⱥ Ⱦ", toupper("ⱥ ⱦ"))
13092
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
346
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
347 " This call to toupper with invalid utf8 sequence used to cause access to
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
348 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
349 call toupper("\xC0\x80\xC0")
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
350 call toupper("123\xC0\x80\xC0")
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
351 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
352
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
353 " Tests for the mode() function
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
354 let current_modes = ''
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
355 func Save_mode()
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
356 let g:current_modes = mode(0) . '-' . mode(1)
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
357 return ''
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
358 endfunc
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
359
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
360 func Test_mode()
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
361 new
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
362 call append(0, ["Blue Ball Black", "Brown Band Bowl", ""])
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
363
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
364 " Only complete from the current buffer.
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
365 set complete=.
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
366
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
367 inoremap <F2> <C-R>=Save_mode()<CR>
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
368
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
369 normal! 3G
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
370 exe "normal i\<F2>\<Esc>"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
371 call assert_equal('i-i', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
372 " i_CTRL-P: Multiple matches
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
373 exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
374 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
375 " i_CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
376 exe "normal iBro\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
377 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
378 " i_CTRL-X
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
379 exe "normal iBa\<C-X>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
380 call assert_equal('i-ix', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
381 " i_CTRL-X CTRL-P: Multiple matches
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
382 exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
383 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
384 " i_CTRL-X CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
385 exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
386 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
387 " i_CTRL-X CTRL-P + CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
388 exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
389 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
390 " i_CTRL-X CTRL-L: Multiple matches
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
391 exe "normal i\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
392 call assert_equal('i-ic', g:current_modes)
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
393 " i_CTRL-X CTRL-L: Single match
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
394 exe "normal iBlu\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
395 call assert_equal('i-ic', g:current_modes)
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
396 " i_CTRL-P: No match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
397 exe "normal iCom\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
398 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
399 " i_CTRL-X CTRL-P: No match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
400 exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
401 call assert_equal('i-ic', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
402 " i_CTRL-X CTRL-L: No match
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
403 exe "normal iabc\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
404 call assert_equal('i-ic', g:current_modes)
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
405
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
406 " R_CTRL-P: Multiple matches
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
407 exe "normal RBa\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
408 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
409 " R_CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
410 exe "normal RBro\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
411 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
412 " R_CTRL-X
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
413 exe "normal RBa\<C-X>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
414 call assert_equal('R-Rx', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
415 " R_CTRL-X CTRL-P: Multiple matches
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
416 exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
417 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
418 " R_CTRL-X CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
419 exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
420 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
421 " R_CTRL-X CTRL-P + CTRL-P: Single match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
422 exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
423 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
424 " R_CTRL-X CTRL-L: Multiple matches
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
425 exe "normal R\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
426 call assert_equal('R-Rc', g:current_modes)
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
427 " R_CTRL-X CTRL-L: Single match
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
428 exe "normal RBlu\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
429 call assert_equal('R-Rc', g:current_modes)
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
430 " R_CTRL-P: No match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
431 exe "normal RCom\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
432 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
433 " R_CTRL-X CTRL-P: No match
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
434 exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u"
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
435 call assert_equal('R-Rc', g:current_modes)
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
436 " R_CTRL-X CTRL-L: No match
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
437 exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
438 call assert_equal('R-Rc', g:current_modes)
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
439
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
440 call assert_equal('n', mode(0))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
441 call assert_equal('n', mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
442
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
443 " How to test operator-pending mode?
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
444
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
445 call feedkeys("v", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
446 call assert_equal('v', mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
447 call assert_equal('v', mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
448 call feedkeys("\<Esc>V", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
449 call assert_equal('V', mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
450 call assert_equal('V', mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
451 call feedkeys("\<Esc>\<C-V>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
452 call assert_equal("\<C-V>", mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
453 call assert_equal("\<C-V>", mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
454 call feedkeys("\<Esc>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
455
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
456 call feedkeys("gh", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
457 call assert_equal('s', mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
458 call assert_equal('s', mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
459 call feedkeys("\<Esc>gH", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
460 call assert_equal('S', mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
461 call assert_equal('S', mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
462 call feedkeys("\<Esc>g\<C-H>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
463 call assert_equal("\<C-S>", mode())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
464 call assert_equal("\<C-S>", mode(1))
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
465 call feedkeys("\<Esc>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
466
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
467 call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
468 call assert_equal('c-c', g:current_modes)
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
469 call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
470 call assert_equal('c-cv', g:current_modes)
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
471 " How to test Ex mode?
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
472
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
473 bwipe!
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
474 iunmap <F2>
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
475 set complete&
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
476 endfunc
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
477
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
478 func Test_getbufvar()
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
479 let bnr = bufnr('%')
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
480 let b:var_num = '1234'
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
481 let def_num = '5678'
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
482 call assert_equal('1234', getbufvar(bnr, 'var_num'))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
483 call assert_equal('1234', getbufvar(bnr, 'var_num', def_num))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
484
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
485 let bd = getbufvar(bnr, '')
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
486 call assert_equal('1234', bd['var_num'])
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
487 call assert_true(exists("bd['changedtick']"))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
488 call assert_equal(2, len(bd))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
489
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
490 let bd2 = getbufvar(bnr, '', def_num)
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
491 call assert_equal(bd, bd2)
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
492
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
493 unlet b:var_num
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
494 call assert_equal(def_num, getbufvar(bnr, 'var_num', def_num))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
495 call assert_equal('', getbufvar(bnr, 'var_num'))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
496
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
497 let bd = getbufvar(bnr, '')
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
498 call assert_equal(1, len(bd))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
499 let bd = getbufvar(bnr, '',def_num)
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
500 call assert_equal(1, len(bd))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
501
11197
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 11191
diff changeset
502 call assert_equal('', getbufvar(9999, ''))
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 11191
diff changeset
503 call assert_equal(def_num, getbufvar(9999, '', def_num))
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
504 unlet def_num
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
505
10891
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
506 call assert_equal(0, getbufvar(bnr, '&autoindent'))
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
507 call assert_equal(0, getbufvar(bnr, '&autoindent', 1))
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
508
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
509 " Open new window with forced option values
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
510 set fileformats=unix,dos
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
511 new ++ff=dos ++bin ++enc=iso-8859-2
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
512 call assert_equal('dos', getbufvar(bufnr('%'), '&fileformat'))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
513 call assert_equal(1, getbufvar(bufnr('%'), '&bin'))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
514 call assert_equal('iso-8859-2', getbufvar(bufnr('%'), '&fenc'))
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
515 close
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
516
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
517 set fileformats&
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
518 endfunc
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
519
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
520 func Test_last_buffer_nr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
521 call assert_equal(bufnr('$'), last_buffer_nr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
522 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
523
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
524 func Test_stridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
525 call assert_equal(-1, stridx('', 'l'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
526 call assert_equal(0, stridx('', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
527 call assert_equal(0, stridx('hello', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
528 call assert_equal(-1, stridx('hello', 'L'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
529 call assert_equal(2, stridx('hello', 'l', -1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
530 call assert_equal(2, stridx('hello', 'l', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
531 call assert_equal(2, stridx('hello', 'l', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
532 call assert_equal(3, stridx('hello', 'l', 3))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
533 call assert_equal(-1, stridx('hello', 'l', 4))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
534 call assert_equal(-1, stridx('hello', 'l', 10))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
535 call assert_equal(2, stridx('hello', 'll'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
536 call assert_equal(-1, stridx('hello', 'hello world'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
537 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
538
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
539 func Test_strridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
540 call assert_equal(-1, strridx('', 'l'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
541 call assert_equal(0, strridx('', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
542 call assert_equal(5, strridx('hello', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
543 call assert_equal(-1, strridx('hello', 'L'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
544 call assert_equal(3, strridx('hello', 'l'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
545 call assert_equal(3, strridx('hello', 'l', 10))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
546 call assert_equal(3, strridx('hello', 'l', 3))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
547 call assert_equal(2, strridx('hello', 'l', 2))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
548 call assert_equal(-1, strridx('hello', 'l', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
549 call assert_equal(-1, strridx('hello', 'l', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
550 call assert_equal(-1, strridx('hello', 'l', -1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
551 call assert_equal(2, strridx('hello', 'll'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
552 call assert_equal(-1, strridx('hello', 'hello world'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
553 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
554
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
555 func Test_match_func()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
556 call assert_equal(4, match('testing', 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
557 call assert_equal(4, match('testing', 'ing', 2))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
558 call assert_equal(-1, match('testing', 'ing', 5))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
559 call assert_equal(-1, match('testing', 'ing', 8))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
560 call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
561 call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
562 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
563
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
564 func Test_matchend()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
565 call assert_equal(7, matchend('testing', 'ing'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
566 call assert_equal(7, matchend('testing', 'ing', 2))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
567 call assert_equal(-1, matchend('testing', 'ing', 5))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
568 call assert_equal(-1, matchend('testing', 'ing', 8))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
569 call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
570 call assert_equal(match(['vim', 'testing', 'execute'], 'img'), matchend(['vim', 'testing', 'execute'], 'img'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
571 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
572
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
573 func Test_matchlist()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
574 call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
575 call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
576 call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
577 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
578
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
579 func Test_matchstr()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
580 call assert_equal('ing', matchstr('testing', 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
581 call assert_equal('ing', matchstr('testing', 'ing', 2))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
582 call assert_equal('', matchstr('testing', 'ing', 5))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
583 call assert_equal('', matchstr('testing', 'ing', 8))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
584 call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
585 call assert_equal('', matchstr(['vim', 'testing', 'execute'], 'img'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
586 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
587
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
588 func Test_matchstrpos()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
589 call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
590 call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
591 call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
592 call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
593 call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
594 call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
595 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
596
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
597 func Test_nextnonblank_prevnonblank()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
598 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
599 insert
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
600 This
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
601
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
602
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
603 is
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
604
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
605 a
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
606 Test
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
607 .
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
608 call assert_equal(0, nextnonblank(-1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
609 call assert_equal(0, nextnonblank(0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
610 call assert_equal(1, nextnonblank(1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
611 call assert_equal(4, nextnonblank(2))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
612 call assert_equal(4, nextnonblank(3))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
613 call assert_equal(4, nextnonblank(4))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
614 call assert_equal(6, nextnonblank(5))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
615 call assert_equal(6, nextnonblank(6))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
616 call assert_equal(7, nextnonblank(7))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
617 call assert_equal(0, nextnonblank(8))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
618
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
619 call assert_equal(0, prevnonblank(-1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
620 call assert_equal(0, prevnonblank(0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
621 call assert_equal(1, prevnonblank(1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
622 call assert_equal(1, prevnonblank(2))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
623 call assert_equal(1, prevnonblank(3))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
624 call assert_equal(4, prevnonblank(4))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
625 call assert_equal(4, prevnonblank(5))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
626 call assert_equal(6, prevnonblank(6))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
627 call assert_equal(7, prevnonblank(7))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
628 call assert_equal(0, prevnonblank(8))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
629 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
630 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
631
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
632 func Test_byte2line_line2byte()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
633 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
634 call setline(1, ['a', 'bc', 'd'])
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
635
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
636 set fileformat=unix
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
637 call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
638 \ map(range(-1, 8), 'byte2line(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
639 call assert_equal([-1, -1, 1, 3, 6, 8, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
640 \ map(range(-1, 5), 'line2byte(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
641
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
642 set fileformat=mac
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
643 call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
644 \ map(range(-1, 8), 'byte2line(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
645 call assert_equal([-1, -1, 1, 3, 6, 8, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
646 \ map(range(-1, 5), 'line2byte(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
647
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
648 set fileformat=dos
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
649 call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
650 \ map(range(-1, 11), 'byte2line(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
651 call assert_equal([-1, -1, 1, 4, 8, 11, -1],
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
652 \ map(range(-1, 5), 'line2byte(v:val)'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
653
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
654 set fileformat&
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
655 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
656 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
657
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
658 func Test_count()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
659 let l = ['a', 'a', 'A', 'b']
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
660 call assert_equal(2, count(l, 'a'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
661 call assert_equal(1, count(l, 'A'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
662 call assert_equal(1, count(l, 'b'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
663 call assert_equal(0, count(l, 'B'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
664
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
665 call assert_equal(2, count(l, 'a', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
666 call assert_equal(1, count(l, 'A', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
667 call assert_equal(1, count(l, 'b', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
668 call assert_equal(0, count(l, 'B', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
669
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
670 call assert_equal(3, count(l, 'a', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
671 call assert_equal(3, count(l, 'A', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
672 call assert_equal(1, count(l, 'b', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
673 call assert_equal(1, count(l, 'B', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
674 call assert_equal(0, count(l, 'c', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
675
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
676 call assert_equal(1, count(l, 'a', 0, 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
677 call assert_equal(2, count(l, 'a', 1, 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
678 call assert_fails('call count(l, "a", 0, 10)', 'E684:')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
679
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
680 let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
681 call assert_equal(2, count(d, 'a'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
682 call assert_equal(1, count(d, 'A'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
683 call assert_equal(1, count(d, 'b'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
684 call assert_equal(0, count(d, 'B'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
685
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
686 call assert_equal(2, count(d, 'a', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
687 call assert_equal(1, count(d, 'A', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
688 call assert_equal(1, count(d, 'b', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
689 call assert_equal(0, count(d, 'B', 0))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
690
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
691 call assert_equal(3, count(d, 'a', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
692 call assert_equal(3, count(d, 'A', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
693 call assert_equal(1, count(d, 'b', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
694 call assert_equal(1, count(d, 'B', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
695 call assert_equal(0, count(d, 'c', 1))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
696
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
697 call assert_fails('call count(d, "a", 0, 1)', 'E474:')
11828
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
698
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
699 call assert_equal(0, count("foo", "bar"))
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
700 call assert_equal(1, count("foo", "oo"))
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
701 call assert_equal(2, count("foo", "o"))
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
702 call assert_equal(0, count("foo", "O"))
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
703 call assert_equal(2, count("foo", "O", 1))
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
704 call assert_equal(2, count("fooooo", "oo"))
13070
17720967656c patch 8.0.1410: hang when using count() with an empty string
Christian Brabandt <cb@256bit.org>
parents: 12869
diff changeset
705 call assert_equal(0, count("foo", ""))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
706 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
707
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
708 func Test_changenr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
709 new Xchangenr
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
710 call assert_equal(0, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
711 norm ifoo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
712 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
713 set undolevels=10
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
714 norm Sbar
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
715 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
716 undo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
717 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
718 redo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
719 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
720 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
721 set undolevels&
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
722 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
723
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
724 func Test_filewritable()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
725 new Xfilewritable
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
726 write!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
727 call assert_equal(1, filewritable('Xfilewritable'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
728
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
729 call assert_notequal(0, setfperm('Xfilewritable', 'r--r-----'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
730 call assert_equal(0, filewritable('Xfilewritable'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
731
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
732 call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
733 call assert_equal(1, filewritable('Xfilewritable'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
734
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
735 call assert_equal(0, filewritable('doesnotexist'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
736
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
737 call delete('Xfilewritable')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
738 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
739 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
740
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
741 func Test_hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
742 let hostname_vim = hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
743 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
744 let hostname_system = systemlist('uname -n')[0]
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
745 call assert_equal(hostname_vim, hostname_system)
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
746 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
747 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
748
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
749 func Test_getpid()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
750 " getpid() always returns the same value within a vim instance.
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
751 call assert_equal(getpid(), getpid())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
752 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
753 call assert_equal(systemlist('echo $PPID')[0], string(getpid()))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
754 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
755 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
756
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
757 func Test_hlexists()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
758 call assert_equal(0, hlexists('does_not_exist'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
759 call assert_equal(0, hlexists('Number'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
760 call assert_equal(0, highlight_exists('does_not_exist'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
761 call assert_equal(0, highlight_exists('Number'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
762 syntax on
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
763 call assert_equal(0, hlexists('does_not_exist'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
764 call assert_equal(1, hlexists('Number'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
765 call assert_equal(0, highlight_exists('does_not_exist'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
766 call assert_equal(1, highlight_exists('Number'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
767 syntax off
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
768 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
769
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
770 func Test_col()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
771 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
772 call setline(1, 'abcdef')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
773 norm gg4|mx6|mY2|
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
774 call assert_equal(2, col('.'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
775 call assert_equal(7, col('$'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
776 call assert_equal(4, col("'x"))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
777 call assert_equal(6, col("'Y"))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
778 call assert_equal(2, col([1, 2]))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
779 call assert_equal(7, col([1, '$']))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
780
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
781 call assert_equal(0, col(''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
782 call assert_equal(0, col('x'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
783 call assert_equal(0, col([2, '$']))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
784 call assert_equal(0, col([1, 100]))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
785 call assert_equal(0, col([1]))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
786 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
787 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
788
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
789 func Test_balloon_show()
11024
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
790 if has('balloon_eval')
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
791 " This won't do anything but must not crash either.
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
792 call balloon_show('hi!')
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
793 endif
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
794 endfunc
11191
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
795
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
796 func Test_setbufvar_options()
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
797 " This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
798 " window layout.
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
799 call assert_equal(1, winnr('$'))
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
800 split dummy_preview
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
801 resize 2
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
802 set winfixheight winfixwidth
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
803 let prev_id = win_getid()
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
804
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
805 wincmd j
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
806 let wh = winheight('.')
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
807 let dummy_buf = bufnr('dummy_buf1', v:true)
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
808 call setbufvar(dummy_buf, '&buftype', 'nofile')
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
809 execute 'belowright vertical split #' . dummy_buf
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
810 call assert_equal(wh, winheight('.'))
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
811 let dum1_id = win_getid()
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
812
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
813 wincmd h
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
814 let wh = winheight('.')
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
815 let dummy_buf = bufnr('dummy_buf2', v:true)
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
816 call setbufvar(dummy_buf, '&buftype', 'nofile')
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
817 execute 'belowright vertical split #' . dummy_buf
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
818 call assert_equal(wh, winheight('.'))
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
819
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
820 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
821 call win_gotoid(prev_id)
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
822 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
823 call win_gotoid(dum1_id)
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
824 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
825 endfunc
11325
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
826
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
827 func Test_redo_in_nested_functions()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
828 nnoremap g. :set opfunc=Operator<CR>g@
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
829 function Operator( type, ... )
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
830 let @x = 'XXX'
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
831 execute 'normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]' . '"xp'
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
832 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
833
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
834 function! Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
835 5,6normal! .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
836 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
837
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
838 new
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
839 call setline(1, repeat(['some "quoted" text', 'more "quoted" text'], 3))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
840 1normal g.i"
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
841 call assert_equal('some "XXX" text', getline(1))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
842 3,4normal .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
843 call assert_equal('some "XXX" text', getline(3))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
844 call assert_equal('more "XXX" text', getline(4))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
845 call Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
846 call assert_equal('some "XXX" text', getline(5))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
847 call assert_equal('more "XXX" text', getline(6))
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
848 bwipe!
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
849
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
850 nunmap g.
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
851 delfunc Operator
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
852 delfunc Apply
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
853 endfunc
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
854
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
855 func Test_shellescape()
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
856 let save_shell = &shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
857 set shell=bash
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
858 call assert_equal("'text'", shellescape('text'))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
859 call assert_equal("'te\"xt'", shellescape('te"xt'))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
860 call assert_equal("'te'\\''xt'", shellescape("te'xt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
861
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
862 call assert_equal("'te%xt'", shellescape("te%xt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
863 call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
864 call assert_equal("'te#xt'", shellescape("te#xt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
865 call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
866 call assert_equal("'te!xt'", shellescape("te!xt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
867 call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
868
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
869 call assert_equal("'te\nxt'", shellescape("te\nxt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
870 call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
871 set shell=tcsh
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
872 call assert_equal("'te\\!xt'", shellescape("te!xt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
873 call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
874 call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
875 call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
876
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
877 let &shell = save_shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
878 endfunc