annotate src/testdir/test_functions.vim @ 20629:7b8ac5e49451 v8.2.0868

patch 8.2.0868: trim() always trims both ends Commit: https://github.com/vim/vim/commit/2245ae18e3480057f98fc0e5d9f18091f32a5de0 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 31 22:20:36 2020 +0200 patch 8.2.0868: trim() always trims both ends Problem: trim() always trims both ends. Solution: Add an argument to only trim the beginning or end. (Yegappan Lakshmanan, closes #6126)
author Bram Moolenaar <Bram@vim.org>
date Sun, 31 May 2020 22:30:04 +0200
parents 89b0f161e6a6
children c2beb6baa42c
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
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17484
diff changeset
3 source check.vim
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
4 source term_util.vim
19400
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
5 source screendump.vim
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
7 " 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
8 func Test_00_bufexists()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
9 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
10 call assert_equal(1, bufexists(bufnr('%')))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
11 call assert_equal(0, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
12 new Xfoo
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
13 let bn = bufnr('%')
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
14 call assert_equal(1, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
15 call assert_equal(1, bufexists('Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
16 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
17 call assert_equal(1, bufexists(0))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
18 bw
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
19 call assert_equal(0, bufexists(bn))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
20 call assert_equal(0, bufexists('Xfoo'))
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
21 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
22
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
23 func Test_has()
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
24 call assert_equal(1, has('eval'))
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
25 call assert_equal(1, has('eval', 1))
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
26
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
27 if has('unix')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
28 call assert_equal(1, or(has('ttyin'), 1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
29 call assert_equal(0, and(has('ttyout'), 0))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
30 call assert_equal(1, has('multi_byte_encoding'))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
31 endif
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
32 call assert_equal(1, has('vcon', 1))
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
33 call assert_equal(1, has('mouse_gpm_enabled', 1))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
34
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
35 call assert_equal(0, has('nonexistent'))
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
36 call assert_equal(0, has('nonexistent', 1))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
37
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
38 " Will we ever have patch 9999?
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
39 let ver = 'patch-' .. v:version / 100 .. '.' .. v:version % 100 .. '.9999'
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
40 call assert_equal(0, has(ver))
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
41 endfunc
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
42
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
43 func Test_empty()
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(''))
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('a'))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
46
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
47 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
48 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
49 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
50 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
51
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
52 if has('float')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
53 call assert_equal(1, empty(0.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
54 call assert_equal(1, empty(-0.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
55 call assert_equal(0, empty(1.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
56 call assert_equal(0, empty(-1.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
57 call assert_equal(0, empty(1.0/0.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
58 call assert_equal(0, empty(0.0/0.0))
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
59 endif
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
60
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
61 call assert_equal(1, empty([]))
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, empty(['a']))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
63
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
64 call assert_equal(1, empty({}))
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, empty({'a':1}))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
66
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
67 call assert_equal(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
68 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
69 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
70 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
71
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
72 if has('channel')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
73 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
74 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
75 if has('job')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
76 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
77 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
78
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
79 call assert_equal(0, 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
80 call assert_equal(0, empty(function('Test_empty', [0])))
19548
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19536
diff changeset
81
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19536
diff changeset
82 call assert_fails("call empty(test_void())", 'E685:')
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19536
diff changeset
83 call assert_fails("call empty(test_unknown())", 'E685:')
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
84 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
85
19554
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
86 func Test_test_void()
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
87 call assert_fails('echo 1 == test_void()', 'E685:')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
88 if has('float')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
89 call assert_fails('echo 1.0 == test_void()', 'E685:')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
90 endif
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
91 call assert_fails('let x = json_encode(test_void())', 'E685:')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
92 call assert_fails('let x = copy(test_void())', 'E685:')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
93 call assert_fails('let x = copy([test_void()])', 'E685:')
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
94 endfunc
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
95
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
96 func Test_len()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
97 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
98 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
99
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
100 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
101 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
102
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
103 call assert_equal(0, len([]))
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
104 call assert_equal(0, len(test_null_list()))
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
105 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
106
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
107 call assert_equal(0, len({}))
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
108 call assert_equal(0, len(test_null_dict()))
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
109 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
110
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
111 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
112 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
113 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
114
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
115 func Test_max()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
116 call assert_equal(0, max([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
117 call assert_equal(2, max([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
118 call assert_equal(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
119 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
120
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
121 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
122 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
123
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
124 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
125 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
126 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
127
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
128 func Test_min()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
129 call assert_equal(0, min([]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
130 call assert_equal(2, min([2]))
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
131 call assert_equal(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
132 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
133
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
134 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
135 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
136
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
137 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
138 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
139 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
140
13980
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
141 func Test_strwidth()
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
142 for aw in ['single', 'double']
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
143 exe 'set ambiwidth=' . aw
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
144 call assert_equal(0, strwidth(''))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
145 call assert_equal(1, strwidth("\t"))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
146 call assert_equal(3, strwidth('Vim'))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
147 call assert_equal(4, strwidth(1234))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
148 call assert_equal(5, strwidth(-1234))
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
149
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
150 call assert_equal(2, strwidth('😉'))
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
151 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
152 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
153
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
154 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
155 call assert_fails('call strwidth([])', 'E730:')
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
156 call assert_fails('call strwidth({})', 'E731:')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
157 if has('float')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
158 call assert_fails('call strwidth(1.2)', 'E806:')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
159 endif
13980
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
160 endfor
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
161
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
162 set ambiwidth&
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
163 endfunc
a9e31b01366b patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents: 13513
diff changeset
164
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 func Test_str2nr()
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 call assert_equal(0, str2nr(''))
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 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
168 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
169
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 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
171 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
172 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
173
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 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
175 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
176 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
177
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 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
179 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
180
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
181 call assert_equal(5, str2nr('101', 2))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
182 call assert_equal(5, '0b101'->str2nr(2))
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
183 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
184 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
185 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
186 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
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_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
189 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
190 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
191 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
192
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
201 call assert_equal(1, str2nr("1'000'000", 10, 0))
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
202 call assert_equal(256, str2nr("1'0000'0000", 2, 1))
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
203 call assert_equal(262144, str2nr("1'000'000", 8, 1))
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
204 call assert_equal(1000000, str2nr("1'000'000", 10, 1))
18096
609b351cb58f patch 8.1.2043: not sufficient testing for quoted numbers
Bram Moolenaar <Bram@vim.org>
parents: 18080
diff changeset
205 call assert_equal(1000, str2nr("1'000''000", 10, 1))
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
206 call assert_equal(65536, str2nr("1'00'00", 16, 1))
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
207
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
208 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
209 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
210 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
211 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
212 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
213
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
214 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
215 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
216
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
217 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
218 call assert_fails('call str2nr({->2})', 'E729:')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
219 if has('float')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
220 call assert_fails('call str2nr(1.2)', 'E806:')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
221 endif
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
222 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
223 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
224
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
225 func Test_strftime()
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
226 CheckFunction strftime
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
227
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
228 " 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
229 " 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
230 " 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
231 "
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
232 " 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
233 " 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
234 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
235 "
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
236 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\)$', '%Y-%m-%d %H:%M:%S'->strftime())
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
237
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
238 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
239 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
240
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
241 " 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
242 " 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
243 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
244 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
245 endif
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
246
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
247 " 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
248 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
249 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
250
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
251 " 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
252 " 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
253 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
254 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
255 " 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
256 if has('unix')
ca4e6685e2f4 patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 17135
diff changeset
257 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
258 endif
17135
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
259
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
260 " 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
261 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
262 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
263 else
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
264 unlet $TZ
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
265 endif
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
266 endfunc
17135
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 16945
diff changeset
267
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
268 func Test_strptime()
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
269 CheckFunction strptime
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
270
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
271 if exists('$TZ')
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
272 let tz = $TZ
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
273 endif
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
274 let $TZ = 'UTC'
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
275
18821
a9cfb0db187d patch 8.1.2398: strptime() test fails on Japanese Mac
Bram Moolenaar <Bram@vim.org>
parents: 18669
diff changeset
276 call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23'))
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
277
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
278 call assert_fails('call strptime()', 'E119:')
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
279 call assert_fails('call strptime("xxx")', 'E119:')
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
280 call assert_equal(0, strptime("%Y", ''))
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
281 call assert_equal(0, strptime("%Y", "xxx"))
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
282
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
283 if exists('tz')
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
284 let $TZ = tz
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
285 else
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
286 unlet $TZ
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
287 endif
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
288 endfunc
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
289
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
290 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
291 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
292 return
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
293 endif
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
294
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
295 " Xlink1 -> Xlink2
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
296 " Xlink2 -> Xlink3
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
297 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
298 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
299 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
300 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
301 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
302 " 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
303 "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
304 "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
305 "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
306 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
307
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
308 " 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
309 " Xlink1 -> Xlink2
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
310 " Xlink2 -> Xlink3
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
311 " Xlink3 -> Xlink1
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 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
320
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
321 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
322 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
323 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
324
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
325 silent !ln -s -f Xlink2/ Xlink1
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
326 call assert_equal('Xlink2', 'Xlink1'->resolve())
14885
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
327 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
328 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
329
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
330 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
331 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
332 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
333 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
334 endfunc
5e47597de905 patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents: 14883
diff changeset
335
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
336 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
337 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
338 let ret = substitute(ret, '//', '/', 'g')
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
339 return ret->tolower()
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
340 endfunc
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
341
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
342 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
343 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
344 return
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
345 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
346
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
347 " 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
348 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
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
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
351 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
352 Set fs = CreateObject("Scripting.FileSystemObject")
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
353 Set ws = WScript.CreateObject("WScript.Shell")
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
354 Set shortcut = ws.CreateShortcut("Xlink.lnk")
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
355 shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile")
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
356 shortcut.Save
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
357 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17137
diff changeset
358 call writefile(lines, 'link.vbs')
15774
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
359 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
360 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
361 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
362 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
363
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
364 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
365 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
366 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
367 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
368 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
369
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
370 " 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
371 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
372 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
373 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
374
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
375 " 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
376 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
377 wq
16945
efd36a9052cc patch 8.1.1473: new resolve() implementation causes problem for plugins
Bram Moolenaar <Bram@vim.org>
parents: 16831
diff changeset
378 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
379 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
380 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
381 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
382 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
383 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
384 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
385 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
386 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
387
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
388 " 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
389 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
390 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
391 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
392 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
393
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
394 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
395
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
396 " 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
397 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
398 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
399 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
400 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
401 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
402 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
403
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
404 " 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
405 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
406 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
407 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
408 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
409
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
410 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
411
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
412 " 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
413 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
414 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
415 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
416 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
417 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
418 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
419
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
420 " 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
421 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
422 wq
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
423 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
424 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
425 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
426 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
427 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
428 bw!
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
429 else
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
430 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
431 endif
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
432 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
433
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
434 " 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447
f42aa3d90b12 patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
448 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
449 endfunc
c4efa095f323 patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents: 15754
diff changeset
450
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
451 func Test_simplify()
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
452 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
453 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
454 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
455 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
456 call assert_equal('/...', simplify('/...'))
19952
82ea10d554fb patch 8.2.0532: cannot use simplify() as a method
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
457 call assert_equal('./dir/file', './dir/file'->simplify())
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
458 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
459 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
460 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
461 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
462 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
463
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
464 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
465 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
466 call assert_fails('call simplify({})', 'E731:')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
467 if has('float')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
468 call assert_fails('call simplify(1.2)', 'E806:')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19241
diff changeset
469 endif
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 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
471
14487
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
472 func Test_pathshorten()
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
473 call assert_equal('', pathshorten(''))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
474 call assert_equal('foo', pathshorten('foo'))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
475 call assert_equal('/foo', '/foo'->pathshorten())
14487
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
476 call assert_equal('f/', pathshorten('foo/'))
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
477 call assert_equal('f/bar', pathshorten('foo/bar'))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
478 call assert_equal('f/b/foobar', 'foo/bar/foobar'->pathshorten())
14487
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
479 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
480 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
481 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
482 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
483 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
484 call assert_equal('~/f/bar', pathshorten('~/foo/bar'))
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
485 call assert_fails('call pathshorten([])', 'E730:')
14487
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
486 endfunc
336213a840d9 patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents: 14422
diff changeset
487
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
488 func Test_strpart()
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
489 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
490 call assert_equal('ab', strpart('abcdefg', -2, 4))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
491 call assert_equal('abcdefg', 'abcdefg'->strpart(-2))
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
492 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
493 call assert_equal('defg', strpart('abcdefg', 3))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
494 call assert_equal('', strpart('abcdefg', 10))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
495 call assert_fails("let s=strpart('abcdef', [])", 'E745:')
12869
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
496
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15008
diff changeset
497 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
498 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
499 endfunc
a89350ba2a9d patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
500
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
501 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
502 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
503
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
504 " 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
505 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
506 \ 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
507
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
508 " 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
509 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
510 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
511 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
512 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
513 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
514 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
515 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
516 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
517 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
518 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
519 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
520 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
521 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
522 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
523 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
524 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
525 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
526 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
527 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
528 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
529 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
530 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
531 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
532 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
533 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
534 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
535
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
536 " 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
537 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
538 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
539 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
540 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
541 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
542 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
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 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
554 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
555 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
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
564 " 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
565 " Ⱥ (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
566 " 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
567 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
568
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
569 " 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
570 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
571 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
572 call tolower("123\xC0\x80\xC0")
20313
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
573
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
574 " Test in latin1 encoding
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
575 let save_enc = &encoding
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
576 set encoding=latin1
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
577 call assert_equal("abc", tolower("ABC"))
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
578 let &encoding = save_enc
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
579 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
580
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
581 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
582 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
583
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
584 " 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
585 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
586 \ 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
587
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
588 " Test with a few lowercase diacritics.
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
589 call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", "aàáâãäåāăąǎǟǡả"->toupper())
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
590 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
591 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
592 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
593 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
594 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
595 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
596 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
597 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
598 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
599 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
600 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
601 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
602 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
603 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
604 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
605 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
606 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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 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
615
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
616 " 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
617 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
618 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
619 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
620 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
621 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
622 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
623 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
624 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
625 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
626 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
627 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
628 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
629 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
630 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643
10743
8779b4b2e958 patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
644 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
645
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
646 " 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
647 " invalid memory.
d5647746c267 patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
648 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
649 call toupper("123\xC0\x80\xC0")
20313
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
650
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
651 " Test in latin1 encoding
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
652 let save_enc = &encoding
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
653 set encoding=latin1
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
654 call assert_equal("ABC", toupper("abc"))
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
655 let &encoding = save_enc
10706
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
656 endfunc
056e32b99e93 patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
657
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
658 func Test_tr()
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
659 call assert_equal('foo', tr('bar', 'bar', 'foo'))
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
660 call assert_equal('zxy', 'cab'->tr('abc', 'xyz'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
661 call assert_fails("let s=tr([], 'abc', 'def')", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
662 call assert_fails("let s=tr('abc', [], 'def')", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
663 call assert_fails("let s=tr('abc', 'abc', [])", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
664 call assert_fails("let s=tr('abcd', 'abcd', 'def')", 'E475:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
665 set encoding=latin1
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
666 call assert_fails("let s=tr('abcd', 'abcd', 'def')", 'E475:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
667 call assert_equal('hEllO', tr('hello', 'eo', 'EO'))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
668 call assert_equal('hello', tr('hello', 'xy', 'ab'))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
669 set encoding=utf8
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
670 endfunc
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
671
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
672 " 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
673 let current_modes = ''
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
674 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
675 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
676 return ''
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
677 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
678
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
679 " Test for the mode() function
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
680 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
681 new
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
682 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
683
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
684 " 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
685 set complete=.
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
686
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
687 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
688
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
689 normal! 3G
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
690 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
691 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
692 " 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
693 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
694 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
695 " 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
696 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
697 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
698 " 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
699 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
700 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
701 " 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
702 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
703 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
704 " 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
705 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
706 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
707 " 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
708 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
709 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
710 " 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
711 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
712 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
713 " 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
714 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
715 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
716 " 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
717 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
718 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
719 " 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
720 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
721 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
722 " 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
723 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
724 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
725
10833
d66e5446cc48 patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
726 " 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
727 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
728 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
729 " 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
730 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
731 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
732 " 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
733 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
734 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
735 " 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
736 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
737 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
738 " 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
739 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
740 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
741 " 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
742 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
743 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
744 " 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
745 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
746 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
747 " 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
748 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
749 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
750 " 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
751 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
752 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
753 " 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
754 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
755 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
756 " 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
757 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
758 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
759
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
760 call assert_equal('n', 0->mode())
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
761 call assert_equal('n', 1->mode())
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
762
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
763 " 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
764 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
765 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
766
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
767 " 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
768 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
769 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
770
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14379
diff changeset
771 " 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
772 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
773 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
774
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
775 " 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
776
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
777 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
778 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
779 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
780 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
781 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
782 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
783 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
784 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
785 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
786 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
787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
788 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
789 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
790 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
791 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
792 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
793 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
794 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
795 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
796 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
797 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
798
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
799 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
800 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
801 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
802 call assert_equal('c-cv', g:current_modes)
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
803 call feedkeys("Qcall Save_mode()\<CR>vi\<CR>", 'xt')
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
804 call assert_equal('c-ce', 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
805 " 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
806
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
807 bwipe!
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
808 iunmap <F2>
11135
c4e4387bbd50 patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents: 11095
diff changeset
809 set complete&
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10743
diff changeset
810 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
811
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
812 " Test for append()
17871
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
813 func Test_append()
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
814 enew!
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
815 split
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
816 call append(0, ["foo"])
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
817 call append(1, [])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
818 call append(1, test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
819 call assert_equal(['foo', ''], getline(1, '$'))
17871
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
820 split
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
821 only
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
822 undo
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
823 undo
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
824
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
825 " Using $ instead of '$' must give an error
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
826 call assert_fails("call append($, 'foobar')", 'E116:')
17871
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
827 endfunc
521ce0d887e5 patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
828
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
829 " Test for setline()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
830 func Test_setline()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
831 new
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
832 call setline(0, ["foo"])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
833 call setline(0, [])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
834 call setline(0, test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
835 call setline(1, ["bar"])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
836 call setline(1, [])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
837 call setline(1, test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
838 call setline(2, [])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
839 call setline(2, test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
840 call setline(3, [])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
841 call setline(3, test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
842 call setline(2, ["baz"])
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
843 call assert_equal(['bar', 'baz'], getline(1, '$'))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
844 close!
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
845 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
846
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
847 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
848 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
849 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
850 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
851 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
852 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
853
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
854 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
855 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
856 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
857 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
858
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
859 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
860 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
861
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
862 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
863 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
864 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
865
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
866 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
867 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
868 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
869 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
870
11197
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 11191
diff changeset
871 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
872 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
873 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
874
10891
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
875 call assert_equal(0, getbufvar(bnr, '&autoindent'))
c9d057b7a0ab patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
876 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
877
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
878 " Set and get a buffer-local variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
879 call setbufvar(bnr, 'bufvar_test', ['one', 'two'])
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
880 call assert_equal(['one', 'two'], getbufvar(bnr, 'bufvar_test'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
881
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
882 " 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
883 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
884 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
885 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
886 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
887 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
888 close
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
889
19902
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
890 " Get the b: dict.
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
891 let b:testvar = 'one'
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
892 new
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
893 let b:testvar = 'two'
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
894 let thebuf = bufnr()
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
895 wincmd w
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
896 call assert_equal('two', getbufvar(thebuf, 'testvar'))
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
897 call assert_equal('two', getbufvar(thebuf, '').testvar)
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
898 bwipe!
481e8fa158b4 patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents: 19795
diff changeset
899
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10833
diff changeset
900 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
901 endfunc
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
902
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
903 func Test_last_buffer_nr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
904 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
905 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
906
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
907 func Test_stridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
908 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
909 call assert_equal(0, stridx('', ''))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
910 call assert_equal(0, 'hello'->stridx(''))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
911 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
912 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
913 call assert_equal(2, stridx('hello', 'l', 0))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
914 call assert_equal(2, 'hello'->stridx('l', 1))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
915 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
916 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
917 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
918 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
919 call assert_equal(-1, stridx('hello', 'hello world'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
920 call assert_fails("let n=stridx('hello', [])", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
921 call assert_fails("let n=stridx([], 'l')", 'E730:')
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
922 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
923
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
924 func Test_strridx()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
925 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
926 call assert_equal(0, strridx('', ''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
927 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
928 call assert_equal(-1, strridx('hello', 'L'))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
929 call assert_equal(3, 'hello'->strridx('l'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
930 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
931 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
932 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
933 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
934 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
935 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
936 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
937 call assert_equal(-1, strridx('hello', 'hello world'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
938 call assert_fails("let n=strridx('hello', [])", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
939 call assert_fails("let n=strridx([], 'l')", 'E730:')
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
940 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
941
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
942 func Test_match_func()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
943 call assert_equal(4, match('testing', 'ing'))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
944 call assert_equal(4, 'testing'->match('ing', 2))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
945 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
946 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
947 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
948 call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
949 call assert_fails("let x=match('vim', [])", 'E730:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
950 call assert_equal(3, match(['a', 'b', 'c', 'a'], 'a', 1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
951 call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
952 call assert_equal(4, match('testing', 'ing', -1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
953 call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
954 call assert_equal(-1, match(test_null_list(), 2))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
955 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
956
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
957 func Test_matchend()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
958 call assert_equal(7, matchend('testing', 'ing'))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
959 call assert_equal(7, 'testing'->matchend('ing', 2))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
960 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
961 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
962 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
963 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
964 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
965
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
966 func Test_matchlist()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
967 call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
968 call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], 'acd'->matchlist('\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
969 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
970 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
971
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
972 func Test_matchstr()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
973 call assert_equal('ing', matchstr('testing', 'ing'))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
974 call assert_equal('ing', 'testing'->matchstr('ing', 2))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
975 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
976 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
977 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
978 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
979 endfunc
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
980
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
981 func Test_matchstrpos()
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
982 call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
983 call assert_equal(['ing', 4, 7], 'testing'->matchstrpos('ing', 2))
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
984 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
985 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
986 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
987 call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
988 call assert_equal(['', -1, -1], matchstrpos(test_null_list(), '\a'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
989 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
990
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
991 func Test_nextnonblank_prevnonblank()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
992 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
993 insert
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
994 This
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
995
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
996
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
997 is
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
998
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
999 a
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1000 Test
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1001 .
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1002 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
1003 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
1004 call assert_equal(1, nextnonblank(1))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
1005 call assert_equal(4, 2->nextnonblank())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1006 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
1007 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
1008 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
1009 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
1010 call assert_equal(7, nextnonblank(7))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
1011 call assert_equal(0, 8->nextnonblank())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1012
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1013 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
1014 call assert_equal(0, prevnonblank(0))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
1015 call assert_equal(1, 1->prevnonblank())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1016 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
1017 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
1018 call assert_equal(4, prevnonblank(4))
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
1019 call assert_equal(4, 5->prevnonblank())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1020 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
1021 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
1022 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
1023 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1024 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1025
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1026 func Test_byte2line_line2byte()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1027 new
14579
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1028 set endofline
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1029 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
1030
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1031 set fileformat=unix
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1032 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
1033 \ 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
1034 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
1035 \ 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
1036
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1037 set fileformat=mac
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1038 call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1039 \ map(range(-1, 8), 'v:val->byte2line()'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1040 call assert_equal([-1, -1, 1, 3, 6, 8, -1],
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
1041 \ map(range(-1, 5), 'v:val->line2byte()'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1042
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1043 set fileformat=dos
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1044 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
1045 \ 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
1046 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
1047 \ 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
1048
14579
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1049 bw!
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1050 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
1051 normal a-
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1052 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
1053 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
1054 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
1055 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
1056 endfor
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1057
23d6d9e9ae3e patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents: 14487
diff changeset
1058 set endofline& fixendofline& fileformat&
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1059 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1060 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1061
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1062 " Test for byteidx() and byteidxcomp() functions
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1063 func Test_byteidx()
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1064 let a = '.é.' " one char of two bytes
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1065 call assert_equal(0, byteidx(a, 0))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1066 call assert_equal(0, byteidxcomp(a, 0))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1067 call assert_equal(1, byteidx(a, 1))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1068 call assert_equal(1, byteidxcomp(a, 1))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1069 call assert_equal(3, byteidx(a, 2))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1070 call assert_equal(3, byteidxcomp(a, 2))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1071 call assert_equal(4, byteidx(a, 3))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1072 call assert_equal(4, byteidxcomp(a, 3))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1073 call assert_equal(-1, byteidx(a, 4))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1074 call assert_equal(-1, byteidxcomp(a, 4))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1075
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1076 let b = '.é.' " normal e with composing char
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1077 call assert_equal(0, b->byteidx(0))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1078 call assert_equal(1, b->byteidx(1))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1079 call assert_equal(4, b->byteidx(2))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1080 call assert_equal(5, b->byteidx(3))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1081 call assert_equal(-1, b->byteidx(4))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1082 call assert_fails("call byteidx([], 0)", 'E730:')
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1083
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1084 call assert_equal(0, b->byteidxcomp(0))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1085 call assert_equal(1, b->byteidxcomp(1))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1086 call assert_equal(2, b->byteidxcomp(2))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1087 call assert_equal(4, b->byteidxcomp(3))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1088 call assert_equal(5, b->byteidxcomp(4))
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1089 call assert_equal(-1, b->byteidxcomp(5))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1090 call assert_fails("call byteidxcomp([], 0)", 'E730:')
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1091 endfunc
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1092
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1093 func Test_count()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1094 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
1095 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
1096 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
1097 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
1098 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
1099
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1100 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
1101 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
1102 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
1103 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
1104
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1105 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
1106 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
1107 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
1108 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
1109 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
1110
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1111 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
1112 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
1113 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
1114 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
1115
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1116 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
1117 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
1118 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
1119 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
1120 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
1121
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1122 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
1123 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
1124 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
1125 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
1126
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1127 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
1128 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
1129 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
1130 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
1131 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
1132
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1133 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
1134
5a07a3ff56c1 patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents: 11484
diff changeset
1135 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
1136 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
1137 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
1138 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
1139 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
1140 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
1141 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
1142
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1143 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
1144 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1145
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1146 func Test_changenr()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1147 new Xchangenr
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1148 call assert_equal(0, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1149 norm ifoo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1150 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1151 set undolevels=10
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1152 norm Sbar
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1153 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1154 undo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1155 call assert_equal(1, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1156 redo
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1157 call assert_equal(2, changenr())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1158 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1159 set undolevels&
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1160 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1161
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1162 func Test_filewritable()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1163 new Xfilewritable
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1164 write!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1165 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
1166
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1167 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
1168 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
1169
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1170 call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1171 call assert_equal(1, 'Xfilewritable'->filewritable())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1172
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1173 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
1174
20313
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1175 call mkdir('Xdir')
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1176 call assert_equal(2, filewritable('Xdir'))
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1177 call delete('Xdir', 'd')
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1178
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1179 call delete('Xfilewritable')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1180 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1181 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1182
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1183 func Test_Executable()
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1184 if has('win32')
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1185 call assert_equal(1, executable('notepad'))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1186 call assert_equal(1, 'notepad.exe'->executable())
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1187 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
1188 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
1189 call assert_equal(0, executable('win.ini'))
20593
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1190
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1191 " get "notepad" path and remove the leading drive and sep. (ex. 'C:\')
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1192 let notepadcmd = exepath('notepad.exe')
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1193 let driveroot = notepadcmd[:2]
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1194 let notepadcmd = notepadcmd[3:]
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1195 new
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1196 " check that the relative path works in /
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1197 execute 'lcd' driveroot
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1198 call assert_equal(1, executable(notepadcmd))
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1199 call assert_equal(driveroot .. notepadcmd, notepadcmd->exepath())
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1200 bwipe
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1201
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1202 " create "notepad.bat"
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1203 call mkdir('Xdir')
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1204 let notepadbat = fnamemodify('Xdir/notepad.bat', ':p')
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1205 call writefile([], notepadbat)
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1206 new
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1207 " check that the path and the pathext order is valid
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1208 lcd Xdir
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1209 let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1210 call assert_equal(notepadbat, exepath('notepad'))
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1211 let $PATHEXT = pathext
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1212 bwipe
89b0f161e6a6 patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
1213 eval 'Xdir'->delete('rf')
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1214 elseif has('unix')
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1215 call assert_equal(1, 'cat'->executable())
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
1216 call assert_equal(0, executable('nodogshere'))
17484
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1217
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1218 " get "cat" path and remove the leading /
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1219 let catcmd = exepath('cat')[1:]
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1220 new
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1221 " check that the relative path works in /
17484
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1222 lcd /
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1223 call assert_equal(1, executable(catcmd))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1224 call assert_equal('/' .. catcmd, catcmd->exepath())
17484
f1fd0b0b335c patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1225 bwipe
14883
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1226 endif
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1227 endfunc
1c2ba2b0227e patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents: 14669
diff changeset
1228
16180
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1229 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
1230 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
1231 return
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1232 endif
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1233
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1234 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
1235 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
1236 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
1237 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
1238 endfunc
1eaaa82ececf patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1239
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1240 func Test_hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1241 let hostname_vim = hostname()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1242 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1243 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
1244 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
1245 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1246 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1247
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1248 func Test_getpid()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1249 " 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
1250 call assert_equal(getpid(), getpid())
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1251 if has('unix')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1252 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
1253 endif
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1254 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1255
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1256 func Test_hlexists()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1257 call assert_equal(0, hlexists('does_not_exist'))
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1258 call assert_equal(0, 'Number'->hlexists())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1259 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
1260 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
1261 syntax on
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1262 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
1263 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
1264 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
1265 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
1266 syntax off
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1267 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1268
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
1269 " Test for the col() function
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1270 func Test_col()
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1271 new
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1272 call setline(1, 'abcdef')
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1273 norm gg4|mx6|mY2|
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1274 call assert_equal(2, col('.'))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1275 call assert_equal(7, col('$'))
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1276 call assert_equal(2, col('v'))
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1277 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
1278 call assert_equal(6, col("'Y"))
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
1279 call assert_equal(2, [1, 2]->col())
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1280 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
1281
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1282 call assert_equal(0, col(''))
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1283 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
1284 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
1285 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
1286 call assert_equal(0, col([1]))
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
1287 call assert_equal(0, col(test_null_list()))
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
1288 call assert_fails('let c = col({})', 'E731:')
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1289
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1290 " test for getting the visual start column
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1291 func T()
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1292 let g:Vcol = col('v')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1293 return ''
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1294 endfunc
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1295 let g:Vcol = 0
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1296 xmap <expr> <F2> T()
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1297 exe "normal gg3|ve\<F2>"
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1298 call assert_equal(3, g:Vcol)
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1299 xunmap <F2>
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1300 delfunc T
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
1301
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1302 " Test for the visual line start and end marks '< and '>
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1303 call setline(1, ['one', 'one two', 'one two three'])
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1304 "normal! ggVG
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1305 call feedkeys("ggVG\<Esc>", 'xt')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1306 call assert_equal(1, col("'<"))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1307 call assert_equal(14, col("'>"))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1308 " Delete the last line of the visually selected region
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1309 $d
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1310 call assert_notequal(14, col("'>"))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1311
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1312 " Test with 'virtualedit'
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1313 set virtualedit=all
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1314 call cursor(1, 10)
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1315 call assert_equal(4, col('.'))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1316 set virtualedit&
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1317
11095
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1318 bw!
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1319 endfunc
5763281d212a patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents: 11024
diff changeset
1320
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1321 " Test for input()
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1322 func Test_input_func()
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1323 " Test for prompt with multiple lines
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1324 redir => v
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1325 call feedkeys(":let c = input(\"A\\nB\\nC\\n? \")\<CR>B\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1326 redir END
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1327 call assert_equal("B", c)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1328 call assert_equal(['A', 'B', 'C'], split(v, "\n"))
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1329
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1330 " Test for default value
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1331 call feedkeys(":let c = input('color? ', 'red')\<CR>\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1332 call assert_equal('red', c)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1333
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1334 " Test for completion at the input prompt
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1335 func! Tcomplete(arglead, cmdline, pos)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1336 return "item1\nitem2\nitem3"
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1337 endfunc
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1338 call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1339 \ .. "\<C-A>\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1340 delfunc Tcomplete
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1341 call assert_equal('item1 item2 item3', c)
19536
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1342
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1343 call assert_fails("call input('F:', '', 'invalid')", 'E180:')
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1344 call assert_fails("call input('F:', '', [])", 'E730:')
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1345 endfunc
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1346
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1347 " Test for the inputdialog() function
bab20768e1fd patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
1348 func Test_inputdialog()
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1349 if has('gui_running')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1350 call assert_fails('let v=inputdialog([], "xx")', 'E730:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1351 call assert_fails('let v=inputdialog("Q", [])', 'E730:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1352 else
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1353 call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<CR>", 'xt')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1354 call assert_equal('xx', v)
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1355 call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1356 call assert_equal('yy', v)
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1357 endif
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1358 endfunc
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1359
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
1360 " Test for inputlist()
14379
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1361 func Test_inputlist()
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1362 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
1363 call assert_equal(1, c)
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1364 call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx')
14379
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1365 call assert_equal(2, c)
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1366 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
1367 call assert_equal(3, c)
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1368
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1369 " Use backspace to delete characters in the prompt
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1370 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<BS>3\<BS>2\<cr>", 'tx')
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1371 call assert_equal(2, c)
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1372
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1373 " Use mouse to make a selection
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1374 call test_setmouse(&lines - 3, 2)
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1375 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<LeftMouse>", 'tx')
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1376 call assert_equal(1, c)
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1377 " Mouse click outside of the list
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1378 call test_setmouse(&lines - 6, 2)
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1379 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<LeftMouse>", 'tx')
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1380 call assert_equal(-2, c)
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19902
diff changeset
1381
14379
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1382 call assert_fails('call inputlist("")', 'E686:')
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
1383 call assert_fails('call inputlist(test_null_list())', 'E686:')
14379
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1384 endfunc
0f1446193ded patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents: 14348
diff changeset
1385
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
1386 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
1387 if has('balloon_eval')
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
1388 " 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
1389 call balloon_show('hi!')
19207
f92ccb8ca489 patch 8.2.0162: balloon test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
1390 if !has('gui_running')
f92ccb8ca489 patch 8.2.0162: balloon test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
1391 call balloon_show(range(3))
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
1392 call balloon_show([])
19207
f92ccb8ca489 patch 8.2.0162: balloon test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
1393 endif
11024
973fa964cb91 patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents: 11020
diff changeset
1394 endif
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 10891
diff changeset
1395 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
1396
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1397 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
1398 " 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
1399 " 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
1400 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
1401 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
1402 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
1403 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
1404 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
1405
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1406 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
1407 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
1408 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
1409 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
1410 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
1411 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
1412 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
1413
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1414 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
1415 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
1416 let dummy_buf = bufnr('dummy_buf2', v:true)
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17982
diff changeset
1417 eval 'nofile'->setbufvar(dummy_buf, '&buftype')
11191
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1418 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
1419 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
1420
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1421 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1422 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
1423 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1424 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
1425 bwipe!
445fd6be2009 patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents: 11135
diff changeset
1426 endfunc
11325
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1427
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1428 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
1429 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
1430 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
1431 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
1432 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
1433 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1434
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1435 function! Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1436 5,6normal! .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1437 endfunction
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1438
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1439 new
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1440 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
1441 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
1442 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
1443 3,4normal .
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1444 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
1445 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
1446 call Apply()
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1447 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
1448 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
1449 bwipe!
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1450
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1451 nunmap g.
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1452 delfunc Operator
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1453 delfunc Apply
77f3b7316d8b patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
1454 endfunc
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1455
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1456 func Test_shellescape()
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1457 let save_shell = &shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1458 set shell=bash
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1459 call assert_equal("'text'", shellescape('text'))
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
1460 call assert_equal("'te\"xt'", 'te"xt'->shellescape())
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1461 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
1462
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1463 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
1464 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
1465 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
1466 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
1467 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
1468 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
1469
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1470 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
1471 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
1472 set shell=tcsh
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1473 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
1474 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
1475 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
1476 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
1477
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1478 let &shell = save_shell
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11325
diff changeset
1479 endfunc
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1480
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1481 func Test_trim()
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1482 call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B"))
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
1483 call assert_equal("Testing", " \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"->trim())
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1484 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
1485 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
1486 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
1487 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
1488 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
1489 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
1490 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
1491 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
1492 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
1493 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
1494 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
1495 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
1496 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
1497 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
1498 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
1499
20629
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1500 call assert_equal("vim", trim(" vim ", " ", 0))
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1501 call assert_equal("vim ", trim(" vim ", " ", 1))
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1502 call assert_equal(" vim", trim(" vim ", " ", 2))
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1503 call assert_fails('eval trim(" vim ", " ", [])', 'E745:')
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1504 call assert_fails('eval trim(" vim ", " ", -1)', 'E475:')
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1505 call assert_fails('eval trim(" vim ", " ", 3)', 'E475:')
7b8ac5e49451 patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents: 20593
diff changeset
1506
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17952
diff changeset
1507 let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '')
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1508 call assert_equal("x", trim(chars . "x" . chars))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1509
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1510 call assert_fails('let c=trim([])', 'E730:')
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13092
diff changeset
1511 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
1512
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1513 " 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
1514 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
1515 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
1516 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
1517 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
1518 return ''
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1519 endfunc
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1520
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1521 new
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1522 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
1523 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
1524 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
1525 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
1526 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
1527 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
1528 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
1529 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
1530 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
1531 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
1532
15973
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1533 " :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
1534 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
1535 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
1536 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
1537 normal! ia
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1538 endfunc
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1539 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
1540 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
1541 delfunc TestFunc
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15774
diff changeset
1542
15979
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1543 " 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
1544 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
1545 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
1546 let g:typed = ''
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1547 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
1548 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
1549 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
1550 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
1551 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
1552 endfunc
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1553 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
1554 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
1555 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
1556 delfunc TestFunc
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1557 unmap W
72987a858c96 patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
1558 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
1559 unlet g:regs
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1560
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1561 " 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
1562 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
1563 let @q = "W"
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1564 let g:typed = ''
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1565 let g:regs = []
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1566 func TestFunc() abort
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1567 let g:regs += [reg_executing()]
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1568 let g:typed = '?'->input()
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1569 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
1570 endfunc
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1571 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
1572 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
1573 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
1574 delfunc TestFunc
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1575 unmap W
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1576 unlet g:typed
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
1577 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
1578
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1579 bwipe!
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13980
diff changeset
1580 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
1581 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
1582 endfunc
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1583
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1584 func Test_inputsecret()
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1585 map W :call TestFunc()<CR>
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1586 let @q = "W"
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1587 let g:typed1 = ''
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1588 let g:typed2 = ''
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1589 let g:regs = []
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1590 func TestFunc() abort
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1591 let g:typed1 = '?'->inputsecret()
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1592 let g:typed2 = inputsecret('password: ')
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1593 endfunc
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1594 call feedkeys("@qsomething\<CR>else\<CR>", 'xt')
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1595 call assert_equal("something", g:typed1)
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1596 call assert_equal("else", g:typed2)
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1597 delfunc TestFunc
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1598 unmap W
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1599 unlet g:typed1
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1600 unlet g:typed2
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1601 endfunc
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17871
diff changeset
1602
17952
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1603 func Test_getchar()
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1604 call feedkeys('a', '')
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1605 call assert_equal(char2nr('a'), getchar())
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1606
18623
3089b422b9dc patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents: 18209
diff changeset
1607 call setline(1, 'xxxx')
17952
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1608 call test_setmouse(1, 3)
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1609 let v:mouse_win = 9
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1610 let v:mouse_winid = 9
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1611 let v:mouse_lnum = 9
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1612 let v:mouse_col = 9
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1613 call feedkeys("\<S-LeftMouse>", '')
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1614 call assert_equal("\<S-LeftMouse>", getchar())
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1615 call assert_equal(1, v:mouse_win)
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1616 call assert_equal(win_getid(1), v:mouse_winid)
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1617 call assert_equal(1, v:mouse_lnum)
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1618 call assert_equal(3, v:mouse_col)
18623
3089b422b9dc patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents: 18209
diff changeset
1619 enew!
17952
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1620 endfunc
4754339d9aee patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents: 17944
diff changeset
1621
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1622 func Test_libcall_libcallnr()
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1623 if !has('libcall')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1624 return
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1625 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1626
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1627 if has('win32')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1628 let libc = 'msvcrt.dll'
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1629 elseif has('mac')
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1630 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
1631 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
1632 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
1633 endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1634 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
1635 " 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
1636 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
1637 " 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
1638 " 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
1639 " 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
1640 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
1641 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
1642 " 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
1643 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
1644 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
1645 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
1646 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
1647 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
1648 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
1649 else
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1650 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
1651 endif
14669
63d5ae57a663 patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents: 14579
diff changeset
1652 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
1653 " 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
1654 return
14669
63d5ae57a663 patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents: 14579
diff changeset
1655 endif
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1656 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1657
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1658 if has('win32')
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
1659 call assert_equal($USERPROFILE, 'USERPROFILE'->libcall(libc, 'getenv'))
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1660 else
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
1661 call assert_equal($HOME, 'HOME'->libcall(libc, 'getenv'))
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1662 endif
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1663
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1664 " 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
1665 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
1666
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1667 " Test libcallnr() with string and integer argument.
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
1668 call assert_equal(4, 'abcd'->libcallnr(libc, 'strlen'))
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
1669 call assert_equal(char2nr('A'), char2nr('a')->libcallnr(libc, 'toupper'))
14137
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1670
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1671 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
1672 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
1673
0d534adbcc2f patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
1674 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
1675 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
1676 endfunc
14348
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1677
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1678 sandbox function Fsandbox()
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1679 normal ix
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1680 endfunc
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1681
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1682 func Test_func_sandbox()
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1683 sandbox let F = {-> 'hello'}
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1684 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
1685
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1686 sandbox let F = {-> "normal ix\<Esc>"->execute()}
14348
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1687 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
1688 unlet F
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1689
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1690 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
1691 delfunc Fsandbox
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1692
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1693 " From a sandbox try to set a predefined variable (which cannot be modified
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1694 " from a sandbox)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1695 call assert_fails('sandbox let v:lnum = 10', 'E794:')
14348
e73c0a0e7e87 patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents: 14137
diff changeset
1696 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
1697
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1698 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
1699 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
1700 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
1701 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
1702
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1703 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
1704 " 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
1705 " 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
1706 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
1707 new
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17982
diff changeset
1708 eval 10->range()->setline(1)
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
1709 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
1710 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
1711
32787e326de2 patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents: 14895
diff changeset
1712 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
1713 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
1714 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
1715 endfunc
15008
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1716
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1717 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
1718 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
1719 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
1720 source Xfuncexists
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1721 call assert_equal(1, '*ExistingFunction'->exists())
15008
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1722 " 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
1723 source Xfuncexists
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1724 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
1725
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1726 " 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
1727 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
1728 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
1729
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1730 delfunc ExistingFunction
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1731 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
1732 call writefile([
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1733 \ '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
1734 \ '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
1735 \ ], 'Xfuncexists')
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1736 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
1737 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
1738
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1739 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
1740 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
1741 delfunc ExistingFunction
67e3103d6e18 patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents: 15000
diff changeset
1742 endfunc
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1743
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1744 " Test confirm({msg} [, {choices} [, {default} [, {type}]]])
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1745 func Test_confirm()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17484
diff changeset
1746 CheckUnix
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17484
diff changeset
1747 CheckNotGui
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1748
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1749 call feedkeys('o', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1750 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
1751 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1752
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1753 call feedkeys('y', 'L')
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
1754 let a = 'Are you sure?'->confirm("&Yes\n&No")
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1755 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1756
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1757 call feedkeys('n', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1758 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
1759 call assert_equal(2, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1760
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1761 " confirm() should return 0 when pressing CTRL-C.
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
1762 call feedkeys("\<C-C>", 'L')
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1763 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
1764 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1765
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1766 " <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
1767 " escape sequence. Zero should be harmless.
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1768 eval "\<Esc>0"->feedkeys('L')
15649
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1769 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
1770 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1771
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1772 " 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
1773 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1774 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
1775 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1776
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1777 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1778 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
1779 call assert_equal(2, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1780
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1781 call feedkeys("\<CR>", 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1782 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
1783 call assert_equal(0, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1784
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1785 " Test with the {type} 4th argument
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1786 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
1787 call feedkeys('y', 'L')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1788 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
1789 call assert_equal(1, a)
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1790 endfor
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1791
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1792 call assert_fails('call confirm([])', 'E730:')
e649df212461 patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
1793 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
1794 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
1795 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
1796 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
1797
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1798 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
1799 " The system matches at most only one name.
20591
4411c2b96af9 patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents: 20540
diff changeset
1800 let names = ['amiga', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1801 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
1802
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1803 " 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
1804 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
1805 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
1806 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
1807 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
1808 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
1809 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
1810 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
1811 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
1812
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1813 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
1814 let uname = system('uname')
15742
916c13256877 patch 8.1.0878: test for has('bsd') fails on some BSD systems
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
1815 " 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
1816 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
1817 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
1818 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
1819 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
1820 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
1821 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
1822 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
1823 endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15649
diff changeset
1824 endfunc
16231
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1825
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1826 func Test_readdir()
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1827 call mkdir('Xdir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1828 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
1829 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
1830 call mkdir('Xdir/dir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1831
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1832 " All results
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1833 let files = readdir('Xdir')
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1834 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
1835
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1836 " Only results containing "f"
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17976
diff changeset
1837 let files = 'Xdir'->readdir({ x -> stridx(x, 'f') !=- 1 })
16231
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1838 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
1839
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1840 " Only .txt files
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1841 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
1842 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
1843
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1844 " 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
1845 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
1846 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
1847
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1848 " Limit to 1 result.
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1849 let l = []
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1850 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
1851 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
1852
17944
745c02392844 patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
1853 " Nested readdir() must not crash
745c02392844 patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
1854 let files = readdir('Xdir', 'readdir("Xdir", "1") != []')
745c02392844 patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
1855 call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
745c02392844 patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
1856
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
1857 eval 'Xdir'->delete('rf')
16231
0761a4c111a7 patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents: 16180
diff changeset
1858 endfunc
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1859
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
1860 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
1861 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
1862 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
1863 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
1864 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
1865 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
1866 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
1867 call assert_true(filereadable('Xdir/foo.txt'))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
1868 call assert_true('Xdir/[a-1]/foo.txt'->filereadable())
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
1869
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
1870 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
1871 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
1872 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
1873 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
1874
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1875 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
1876 call assert_equal(3, call('len', [123]))
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1877 call assert_equal(3, 'len'->call([123]))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1878 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
1879 call assert_equal(0, call('', []))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
1880 call assert_equal(0, call('len', test_null_list()))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1881
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1882 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
1883 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
1884 endfunction
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1885 let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
1886 eval mydict.len->call([], mydict)->assert_equal(4)
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1887 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
1888 endfunc
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1889
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1890 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
1891 call assert_equal(12354, char2nr('あ', 1))
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
1892 call assert_equal(120, 'x'->char2nr())
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1893 set encoding=latin1
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1894 call assert_equal(120, 'x'->char2nr())
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1895 set encoding=utf-8
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1896 endfunc
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1897
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
1898 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
1899 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
1900 endfunc
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1901
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1902 func Test_bufadd_bufload()
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1903 call assert_equal(0, bufexists('someName'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1904 let buf = bufadd('someName')
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1905 call assert_notequal(0, buf)
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1906 call assert_equal(1, bufexists('someName'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1907 call assert_equal(0, getbufvar(buf, '&buflisted'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1908 call assert_equal(0, bufloaded(buf))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1909 call bufload(buf)
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1910 call assert_equal(1, bufloaded(buf))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1911 call assert_equal([''], getbufline(buf, 1, '$'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1912
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1913 let curbuf = bufnr('')
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
1914 eval ['some', 'text']->writefile('XotherName')
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
1915 let buf = 'XotherName'->bufadd()
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1916 call assert_notequal(0, buf)
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
1917 eval 'XotherName'->bufexists()->assert_equal(1)
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1918 call assert_equal(0, getbufvar(buf, '&buflisted'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1919 call assert_equal(0, bufloaded(buf))
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
1920 eval buf->bufload()
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1921 call assert_equal(1, bufloaded(buf))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1922 call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1923 call assert_equal(curbuf, bufnr(''))
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1924
17223
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1925 let buf1 = bufadd('')
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1926 let buf2 = bufadd('')
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1927 call assert_notequal(0, buf1)
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1928 call assert_notequal(0, buf2)
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1929 call assert_notequal(buf1, buf2)
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1930 call assert_equal(1, bufexists(buf1))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1931 call assert_equal(1, bufexists(buf2))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1932 call assert_equal(0, bufloaded(buf1))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1933 exe 'bwipe ' .. buf1
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1934 call assert_equal(0, bufexists(buf1))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1935 call assert_equal(1, bufexists(buf2))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1936 exe 'bwipe ' .. buf2
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1937 call assert_equal(0, bufexists(buf2))
07bbe73b8e74 patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents: 17221
diff changeset
1938
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1939 bwipe someName
17278
b6de6181e5ab patch 8.1.1638: running tests leaves some files behind
Bram Moolenaar <Bram@vim.org>
parents: 17223
diff changeset
1940 bwipe XotherName
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1941 call assert_equal(0, bufexists('someName'))
17278
b6de6181e5ab patch 8.1.1638: running tests leaves some files behind
Bram Moolenaar <Bram@vim.org>
parents: 17223
diff changeset
1942 call delete('XotherName')
17221
a8fc7d97b54d patch 8.1.1610: there is no way to add or load a buffer without side effects
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1943 endfunc
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1944
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1945 func Test_state()
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1946 CheckRunVimInTerminal
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1947
19795
1c7f92a1100e patch 8.2.0454: some tests fail when the system is slow
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
1948 let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
1c7f92a1100e patch 8.2.0454: some tests fail when the system is slow
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
1949
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1950 let lines =<< trim END
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1951 call setline(1, ['one', 'two', 'three'])
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1952 map ;; gg
18209
9a7bbad64376 patch 8.1.2099: state() test fails on some Mac systems
Bram Moolenaar <Bram@vim.org>
parents: 18143
diff changeset
1953 set complete=.
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1954 func RunTimer()
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1955 call timer_start(10, {id -> execute('let g:state = state()') .. execute('let g:mode = mode()')})
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1956 endfunc
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1957 au Filetype foobar let g:state = state()|let g:mode = mode()
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1958 END
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1959 call writefile(lines, 'XState')
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1960 let buf = RunVimInTerminal('-S XState', #{rows: 6})
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1961
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1962 " Using a ":" command Vim is busy, thus "S" is returned
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1963 call term_sendkeys(buf, ":echo 'state: ' .. state() .. '; mode: ' .. mode()\<CR>")
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1964 call WaitForAssert({-> assert_match('state: S; mode: n', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1965 call term_sendkeys(buf, ":\<CR>")
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1966
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1967 " Using a timer callback
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1968 call term_sendkeys(buf, ":call RunTimer()\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
1969 call TermWait(buf, 25)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1970 call term_sendkeys(buf, getstate)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1971 call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1972
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1973 " Halfway a mapping
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1974 call term_sendkeys(buf, ":call RunTimer()\<CR>;")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
1975 call TermWait(buf, 25)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1976 call term_sendkeys(buf, ";")
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1977 call term_sendkeys(buf, getstate)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1978 call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1979
18209
9a7bbad64376 patch 8.1.2099: state() test fails on some Mac systems
Bram Moolenaar <Bram@vim.org>
parents: 18143
diff changeset
1980 " Insert mode completion (bit slower on Mac)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1981 call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
1982 call TermWait(buf, 25)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1983 call term_sendkeys(buf, "\<Esc>")
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1984 call term_sendkeys(buf, getstate)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1985 call WaitForAssert({-> assert_match('state: aSc; mode: i', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1986
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1987 " Autocommand executing
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1988 call term_sendkeys(buf, ":set filetype=foobar\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
1989 call TermWait(buf, 25)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1990 call term_sendkeys(buf, getstate)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1991 call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1992
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1993 " Todo: "w" - waiting for ch_evalexpr()
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1994
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1995 " messages scrolled
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1996 call term_sendkeys(buf, ":call RunTimer()\<CR>:echo \"one\\ntwo\\nthree\"\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
1997 call TermWait(buf, 25)
18143
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1998 call term_sendkeys(buf, "\<CR>")
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
1999 call term_sendkeys(buf, getstate)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
2000 call WaitForAssert({-> assert_match('state: Scs; mode: r', term_getline(buf, 6))}, 1000)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
2001
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
2002 call StopVimInTerminal(buf)
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
2003 call delete('XState')
2416e1a887ca patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents: 18096
diff changeset
2004 endfunc
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2005
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2006 func Test_range()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2007 " destructuring
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2008 let [x, y] = range(2)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2009 call assert_equal([0, 1], [x, y])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2010
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2011 " index
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2012 call assert_equal(4, range(1, 10)[3])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2013
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2014 " add()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2015 call assert_equal([0, 1, 2, 3], add(range(3), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2016 call assert_equal([0, 1, 2, [0, 1, 2]], add([0, 1, 2], range(3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2017 call assert_equal([0, 1, 2, [0, 1, 2]], add(range(3), range(3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2018
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2019 " append()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2020 new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2021 call append('.', range(5))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2022 call assert_equal(['', '0', '1', '2', '3', '4'], getline(1, '$'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2023 bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2024
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2025 " appendbufline()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2026 new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2027 call appendbufline(bufnr(''), '.', range(5))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2028 call assert_equal(['0', '1', '2', '3', '4', ''], getline(1, '$'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2029 bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2030
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2031 " call()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2032 func TwoArgs(a, b)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2033 return [a:a, a:b]
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2034 endfunc
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2035 call assert_equal([0, 1], call('TwoArgs', range(2)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2036
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2037 " col()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2038 new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2039 call setline(1, ['foo', 'bar'])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2040 call assert_equal(2, col(range(1, 2)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2041 bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2042
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2043 " complete()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2044 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>"
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2045 " complete_info()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2046 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>"
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2047
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2048 " copy()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2049 call assert_equal([1, 2, 3], copy(range(1, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2050
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2051 " count()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2052 call assert_equal(0, count(range(0), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2053 call assert_equal(0, count(range(2), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2054 call assert_equal(1, count(range(5), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2055
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2056 " cursor()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2057 new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2058 call setline(1, ['aaa', 'bbb', 'ccc'])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2059 call cursor(range(1, 2))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2060 call assert_equal([2, 1], [col('.'), line('.')])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2061 bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2062
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2063 " deepcopy()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2064 call assert_equal([1, 2, 3], deepcopy(range(1, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2065
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2066 " empty()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2067 call assert_true(empty(range(0)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2068 call assert_false(empty(range(2)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2069
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2070 " execute()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2071 new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2072 call setline(1, ['aaa', 'bbb', 'ccc'])
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2073 call execute(range(3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2074 call assert_equal(2, line('.'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2075 bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2076
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2077 " extend()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2078 call assert_equal([1, 2, 3, 4], extend([1], range(2, 4)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2079 call assert_equal([1, 2, 3, 4], extend(range(1, 1), range(2, 4)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2080 call assert_equal([1, 2, 3, 4], extend(range(1, 1), [2, 3, 4]))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2081
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2082 " filter()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2083 call assert_equal([1, 3], filter(range(5), 'v:val % 2'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2084
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2085 " funcref()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2086 call assert_equal([0, 1], funcref('TwoArgs', range(2))())
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2087
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2088 " function()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2089 call assert_equal([0, 1], function('TwoArgs', range(2))())
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2090
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2091 " garbagecollect()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2092 let thelist = [1, range(2), 3]
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2093 let otherlist = range(3)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2094 call test_garbagecollect_now()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2095
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2096 " get()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2097 call assert_equal(4, get(range(1, 10), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2098 call assert_equal(-1, get(range(1, 10), 42, -1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2099
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2100 " index()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2101 call assert_equal(1, index(range(1, 5), 2))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2102 call assert_fails("echo index([1, 2], 1, [])", 'E745:')
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2103
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2104 " inputlist()
19209
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2105 call feedkeys(":let result = inputlist(range(10))\<CR>1\<CR>", 'x')
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2106 call assert_equal(1, result)
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2107 call feedkeys(":let result = inputlist(range(3, 10))\<CR>1\<CR>", 'x')
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2108 call assert_equal(1, result)
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2109
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2110 " insert()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2111 call assert_equal([42, 1, 2, 3, 4, 5], insert(range(1, 5), 42))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2112 call assert_equal([42, 1, 2, 3, 4, 5], insert(range(1, 5), 42, 0))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2113 call assert_equal([1, 42, 2, 3, 4, 5], insert(range(1, 5), 42, 1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2114 call assert_equal([1, 2, 3, 4, 42, 5], insert(range(1, 5), 42, 4))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2115 call assert_equal([1, 2, 3, 4, 42, 5], insert(range(1, 5), 42, -1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2116 call assert_equal([1, 2, 3, 4, 5, 42], insert(range(1, 5), 42, 5))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2117
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2118 " join()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2119 call assert_equal('0 1 2 3 4', join(range(5)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2120
19209
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2121 " json_encode()
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2122 call assert_equal('[0,1,2,3]', json_encode(range(4)))
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19207
diff changeset
2123
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2124 " len()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2125 call assert_equal(0, len(range(0)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2126 call assert_equal(2, len(range(2)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2127 call assert_equal(5, len(range(0, 12, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2128 call assert_equal(4, len(range(3, 0, -1)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2129
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2130 " list2str()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2131 call assert_equal('ABC', list2str(range(65, 67)))
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2132 call assert_fails('let s = list2str(5)', 'E474:')
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2133
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2134 " lock()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2135 let thelist = range(5)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2136 lockvar thelist
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2137
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2138 " map()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2139 call assert_equal([0, 2, 4, 6, 8], map(range(5), 'v:val * 2'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2140
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2141 " match()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2142 call assert_equal(3, match(range(5), 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2143
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2144 " matchaddpos()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2145 highlight MyGreenGroup ctermbg=green guibg=green
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2146 call matchaddpos('MyGreenGroup', range(line('.'), line('.')))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2147
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2148 " matchend()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2149 call assert_equal(4, matchend(range(5), '4'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2150 call assert_equal(3, matchend(range(1, 5), '4'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2151 call assert_equal(-1, matchend(range(1, 5), '42'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2152
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2153 " matchstrpos()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2154 call assert_equal(['4', 4, 0, 1], matchstrpos(range(5), '4'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2155 call assert_equal(['4', 3, 0, 1], matchstrpos(range(1, 5), '4'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2156 call assert_equal(['', -1, -1, -1], matchstrpos(range(1, 5), '42'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2157
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2158 " max() reverse()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2159 call assert_equal(0, max(range(0)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2160 call assert_equal(0, max(range(10, 9)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2161 call assert_equal(9, max(range(10)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2162 call assert_equal(18, max(range(0, 20, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2163 call assert_equal(20, max(range(20, 0, -3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2164 call assert_equal(99999, max(range(100000)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2165 call assert_equal(99999, max(range(99999, 0, -1)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2166 call assert_equal(99999, max(reverse(range(100000))))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2167 call assert_equal(99999, max(reverse(range(99999, 0, -1))))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2168
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2169 " min() reverse()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2170 call assert_equal(0, min(range(0)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2171 call assert_equal(0, min(range(10, 9)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2172 call assert_equal(5, min(range(5, 10)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2173 call assert_equal(5, min(range(5, 10, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2174 call assert_equal(2, min(range(20, 0, -3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2175 call assert_equal(0, min(range(100000)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2176 call assert_equal(0, min(range(99999, 0, -1)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2177 call assert_equal(0, min(reverse(range(100000))))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2178 call assert_equal(0, min(reverse(range(99999, 0, -1))))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2179
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2180 " remove()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2181 call assert_equal(1, remove(range(1, 10), 0))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2182 call assert_equal(2, remove(range(1, 10), 1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2183 call assert_equal(9, remove(range(1, 10), 8))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2184 call assert_equal(10, remove(range(1, 10), 9))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2185 call assert_equal(10, remove(range(1, 10), -1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2186 call assert_equal([3, 4, 5], remove(range(1, 10), 2, 4))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2187
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2188 " repeat()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2189 call assert_equal([0, 1, 2, 0, 1, 2], repeat(range(3), 2))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2190 call assert_equal([0, 1, 2], repeat(range(3), 1))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2191 call assert_equal([], repeat(range(3), 0))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2192 call assert_equal([], repeat(range(5, 4), 2))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2193 call assert_equal([], repeat(range(5, 4), 0))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2194
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2195 " reverse()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2196 call assert_equal([2, 1, 0], reverse(range(3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2197 call assert_equal([0, 1, 2, 3], reverse(range(3, 0, -1)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2198 call assert_equal([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], reverse(range(10)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2199 call assert_equal([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], reverse(range(10, 20)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2200 call assert_equal([16, 13, 10], reverse(range(10, 18, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2201 call assert_equal([19, 16, 13, 10], reverse(range(10, 19, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2202 call assert_equal([19, 16, 13, 10], reverse(range(10, 20, 3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2203 call assert_equal([11, 14, 17, 20], reverse(range(20, 10, -3)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2204 call assert_equal([], reverse(range(0)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2205
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2206 " TODO: setpos()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2207 " new
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2208 " call setline(1, repeat([''], bufnr('')))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2209 " call setline(bufnr('') + 1, repeat('x', bufnr('') * 2 + 6))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2210 " call setpos('x', range(bufnr(''), bufnr('') + 3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2211 " bwipe!
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2212
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2213 " setreg()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2214 call setreg('a', range(3))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2215 call assert_equal("0\n1\n2\n", getreg('a'))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2216
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2217 " settagstack()
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2218 call settagstack(1, #{items : range(4)})
19306
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2219
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2220 " sign_define()
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2221 call assert_fails("call sign_define(range(5))", "E715:")
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2222 call assert_fails("call sign_placelist(range(5))", "E715:")
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2223
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2224 " sign_undefine()
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2225 call assert_fails("call sign_undefine(range(5))", "E908:")
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2226
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2227 " sign_unplacelist()
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2228 call assert_fails("call sign_unplacelist(range(5))", "E715:")
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2229
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2230 " sort()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2231 call assert_equal([0, 1, 2, 3, 4, 5], sort(range(5, 0, -1)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2232
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2233 " string()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2234 call assert_equal('[0, 1, 2, 3, 4]', string(range(5)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2235
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2236 " taglist() with 'tagfunc'
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2237 func TagFunc(pattern, flags, info)
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2238 return range(10)
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2239 endfunc
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2240 set tagfunc=TagFunc
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2241 call assert_fails("call taglist('asdf')", 'E987:')
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2242 set tagfunc=
19306
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2243
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2244 " term_start()
19255
04e1a025ef00 patch 8.2.0186: a couple of tests may fail when features are missing
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
2245 if has('terminal') && has('termguicolors')
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2246 call assert_fails('call term_start(range(3, 4))', 'E474:')
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2247 let g:terminal_ansi_colors = range(16)
19306
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2248 if has('win32')
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2249 let cmd = "cmd /c dir"
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2250 else
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2251 let cmd = "ls"
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2252 endif
e4a155edc9cb patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents: 19255
diff changeset
2253 call assert_fails('call term_start("' .. cmd .. '", #{term_finish: "close"})', 'E475:')
19241
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2254 unlet g:terminal_ansi_colors
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2255 endif
c53dbbf3229b patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents: 19209
diff changeset
2256
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2257 " type()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2258 call assert_equal(v:t_list, type(range(5)))
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2259
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2260 " uniq()
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2261 call assert_equal([0, 1, 2, 3, 4], uniq(range(5)))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2262
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2263 " errors
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2264 call assert_fails('let x=range(2, 8, 0)', 'E726:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2265 call assert_fails('let x=range(3, 1)', 'E727:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2266 call assert_fails('let x=range(1, 3, -2)', 'E727:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
2267 call assert_fails('let x=range([])', 'E745:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
2268 call assert_fails('let x=range(1, [])', 'E745:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
2269 call assert_fails('let x=range(1, 4, [])', 'E745:')
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 18821
diff changeset
2270 endfunc
19400
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2271
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2272 func Test_echoraw()
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2273 CheckScreendump
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2274
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2275 " Normally used for escape codes, but let's test with a CR.
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2276 let lines =<< trim END
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2277 call echoraw("hello\<CR>x")
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2278 END
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2279 call writefile(lines, 'XTest_echoraw')
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2280 let buf = RunVimInTerminal('-S XTest_echoraw', {'rows': 5, 'cols': 40})
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2281 call VerifyScreenDump(buf, 'Test_functions_echoraw', {})
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2282
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2283 " clean up
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2284 call StopVimInTerminal(buf)
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2285 call delete('XTest_echoraw')
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19306
diff changeset
2286 endfunc
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
2287
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2288 " Test for echo highlighting
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2289 func Test_echohl()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2290 echohl Search
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2291 echo 'Vim'
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2292 call assert_equal('Vim', Screenline(&lines))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2293 " TODO: How to check the highlight group used by echohl?
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2294 " ScreenAttrs() returns all zeros.
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2295 echohl None
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2296 endfunc
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2297
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2298 " Test for the eval() function
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2299 func Test_eval()
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2300 call assert_fails("call eval('5 a')", 'E488:')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2301 endfunc
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2302
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2303 " Test for the nr2char() function
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2304 func Test_nr2char()
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2305 set encoding=latin1
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2306 call assert_equal('@', nr2char(64))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2307 set encoding=utf8
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2308 call assert_equal('a', nr2char(97, 1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2309 call assert_equal('a', nr2char(97, 0))
20526
9fd5414e294c patch 8.2.0817: not enough memory allocated when converting string
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
2310
9fd5414e294c patch 8.2.0817: not enough memory allocated when converting string
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
2311 call assert_equal("\x80\xfc\b\xf4\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x100000) .. '>"'))
20540
193c0446cf28 patch 8.2.0824: still not enough memory allocated when converting string
Bram Moolenaar <Bram@vim.org>
parents: 20526
diff changeset
2312 call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x40000000) .. '>"'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2313 endfunc
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2314
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2315 " Test for screenattr(), screenchar() and screenchars() functions
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2316 func Test_screen_functions()
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2317 call assert_equal(-1, screenattr(-1, -1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2318 call assert_equal(-1, screenchar(-1, -1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2319 call assert_equal([], screenchars(-1, -1))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2320 endfunc
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2321
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2322 " Test for getcurpos() and setpos()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2323 func Test_getcurpos_setpos()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2324 new
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2325 call setline(1, ['012345678', '012345678'])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2326 normal gg6l
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2327 let sp = getcurpos()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2328 normal 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2329 call setpos('.', sp)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2330 normal jyl
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2331 call assert_equal('6', @")
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2332 call assert_equal(-1, setpos('.', test_null_list()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2333 call assert_equal(-1, setpos('.', {}))
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2334 close!
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2335 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
2336
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2337 " Test for glob()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2338 func Test_glob()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2339 call assert_equal('', glob(test_null_string()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2340 call assert_equal('', globpath(test_null_string(), test_null_string()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2341 endfunc
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2342
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2343 " Test for browse()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2344 func Test_browse()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2345 CheckFeature browse
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2346 call assert_fails('call browse([], "open", "x", "a.c")', 'E745:')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2347 endfunc
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2348
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2349 " Test for browsedir()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2350 func Test_browsedir()
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2351 CheckFeature browse
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2352 call assert_fails('call browsedir("open", [])', 'E730:')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2353 endfunc
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
2354
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19400
diff changeset
2355 " vim: shiftwidth=2 sts=2 expandtab