annotate src/testdir/test_functions.vim @ 17137:ca4e6685e2f4 v8.1.1568

patch 8.1.1568: strftime() test fails on MS-Windows commit https://github.com/vim/vim/commit/87652a7e3b94755084944afec51a0bfcd8b0a0c3 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 18 23:07:37 2019 +0200 patch 8.1.1568: strftime() test fails on MS-Windows Problem: Strftime() test fails on MS-Windows. Solution: Skip the check for using the $TZ environment variable.
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Jun 2019 23:15:06 +0200
parents d03a52e02f1a
children 6990c1160ea5
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.
14669
63d5ae57a663 patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents: 14579
diff changeset
2 source shared.vim
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
4 " 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
5 func Test_00_bufexists()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
6 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
7 call assert_equal(1, bufexists(bufnr('%')))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
8 call assert_equal(0, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
9 new Xfoo
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
10 let bn = bufnr('%')
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
11 call assert_equal(1, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
12 call assert_equal(1, bufexists('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(getcwd() . '/Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
14 call assert_equal(1, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
15 bw
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
16 call assert_equal(0, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
17 call assert_equal(0, bufexists('Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
18 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
19
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
20 func Test_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(1, empty(''))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
22 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
23
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(1, empty(-0))
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 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
28
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(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
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))
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(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
34 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
35
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(1, empty([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
37 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
38
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(1, empty({}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
40 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
41
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:null))
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:none))
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(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
45 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
46
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
47 if has('channel')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
48 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
49 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
50 if has('job')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
51 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
52 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
53
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
54 call assert_equal(0, empty(function('Test_empty')))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
55 call assert_equal(0, empty(function('Test_empty', [0])))
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
56 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
57
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
58 func Test_len()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
59 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
60 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
61
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
62 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
63 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
64
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
65 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
66 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
67
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
68 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
69 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
70
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
71 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
72 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
73 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
74
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
75 func Test_max()
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(0, max([]))
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([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
78 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
79 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
80
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
81 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
82 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
83
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
84 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
85 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
86 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
87
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
88 func Test_min()
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(0, min([]))
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(2, min([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
91 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
92 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
93
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
94 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
95 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
96
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
97 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
98 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
99 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
100
13980
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
101 func Test_strwidth()
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
102 for aw in ['single', 'double']
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
103 exe 'set ambiwidth=' . aw
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
104 call assert_equal(0, strwidth(''))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
105 call assert_equal(1, strwidth("\t"))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
106 call assert_equal(3, strwidth('Vim'))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
107 call assert_equal(4, strwidth(1234))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
108 call assert_equal(5, strwidth(-1234))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
109
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
110 call assert_equal(2, strwidth('😉'))
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
111 call assert_equal(17, strwidth('Eĥoŝanĝo ĉiuĵaŭde'))
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
112 call assert_equal((aw == 'single') ? 6 : 7, strwidth('Straße'))
13980
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
113
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
114 call assert_fails('call strwidth({->0})', 'E729:')
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
115 call assert_fails('call strwidth([])', 'E730:')
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
116 call assert_fails('call strwidth({})', 'E731:')
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
117 call assert_fails('call strwidth(1.2)', 'E806:')
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
118 endfor
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
119
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
120 set ambiwidth&
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
121 endfunc
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
122
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 func Test_str2nr()
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 call assert_equal(0, str2nr(''))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 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
126 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
127
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 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
129 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
130 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
131
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 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
133 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
134 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
135
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 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
137 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
138
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(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
140 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
141 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
142 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
143 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
144 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
145
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
146 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
147 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
148 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
149 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
150
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
159 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
160 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
161 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
162 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
163 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
164
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
165 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
166 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
167
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
168 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
169 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
170 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
171 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
172 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
173
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
174 func Test_strftime()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
175 if !exists('*strftime')
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
176 return
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
177 endif
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
178 " 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
179 " 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
180 " 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
181 "
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
182 " 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
183 " 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
184 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
185 "
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
186 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
187
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
188 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
189 call assert_fails('call strftime("%Y", [])', 'E745:')
17135
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
190
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
191 " Check that the time changes after we change the timezone
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
192 " Save previous timezone value, if any
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
193 if exists('$TZ')
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
194 let tz = $TZ
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
195 endif
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
196
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
197 " Force EST and then UTC, save the current hour (24-hour clock) for each
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
198 let $TZ = 'EST' | let est = strftime('%H')
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
199 let $TZ = 'UTC' | let utc = strftime('%H')
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
200
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
201 " Those hours should be two bytes long, and should not be the same; if they
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
202 " are, a tzset(3) call may have failed somewhere
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
203 call assert_equal(strlen(est), 2)
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
204 call assert_equal(strlen(utc), 2)
17137
ca4e6685e2f4 patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 17135
diff changeset
205 " TODO: this fails on MS-Windows
ca4e6685e2f4 patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 17135
diff changeset
206 if has('unix')
ca4e6685e2f4 patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 17135
diff changeset
207 call assert_notequal(est, utc)
ca4e6685e2f4 patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 17135
diff changeset
208 endif
17135
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
209
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
210 " If we cached a timezone value, put it back, otherwise clear it
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
211 if exists('tz')
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
212 let $TZ = tz
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
213 else
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
214 unlet $TZ
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
215 endif
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
216
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
217 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
218
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
219 func Test_resolve_unix()
14885
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
220 if !has('unix')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
221 return
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
222 endif
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
223
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
224 " Xlink1 -> Xlink2
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
225 " Xlink2 -> Xlink3
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
226 silent !ln -s -f Xlink2 Xlink1
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
227 silent !ln -s -f Xlink3 Xlink2
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
228 call assert_equal('Xlink3', resolve('Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
229 call assert_equal('./Xlink3', resolve('./Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
230 call assert_equal('Xlink3/', resolve('Xlink2/'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
231 " FIXME: these tests result in things like "Xlink2/" instead of "Xlink3/"?!
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
232 "call assert_equal('Xlink3/', resolve('Xlink1/'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
233 "call assert_equal('./Xlink3/', resolve('./Xlink1/'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
234 "call assert_equal(getcwd() . '/Xlink3/', resolve(getcwd() . '/Xlink1/'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
235 call assert_equal(getcwd() . '/Xlink3', resolve(getcwd() . '/Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
236
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
237 " Test resolve() with a symlink cycle.
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
238 " Xlink1 -> Xlink2
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
239 " Xlink2 -> Xlink3
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
240 " Xlink3 -> Xlink1
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
241 silent !ln -s -f Xlink1 Xlink3
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
242 call assert_fails('call resolve("Xlink1")', 'E655:')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
243 call assert_fails('call resolve("./Xlink1")', 'E655:')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
244 call assert_fails('call resolve("Xlink2")', 'E655:')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
245 call assert_fails('call resolve("Xlink3")', 'E655:')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
246 call delete('Xlink1')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
247 call delete('Xlink2')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
248 call delete('Xlink3')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
249
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
250 silent !ln -s -f Xdir//Xfile Xlink
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
251 call assert_equal('Xdir/Xfile', resolve('Xlink'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
252 call delete('Xlink')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
253
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
254 silent !ln -s -f Xlink2/ Xlink1
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
255 call assert_equal('Xlink2', resolve('Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
256 call assert_equal('Xlink2/', resolve('Xlink1/'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
257 call delete('Xlink1')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
258
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
259 silent !ln -s -f ./Xlink2 Xlink1
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
260 call assert_equal('Xlink2', resolve('Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
261 call assert_equal('./Xlink2', resolve('./Xlink1'))
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
262 call delete('Xlink1')
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
263 endfunc
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
264
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
265 func s:normalize_fname(fname)
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
266 let ret = substitute(a:fname, '\', '/', 'g')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
267 let ret = substitute(ret, '//', '/', 'g')
16831
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
268 return tolower(ret)
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
269 endfunc
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
270
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
271 func Test_resolve_win32()
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
272 if !has('win32')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
273 return
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
274 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
275
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
276 " test for shortcut file
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
277 if executable('cscript')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
278 new Xfile
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
279 wq
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
280 call writefile([
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
281 \ 'Set fs = CreateObject("Scripting.FileSystemObject")',
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
282 \ 'Set ws = WScript.CreateObject("WScript.Shell")',
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
283 \ 'Set shortcut = ws.CreateShortcut("Xlink.lnk")',
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
284 \ 'shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile")',
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
285 \ 'shortcut.Save'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
286 \], 'link.vbs')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
287 silent !cscript link.vbs
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
288 call delete('link.vbs')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
289 call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
290 call delete('Xfile')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
291
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
292 call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
293 call delete('Xlink.lnk')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
294 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
295 echomsg 'skipped test for shortcut file'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
296 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
297
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
298 " remove files
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
299 call delete('Xlink')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
300 call delete('Xdir', 'd')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
301 call delete('Xfile')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
302
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
303 " test for symbolic link to a file
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
304 new Xfile
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
305 wq
16945
efd36a9052cc patch 8.1.1473: new resolve() implementation causes problem for plugins
Bram Moolenaar <Bram@vim.org>
parents: 16831
diff changeset
306 call assert_equal('Xfile', resolve('Xfile'))
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
307 silent !mklink Xlink Xfile
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
308 if !v:shell_error
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
309 call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
310 call delete('Xlink')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
311 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
312 echomsg 'skipped test for symbolic link to a file'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
313 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
314 call delete('Xfile')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
315
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
316 " test for junction to a directory
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
317 call mkdir('Xdir')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
318 silent !mklink /J Xlink Xdir
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
319 if !v:shell_error
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
320 call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
321
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
322 call delete('Xdir', 'd')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
323
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
324 " test for junction already removed
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
325 call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
326 call delete('Xlink')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
327 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
328 echomsg 'skipped test for junction to a directory'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
329 call delete('Xdir', 'd')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
330 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
331
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
332 " test for symbolic link to a directory
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
333 call mkdir('Xdir')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
334 silent !mklink /D Xlink Xdir
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
335 if !v:shell_error
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
336 call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
337
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
338 call delete('Xdir', 'd')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
339
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
340 " test for symbolic link already removed
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
341 call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
342 call delete('Xlink')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
343 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
344 echomsg 'skipped test for symbolic link to a directory'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
345 call delete('Xdir', 'd')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
346 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
347
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
348 " test for buffer name
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
349 new Xfile
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
350 wq
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
351 silent !mklink Xlink Xfile
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
352 if !v:shell_error
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
353 edit Xlink
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
354 call assert_equal('Xlink', bufname('%'))
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
355 call delete('Xlink')
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
356 bw!
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
357 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
358 echomsg 'skipped test for buffer name'
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
359 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
360 call delete('Xfile')
16831
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
361
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
362 " test for reparse point
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
363 call mkdir('Xdir')
16945
efd36a9052cc patch 8.1.1473: new resolve() implementation causes problem for plugins
Bram Moolenaar <Bram@vim.org>
parents: 16831
diff changeset
364 call assert_equal('Xdir', resolve('Xdir'))
16831
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
365 silent !mklink /D Xdirlink Xdir
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
366 if !v:shell_error
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
367 w Xdir/text.txt
16945
efd36a9052cc patch 8.1.1473: new resolve() implementation causes problem for plugins
Bram Moolenaar <Bram@vim.org>
parents: 16831
diff changeset
368 call assert_equal('Xdir/text.txt', resolve('Xdir/text.txt'))
16831
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
369 call assert_equal(s:normalize_fname(getcwd() . '\Xdir\text.txt'), s:normalize_fname(resolve('Xdirlink\text.txt')))
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
370 call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve('Xdirlink')))
16945
efd36a9052cc patch 8.1.1473: new resolve() implementation causes problem for plugins
Bram Moolenaar <Bram@vim.org>
parents: 16831
diff changeset
371 call delete('Xdirlink')
16831
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
372 else
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
373 echomsg 'skipped test for reparse point'
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
374 endif
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
375
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
376 call delete('Xdir', 'rf')
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
377 endfunc
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
378
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
379 func Test_simplify()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
380 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
381 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
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
392 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
393 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
394 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
395 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
396 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
397
14487
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
398 func Test_pathshorten()
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
399 call assert_equal('', pathshorten(''))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
400 call assert_equal('foo', pathshorten('foo'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
401 call assert_equal('/foo', pathshorten('/foo'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
402 call assert_equal('f/', pathshorten('foo/'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
403 call assert_equal('f/bar', pathshorten('foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
404 call assert_equal('f/b/foobar', pathshorten('foo/bar/foobar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
405 call assert_equal('/f/b/foobar', pathshorten('/foo/bar/foobar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
406 call assert_equal('.f/bar', pathshorten('.foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
407 call assert_equal('~f/bar', pathshorten('~foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
408 call assert_equal('~.f/bar', pathshorten('~.foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
409 call assert_equal('.~f/bar', pathshorten('.~foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
410 call assert_equal('~/f/bar', pathshorten('~/foo/bar'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
411 endfunc
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
412
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
413 func Test_strpart()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
414 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
415 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
416 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
417 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
418 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
419
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
420 call assert_equal('lép', strpart('éléphant', 2, 4))
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
421 call assert_equal('léphant', strpart('éléphant', 2))
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
422 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
423
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
424 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
425 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
426
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
427 " 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
428 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
429 \ 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
430
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
431 " 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
432 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
433 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
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 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
457 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
458
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
459 " 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
460 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
487 " 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
488 " Ⱥ (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
489 " 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
490 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
491
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
492 " 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
493 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
494 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
495 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
496 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
497
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
498 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
499 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
500
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
501 " 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
502 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
503 \ 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
504
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
505 " 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
506 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
507 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
508 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
509 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
510 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
511 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
512 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
513 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
514 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
515 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
516 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
517 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
518 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
519 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
520 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
521 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
522 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
523 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
524 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
525 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
526 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
527 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
528 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
529 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
530 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
531 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
532
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
533 " 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
534 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
535 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
536 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
537 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
538 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
539 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
540 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
541 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
542 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
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 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
554 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
555 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
556 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
557 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
558 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
559 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
560
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
561 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
562
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
563 " 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
564 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
565 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
566 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
567 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
568
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
569 " 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
570 let current_modes = ''
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
571 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
572 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
573 return ''
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
574 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
575
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
576 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
577 new
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
578 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
579
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
580 " 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
581 set complete=.
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
582
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
583 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
584
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
585 normal! 3G
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
586 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
587 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
588 " 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
589 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
590 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
591 " 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
592 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
593 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
594 " 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
595 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
596 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
597 " 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
598 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
599 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
600 " 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
601 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
602 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
603 " 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
604 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
605 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
606 " 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
607 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
608 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
609 " 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
610 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
611 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
612 " 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
613 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
614 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
615 " 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
616 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
617 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
618 " 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
619 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
620 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
621
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
622 " 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
623 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
624 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
625 " 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
626 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
627 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
628 " 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
629 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
630 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
631 " 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
632 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
633 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
634 " 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
635 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
636 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
637 " 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
638 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
639 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
640 " 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
641 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
642 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
643 " 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
644 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
645 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
646 " 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
647 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
648 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
649 " 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
650 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
651 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
652 " 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
653 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
654 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
655
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
656 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
657 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
658
14422
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
659 " i_CTRL-O
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
660 exe "normal i\<C-O>:call Save_mode()\<Cr>\<Esc>"
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
661 call assert_equal("n-niI", g:current_modes)
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
662
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
663 " R_CTRL-O
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
664 exe "normal R\<C-O>:call Save_mode()\<Cr>\<Esc>"
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
665 call assert_equal("n-niR", g:current_modes)
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
666
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
667 " gR_CTRL-O
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
668 exe "normal gR\<C-O>:call Save_mode()\<Cr>\<Esc>"
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
669 call assert_equal("n-niV", g:current_modes)
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
670
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
671 " 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
672
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
673 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
674 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
675 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
676 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
677 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
678 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
679 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
680 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
681 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
682 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
683
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
684 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
685 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
686 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
687 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
688 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
689 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
690 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
691 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
692 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
693 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
694
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
695 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
696 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
697 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
698 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
699 " 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
700
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
701 bwipe!
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
702 iunmap <F2>
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
703 set complete&
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
704 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
705
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
706 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
707 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
708 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
709 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
710 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
711 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
712
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
713 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
714 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
715 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
716 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
717
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
718 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
719 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
720
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
721 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
722 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
723 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
724
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
725 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
726 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
727 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
728 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
729
11197
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 11191
diff changeset
730 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
731 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
732 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
733
10891
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
734 call assert_equal(0, getbufvar(bnr, '&autoindent'))
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
735 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
736
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
737 " 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
738 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
739 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
740 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
741 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
742 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
743 close
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
744
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
745 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
746 endfunc
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
747
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
748 func Test_last_buffer_nr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
749 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
750 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
751
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
752 func Test_stridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
753 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
754 call assert_equal(0, stridx('', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
755 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
756 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
757 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
758 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
759 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
760 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
761 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
762 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
763 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
764 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
765 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
766
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
767 func Test_strridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
768 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
769 call assert_equal(0, strridx('', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
770 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
771 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
772 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
773 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
774 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
775 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
776 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
777 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
778 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
779 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
780 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
781 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
782
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
783 func Test_match_func()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
784 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
785 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
786 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
787 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
788 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
789 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
790 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
791
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
792 func Test_matchend()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
793 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
794 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
795 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
796 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
797 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
798 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
799 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
800
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
801 func Test_matchlist()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
802 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
803 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
804 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
805 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
806
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
807 func Test_matchstr()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
808 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
809 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
810 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
811 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
812 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
813 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
814 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
815
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
816 func Test_matchstrpos()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
817 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
818 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
819 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
820 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
821 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
822 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
823 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
824
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
825 func Test_nextnonblank_prevnonblank()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
826 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
827 insert
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
828 This
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
829
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
830
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
831 is
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
832
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
833 a
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
834 Test
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
835 .
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
836 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
847 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
848 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
849 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
850 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
851 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
852 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
853 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
854 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
855 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
856 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
857 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
858 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
859
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
860 func Test_byte2line_line2byte()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
861 new
14579
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
862 set endofline
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
863 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
864
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
865 set fileformat=unix
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
866 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
867 \ 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
868 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
869 \ 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
870
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
871 set fileformat=mac
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
872 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
873 \ 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
874 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
875 \ 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
876
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
877 set fileformat=dos
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
878 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
879 \ 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
880 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
881 \ 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
882
14579
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
883 bw!
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
884 set noendofline nofixendofline
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
885 normal a-
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
886 for ff in ["unix", "mac", "dos"]
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
887 let &fileformat = ff
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
888 call assert_equal(1, line2byte(1))
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
889 call assert_equal(2, line2byte(2)) " line2byte(line("$") + 1) is the buffer size plus one (as per :help line2byte).
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
890 endfor
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
891
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
892 set endofline& fixendofline& fileformat&
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
893 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
894 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
895
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
896 func Test_count()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
897 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
898 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
899 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
900 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
901 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
902
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
903 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
904 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
905 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
906 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
907
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
908 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
909 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
910 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
911 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
912 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
913
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
914 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
915 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
916 call assert_fails('call count(l, "a", 0, 10)', 'E684:')
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
917 call assert_fails('call count(l, "a", [])', 'E745:')
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
918
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
919 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
920 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
921 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
922 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
923 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
924
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
925 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
926 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
927 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
928 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
929
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
930 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
931 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
932 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
933 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
934 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
935
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
936 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
937
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
938 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
939 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
940 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
941 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
942 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
943 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
944 call assert_equal(0, count("foo", ""))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
945
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
946 call assert_fails('call count(0, 0)', 'E712:')
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
947 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
948
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
949 func Test_changenr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
950 new Xchangenr
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
951 call assert_equal(0, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
952 norm ifoo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
953 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
954 set undolevels=10
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
955 norm Sbar
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
956 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
957 undo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
958 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
959 redo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
960 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
961 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
962 set undolevels&
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
963 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
964
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
965 func Test_filewritable()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
966 new Xfilewritable
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
967 write!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
968 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
969
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
970 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
971 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
972
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
973 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
974 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
975
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
976 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
977
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
978 call delete('Xfilewritable')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
979 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
980 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
981
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
982 func Test_Executable()
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
983 if has('win32')
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
984 call assert_equal(1, executable('notepad'))
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
985 call assert_equal(1, executable('notepad.exe'))
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
986 call assert_equal(0, executable('notepad.exe.exe'))
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
987 call assert_equal(0, executable('shell32.dll'))
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
988 call assert_equal(0, executable('win.ini'))
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
989 elseif has('unix')
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
990 call assert_equal(1, executable('cat'))
14895
bde025b0d7de patch 8.1.0459: Test_executable fails when there is a dog in the system
Bram Moolenaar <Bram@vim.org>
parents: 14885
diff changeset
991 call assert_equal(0, executable('nodogshere'))
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
992 endif
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
993 endfunc
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
994
16180
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
995 func Test_executable_longname()
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
996 if !has('win32')
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
997 return
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
998 endif
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
999
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1000 let fname = 'X' . repeat('あ', 200) . '.bat'
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1001 call writefile([], fname)
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1002 call assert_equal(1, executable(fname))
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1003 call delete(fname)
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1004 endfunc
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1005
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1006 func Test_hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1007 let hostname_vim = hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1008 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1009 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
1010 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
1011 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1012 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1013
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1014 func Test_getpid()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1015 " 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
1016 call assert_equal(getpid(), getpid())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1017 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1018 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
1019 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1020 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1021
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1022 func Test_hlexists()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1023 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
1024 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
1025 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
1026 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
1027 syntax on
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1028 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
1029 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
1030 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
1031 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
1032 syntax off
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1033 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1034
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1035 func Test_col()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1036 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1037 call setline(1, 'abcdef')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1038 norm gg4|mx6|mY2|
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1039 call assert_equal(2, col('.'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1040 call assert_equal(7, col('$'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1041 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
1042 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
1043 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
1044 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
1045
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1046 call assert_equal(0, col(''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1047 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
1048 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
1049 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
1050 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
1051 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1052 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1053
14379
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1054 func Test_inputlist()
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1055 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1056 call assert_equal(1, c)
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1057 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx')
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1058 call assert_equal(2, c)
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1059 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1060 call assert_equal(3, c)
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1061
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1062 call assert_fails('call inputlist("")', 'E686:')
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1063 endfunc
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1064
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
1065 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
1066 if has('balloon_eval')
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
1067 " 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
1068 call balloon_show('hi!')
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
1069 endif
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
1070 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
1071
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1072 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
1073 " 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
1074 " 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
1075 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
1076 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
1077 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
1078 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
1079 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
1080
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1081 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
1082 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
1083 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
1084 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
1085 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
1086 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
1087 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
1088
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1089 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
1090 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
1091 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
1092 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
1093 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
1094 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
1095
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1096 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1097 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
1098 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1099 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
1100 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1101 endfunc
11325
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1102
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1103 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
1104 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
1105 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
1106 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
1107 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
1108 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1109
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1110 function! Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1111 5,6normal! .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1112 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1113
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1114 new
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1115 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
1116 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
1117 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
1118 3,4normal .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1119 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
1120 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
1121 call Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1122 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
1123 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
1124 bwipe!
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1125
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1126 nunmap g.
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1127 delfunc Operator
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1128 delfunc Apply
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1129 endfunc
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1130
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1131 func Test_shellescape()
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1132 let save_shell = &shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1133 set shell=bash
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1134 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
1135 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
1136 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
1137
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1138 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
1139 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
1140 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
1141 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
1142 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
1143 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
1144
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1145 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
1146 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
1147 set shell=tcsh
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1148 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
1149 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
1150 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
1151 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
1152
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1153 let &shell = save_shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1154 endfunc
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1155
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1156 func Test_trim()
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1157 call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1158 call assert_equal("Testing", trim(" \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1159 call assert_equal("RESERVE", trim("xyz \twwRESERVEzyww \t\t", " wxyz\t"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1160 call assert_equal("wRE \tSERVEzyww", trim("wRE \tSERVEzyww"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1161 call assert_equal("abcd\t xxxx tail", trim(" \tabcd\t xxxx tail"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1162 call assert_equal("\tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", " "))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1163 call assert_equal(" \tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", "abx"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1164 call assert_equal("RESERVE", trim("你RESERVE好", "你好"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1165 call assert_equal("您R E SER V E早", trim("你好您R E SER V E早好你你", "你好"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1166 call assert_equal("你好您R E SER V E早好你你", trim(" \n\r\r 你好您R E SER V E早好你你 \t \x0B", ))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1167 call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" 你好您R E SER V E早好你你 \t \x0B", " 你好"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1168 call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你好tes"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1169 call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你你你好好好tttsses"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1170 call assert_equal("留下", trim("这些些不要这些留下这些", "这些不要"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1171 call assert_equal("", trim("", ""))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1172 call assert_equal("a", trim("a", ""))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1173 call assert_equal("", trim("", "a"))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1174
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1175 let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1176 call assert_equal("x", trim(chars . "x" . chars))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1177 endfunc
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1178
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1179 " Test for reg_recording() and reg_executing()
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1180 func Test_reg_executing_and_recording()
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1181 let s:reg_stat = ''
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1182 func s:save_reg_stat()
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1183 let s:reg_stat = reg_recording() . ':' . reg_executing()
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1184 return ''
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1185 endfunc
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1186
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1187 new
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1188 call s:save_reg_stat()
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1189 call assert_equal(':', s:reg_stat)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1190 call feedkeys("qa\"=s:save_reg_stat()\<CR>pq", 'xt')
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1191 call assert_equal('a:', s:reg_stat)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1192 call feedkeys("@a", 'xt')
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1193 call assert_equal(':a', s:reg_stat)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1194 call feedkeys("qb@aq", 'xt')
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1195 call assert_equal('b:a', s:reg_stat)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1196 call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt')
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1197 call assert_equal('":', s:reg_stat)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1198
15973
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1199 " :normal command saves and restores reg_executing
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1200 let s:reg_stat = ''
15973
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1201 let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1202 func TestFunc() abort
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1203 normal! ia
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1204 endfunc
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1205 call feedkeys("@q", 'xt')
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1206 call assert_equal(':q', s:reg_stat)
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1207 delfunc TestFunc
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1208
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1209 " getchar() command saves and restores reg_executing
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1210 map W :call TestFunc()<CR>
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1211 let @q = "W"
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1212 let g:typed = ''
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1213 let g:regs = []
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1214 func TestFunc() abort
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1215 let g:regs += [reg_executing()]
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1216 let g:typed = getchar(0)
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1217 let g:regs += [reg_executing()]
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1218 endfunc
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1219 call feedkeys("@qy", 'xt')
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1220 call assert_equal(char2nr("y"), g:typed)
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1221 call assert_equal(['q', 'q'], g:regs)
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1222 delfunc TestFunc
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1223 unmap W
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1224 unlet g:typed
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1225 unlet g:regs
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1226
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1227 " input() command saves and restores reg_executing
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1228 map W :call TestFunc()<CR>
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1229 let @q = "W"
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1230 let g:typed = ''
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1231 let g:regs = []
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1232 func TestFunc() abort
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1233 let g:regs += [reg_executing()]
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1234 let g:typed = input('?')
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1235 let g:regs += [reg_executing()]
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1236 endfunc
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1237 call feedkeys("@qy\<CR>", 'xt')
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1238 call assert_equal("y", g:typed)
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1239 call assert_equal(['q', 'q'], g:regs)
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1240 delfunc TestFunc
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1241 unmap W
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1242 unlet g:typed
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1243 unlet g:regs
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1244
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1245 bwipe!
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1246 delfunc s:save_reg_stat
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1247 unlet s:reg_stat
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1248 endfunc
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1249
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1250 func Test_libcall_libcallnr()
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1251 if !has('libcall')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1252 return
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1253 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1254
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1255 if has('win32')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1256 let libc = 'msvcrt.dll'
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1257 elseif has('mac')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1258 let libc = 'libSystem.B.dylib'
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1259 elseif executable('ldd')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1260 let libc = matchstr(split(system('ldd ' . GetVimProg())), '/libc\.so\>')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1261 endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1262 if get(l:, 'libc', '') ==# ''
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1263 " On Unix, libc.so can be in various places.
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1264 if has('linux')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1265 " There is not documented but regarding the 1st argument of glibc's
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1266 " dlopen an empty string and nullptr are equivalent, so using an empty
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1267 " string for the 1st argument of libcall allows to call functions.
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1268 let libc = ''
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1269 elseif has('sun')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1270 " Set the path to libc.so according to the architecture.
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1271 let test_bits = system('file ' . GetVimProg())
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1272 let test_arch = system('uname -p')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1273 if test_bits =~ '64-bit' && test_arch =~ 'sparc'
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1274 let libc = '/usr/lib/sparcv9/libc.so'
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1275 elseif test_bits =~ '64-bit' && test_arch =~ 'i386'
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1276 let libc = '/usr/lib/amd64/libc.so'
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1277 else
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1278 let libc = '/usr/lib/libc.so'
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1279 endif
14669
63d5ae57a663 patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents: 14579
diff changeset
1280 else
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1281 " Unfortunately skip this test until a good way is found.
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1282 return
14669
63d5ae57a663 patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents: 14579
diff changeset
1283 endif
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1284 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1285
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1286 if has('win32')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1287 call assert_equal($USERPROFILE, libcall(libc, 'getenv', 'USERPROFILE'))
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1288 else
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1289 call assert_equal($HOME, libcall(libc, 'getenv', 'HOME'))
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1290 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1291
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1292 " If function returns NULL, libcall() should return an empty string.
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1293 call assert_equal('', libcall(libc, 'getenv', 'X_ENV_DOES_NOT_EXIT'))
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1294
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1295 " Test libcallnr() with string and integer argument.
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1296 call assert_equal(4, libcallnr(libc, 'strlen', 'abcd'))
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1297 call assert_equal(char2nr('A'), libcallnr(libc, 'toupper', char2nr('a')))
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1298
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1299 call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", 'E364:')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1300 call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", 'E364:')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1301
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1302 call assert_fails("call libcall('Xdoesnotexist_', 'getenv', 'HOME')", 'E364:')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1303 call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1304 endfunc
14348
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1305
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1306 sandbox function Fsandbox()
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1307 normal ix
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1308 endfunc
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1309
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1310 func Test_func_sandbox()
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1311 sandbox let F = {-> 'hello'}
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1312 call assert_equal('hello', F())
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1313
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1314 sandbox let F = {-> execute("normal ix\<Esc>")}
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1315 call assert_fails('call F()', 'E48:')
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1316 unlet F
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1317
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1318 call assert_fails('call Fsandbox()', 'E48:')
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1319 delfunc Fsandbox
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1320 endfunc
15000
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1321
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1322 func EditAnotherFile()
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1323 let word = expand('<cword>')
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1324 edit Xfuncrange2
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1325 endfunc
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1326
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1327 func Test_func_range_with_edit()
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1328 " Define a function that edits another buffer, then call it with a range that
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1329 " is invalid in that buffer.
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1330 call writefile(['just one line'], 'Xfuncrange2')
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1331 new
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1332 call setline(1, range(10))
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1333 write Xfuncrange1
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1334 call assert_fails('5,8call EditAnotherFile()', 'E16:')
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1335
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1336 call delete('Xfuncrange1')
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1337 call delete('Xfuncrange2')
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1338 bwipe!
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1339 endfunc
15008
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1340
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1341 func Test_func_exists_on_reload()
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1342 call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1343 call assert_equal(0, exists('*ExistingFunction'))
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1344 source Xfuncexists
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1345 call assert_equal(1, exists('*ExistingFunction'))
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1346 " Redefining a function when reloading a script is OK.
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1347 source Xfuncexists
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1348 call assert_equal(1, exists('*ExistingFunction'))
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1349
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1350 " But redefining in another script is not OK.
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1351 call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1352 call assert_fails('source Xfuncexists2', 'E122:')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1353
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1354 delfunc ExistingFunction
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1355 call assert_equal(0, exists('*ExistingFunction'))
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1356 call writefile([
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1357 \ 'func ExistingFunction()', 'echo "yes"', 'endfunc',
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1358 \ 'func ExistingFunction()', 'echo "no"', 'endfunc',
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1359 \ ], 'Xfuncexists')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1360 call assert_fails('source Xfuncexists', 'E122:')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1361 call assert_equal(1, exists('*ExistingFunction'))
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1362
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1363 call delete('Xfuncexists2')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1364 call delete('Xfuncexists')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1365 delfunc ExistingFunction
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1366 endfunc
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1367
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1368 " Test confirm({msg} [, {choices} [, {default} [, {type}]]])
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1369 func Test_confirm()
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1370 if !has('unix') || has('gui_running')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1371 return
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1372 endif
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1373
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1374 call feedkeys('o', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1375 let a = confirm('Press O to proceed')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1376 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1377
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1378 call feedkeys('y', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1379 let a = confirm('Are you sure?', "&Yes\n&No")
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1380 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1381
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1382 call feedkeys('n', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1383 let a = confirm('Are you sure?', "&Yes\n&No")
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1384 call assert_equal(2, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1385
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1386 " confirm() should return 0 when pressing CTRL-C.
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1387 call feedkeys("\<C-c>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1388 let a = confirm('Are you sure?', "&Yes\n&No")
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1389 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1390
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1391 " <Esc> requires another character to avoid it being seen as the start of an
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1392 " escape sequence. Zero should be harmless.
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1393 call feedkeys("\<Esc>0", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1394 let a = confirm('Are you sure?', "&Yes\n&No")
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1395 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1396
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1397 " Default choice is returned when pressing <CR>.
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1398 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1399 let a = confirm('Are you sure?', "&Yes\n&No")
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1400 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1401
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1402 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1403 let a = confirm('Are you sure?', "&Yes\n&No", 2)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1404 call assert_equal(2, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1405
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1406 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1407 let a = confirm('Are you sure?', "&Yes\n&No", 0)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1408 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1409
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1410 " Test with the {type} 4th argument
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1411 for type in ['Error', 'Question', 'Info', 'Warning', 'Generic']
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1412 call feedkeys('y', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1413 let a = confirm('Are you sure?', "&Yes\n&No\n", 1, type)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1414 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1415 endfor
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1416
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1417 call assert_fails('call confirm([])', 'E730:')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1418 call assert_fails('call confirm("Are you sure?", [])', 'E730:')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1419 call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", [])', 'E745:')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1420 call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", 0, [])', 'E730:')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1421 endfunc
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1422
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1423 func Test_platform_name()
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1424 " The system matches at most only one name.
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1425 let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1426 call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1427
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1428 " Is Unix?
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1429 call assert_equal(has('beos'), has('beos') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1430 call assert_equal(has('bsd'), has('bsd') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1431 call assert_equal(has('hpux'), has('hpux') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1432 call assert_equal(has('linux'), has('linux') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1433 call assert_equal(has('mac'), has('mac') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1434 call assert_equal(has('qnx'), has('qnx') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1435 call assert_equal(has('sun'), has('sun') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1436 call assert_equal(has('win32'), has('win32') && !has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1437 call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1438
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1439 if has('unix') && executable('uname')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1440 let uname = system('uname')
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1441 call assert_equal(uname =~? 'BeOS', has('beos'))
15742
916c13256877 patch 8.1.0878: test for has('bsd') fails on some BSD systems
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
1442 " GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined
916c13256877 patch 8.1.0878: test for has('bsd') fails on some BSD systems
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
1443 call assert_equal(uname =~? '\%(GNU/k\w\+\)\@<!BSD\|DragonFly', has('bsd'))
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1444 call assert_equal(uname =~? 'HP-UX', has('hpux'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1445 call assert_equal(uname =~? 'Linux', has('linux'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1446 call assert_equal(uname =~? 'Darwin', has('mac'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1447 call assert_equal(uname =~? 'QNX', has('qnx'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1448 call assert_equal(uname =~? 'SunOS', has('sun'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1449 call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1450 endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1451 endfunc
16231
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1452
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1453 func Test_readdir()
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1454 call mkdir('Xdir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1455 call writefile([], 'Xdir/foo.txt')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1456 call writefile([], 'Xdir/bar.txt')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1457 call mkdir('Xdir/dir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1458
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1459 " All results
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1460 let files = readdir('Xdir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1461 call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1462
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1463 " Only results containing "f"
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1464 let files = readdir('Xdir', { x -> stridx(x, 'f') !=- 1 })
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1465 call assert_equal(['foo.txt'], sort(files))
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1466
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1467 " Only .txt files
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1468 let files = readdir('Xdir', { x -> x =~ '.txt$' })
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1469 call assert_equal(['bar.txt', 'foo.txt'], sort(files))
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1470
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1471 " Only .txt files with string
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1472 let files = readdir('Xdir', 'v:val =~ ".txt$"')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1473 call assert_equal(['bar.txt', 'foo.txt'], sort(files))
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1474
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1475 " Limit to 1 result.
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1476 let l = []
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1477 let files = readdir('Xdir', {x -> len(add(l, x)) == 2 ? -1 : 1})
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1478 call assert_equal(1, len(files))
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1479
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1480 call delete('Xdir', 'rf')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1481 endfunc
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1482
16752
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1483 func Test_delete_rf()
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1484 call mkdir('Xdir')
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1485 call writefile([], 'Xdir/foo.txt')
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1486 call writefile([], 'Xdir/bar.txt')
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1487 call mkdir('Xdir/[a-1]') " issue #696
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1488 call writefile([], 'Xdir/[a-1]/foo.txt')
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1489 call writefile([], 'Xdir/[a-1]/bar.txt')
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1490 call assert_true(filereadable('Xdir/foo.txt'))
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1491 call assert_true(filereadable('Xdir/[a-1]/foo.txt'))
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1492
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1493 call assert_equal(0, delete('Xdir', 'rf'))
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1494 call assert_false(filereadable('Xdir/foo.txt'))
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1495 call assert_false(filereadable('Xdir/[a-1]/foo.txt'))
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1496 endfunc
e2d8d83e6721 patch 8.1.1378: delete() can not handle a file name that looks like a pattern
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
1497
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1498 func Test_call()
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1499 call assert_equal(3, call('len', [123]))
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1500 call assert_fails("call call('len', 123)", 'E714:')
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1501 call assert_equal(0, call('', []))
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1502
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1503 function Mylen() dict
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1504 return len(self.data)
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1505 endfunction
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1506 let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1507 call assert_fails("call call('Mylen', [], 0)", 'E715:')
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1508 endfunc
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1509
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1510 func Test_char2nr()
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1511 call assert_equal(12354, char2nr('あ', 1))
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1512 endfunc
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1513
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1514 func Test_eventhandler()
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1515 call assert_equal(0, eventhandler())
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1516 endfunc