Mercurial > vim
annotate src/testdir/test_functions.vim @ 32396:9feee1b0b58a
Added tag v9.0.1529 for changeset 2ed95122d59c114dceacb2f811a92522c8de3c11
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 May 2023 16:15:07 +0200 |
parents | 49a13ac4a1b1 |
children | 3c2c1cb61004 |
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. |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2 |
14669
63d5ae57a663
patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents:
14579
diff
changeset
|
3 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
|
4 source check.vim |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
5 source term_util.vim |
19400
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
6 source screendump.vim |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27412
diff
changeset
|
7 import './vim9.vim' as v9 |
10555
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
12869
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
9 " 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
|
10 func Test_00_bufexists() |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
11 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
|
12 call assert_equal(1, bufexists(bufnr('%'))) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
13 call assert_equal(0, bufexists(0)) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
14 new Xfoo |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
15 let bn = bufnr('%') |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
16 call assert_equal(1, bufexists(bn)) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
17 call assert_equal(1, bufexists('Xfoo')) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
18 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
|
19 call assert_equal(1, bufexists(0)) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
20 bw |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
21 call assert_equal(0, bufexists(bn)) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
22 call assert_equal(0, bufexists('Xfoo')) |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
23 endfunc |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
24 |
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
|
25 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
|
26 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
|
27 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
|
28 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
29 if has('unix') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 endif |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
34 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
|
35 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
|
36 |
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
|
37 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
|
38 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
|
39 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
40 " 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
|
41 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
|
42 call assert_equal(0, has(ver)) |
29334
72d1b2ea70dc
patch 9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29073
diff
changeset
|
43 |
72d1b2ea70dc
patch 9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29073
diff
changeset
|
44 " There actually isn't a patch 9.0.0, but this is more consistent. |
72d1b2ea70dc
patch 9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29073
diff
changeset
|
45 call assert_equal(1, has('patch-9.0.0')) |
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
|
46 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
|
47 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
48 func Test_empty() |
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(1, empty('')) |
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('a')) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
51 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
57 call assert_equal(1, empty(0.0)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
58 call assert_equal(1, empty(-0.0)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
59 call assert_equal(0, empty(1.0)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
60 call assert_equal(0, empty(-1.0)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
61 call assert_equal(0, empty(1.0/0.0)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
62 call assert_equal(0, empty(0.0/0.0)) |
10743
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'])) |
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({})) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
68 call assert_equal(0, empty({'a':1})) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
69 |
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(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
|
71 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
|
72 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
|
73 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
|
74 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
75 if has('channel') |
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_channel())) |
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 if has('job') |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
79 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
|
80 endif |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
81 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
82 call assert_equal(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
|
83 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
|
84 |
9a9ca0e622c8
patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents:
19536
diff
changeset
|
85 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
|
86 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
|
87 endfunc |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
88 |
19554
b38d73f36467
patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents:
19548
diff
changeset
|
89 func Test_test_void() |
24940
0c415a0f54f9
patch 8.2.3007: Vim9: test for void value fails
Bram Moolenaar <Bram@vim.org>
parents:
24878
diff
changeset
|
90 call assert_fails('echo 1 == test_void()', 'E1031:') |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
91 call assert_fails('echo 1.0 == test_void()', 'E1031:') |
19554
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 = 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
|
93 call assert_fails('let x = copy(test_void())', 'E685:') |
24940
0c415a0f54f9
patch 8.2.3007: Vim9: test for void value fails
Bram Moolenaar <Bram@vim.org>
parents:
24878
diff
changeset
|
94 call assert_fails('let x = copy([test_void()])', 'E1031:') |
19554
b38d73f36467
patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents:
19548
diff
changeset
|
95 endfunc |
b38d73f36467
patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents:
19548
diff
changeset
|
96 |
25244
11ed1f0adb01
patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
97 func Test_islocked() |
11ed1f0adb01
patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
98 call assert_fails('call islocked(99)', 'E475:') |
11ed1f0adb01
patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
99 call assert_fails('call islocked("s: x")', 'E488:') |
11ed1f0adb01
patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
100 endfunc |
11ed1f0adb01
patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
101 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
102 func Test_len() |
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(1, len(0)) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
104 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
|
105 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
106 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
|
107 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
|
108 |
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(0, len([])) |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
110 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
|
111 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
|
112 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
117 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
|
118 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
|
119 endfunc |
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 func Test_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(0, max([])) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
123 call assert_equal(2, max([2])) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
124 call assert_equal(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
|
125 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
|
126 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
127 call assert_equal(0, max({})) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
128 call assert_equal(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
|
129 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
130 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
|
131 call assert_fails('call max(v:none)', 'E712:') |
23849
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
132 |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
133 " check we only get one error |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
134 call assert_fails('call max([#{}, [1]])', ['E728:', 'E728:']) |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
135 call assert_fails('call max(#{a: {}, b: [1]})', ['E728:', 'E728:']) |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
136 endfunc |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
137 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
138 func Test_min() |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
139 call assert_equal(0, min([])) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
140 call assert_equal(2, min([2])) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
141 call assert_equal(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
|
142 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
|
143 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
144 call assert_equal(0, min({})) |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
145 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
|
146 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
147 call assert_fails('call min(1)', 'E712:') |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
148 call assert_fails('call min(v:none)', 'E712:') |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
149 call assert_fails('call min([1, {}])', 'E728:') |
23849
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
150 |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
151 " check we only get one error |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
152 call assert_fails('call min([[1], #{}])', ['E745:', 'E745:']) |
a45a922832d4
patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents:
23432
diff
changeset
|
153 call assert_fails('call min(#{a: [1], b: #{}})', ['E745:', 'E745:']) |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
154 endfunc |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
155 |
13980
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
156 func Test_strwidth() |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
157 for aw in ['single', 'double'] |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
158 exe 'set ambiwidth=' . aw |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
159 call assert_equal(0, strwidth('')) |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
160 call assert_equal(1, strwidth("\t")) |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
161 call assert_equal(3, strwidth('Vim')) |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
162 call assert_equal(4, strwidth(1234)) |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
163 call assert_equal(5, strwidth(-1234)) |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
164 |
15607
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
165 call assert_equal(2, strwidth('😉')) |
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
166 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
|
167 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
|
168 |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
169 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
|
170 call assert_fails('call strwidth([])', 'E730:') |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
171 call assert_fails('call strwidth({})', 'E731:') |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
172 endfor |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
173 |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
174 call assert_equal(3, strwidth(1.2)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
175 call v9.CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
24822
5f8dd7b3ae41
patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents:
24766
diff
changeset
|
176 |
13980
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
177 set ambiwidth& |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
178 endfunc |
a9e31b01366b
patch 8.1.0008: no test for strwidth()
Christian Brabandt <cb@256bit.org>
parents:
13513
diff
changeset
|
179 |
10555
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 func Test_str2nr() |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 call assert_equal(0, str2nr('')) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 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
|
183 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
|
184 |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 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
|
190 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
|
191 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
|
192 |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 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
|
194 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
|
195 |
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(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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 call assert_equal(-65, str2nr('-0101', 8)) |
20665
6ff992bf4c82
patch 8.2.0886: cannot use octal numbers in scriptversion 4
Bram Moolenaar <Bram@vim.org>
parents:
20643
diff
changeset
|
207 call assert_equal(65, str2nr('0o101', 8)) |
6ff992bf4c82
patch 8.2.0886: cannot use octal numbers in scriptversion 4
Bram Moolenaar <Bram@vim.org>
parents:
20643
diff
changeset
|
208 call assert_equal(65, str2nr('0O0101', 8)) |
6ff992bf4c82
patch 8.2.0886: cannot use octal numbers in scriptversion 4
Bram Moolenaar <Bram@vim.org>
parents:
20643
diff
changeset
|
209 call assert_equal(-65, str2nr('-0O101', 8)) |
6ff992bf4c82
patch 8.2.0886: cannot use octal numbers in scriptversion 4
Bram Moolenaar <Bram@vim.org>
parents:
20643
diff
changeset
|
210 call assert_equal(-65, str2nr('-0o0101', 8)) |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
211 |
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(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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 |
18080
a6d218f99ff7
patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
227 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
|
228 call assert_equal(0, str2nr('0b10')) |
20665
6ff992bf4c82
patch 8.2.0886: cannot use octal numbers in scriptversion 4
Bram Moolenaar <Bram@vim.org>
parents:
20643
diff
changeset
|
229 call assert_equal(0, str2nr('0o10')) |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
234 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
|
235 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
|
236 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
237 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
|
238 call assert_fails('call str2nr({->2})', 'E729:') |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
239 call assert_equal(1, str2nr(1.2)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
240 call v9.CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
241 call assert_fails('call str2nr(10, [])', 'E745:') |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
242 endfunc |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
243 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
244 func Test_strftime() |
18669
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
245 CheckFunction strftime |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
246 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
247 " 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
|
248 " 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
|
249 " 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
|
250 " |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
251 " 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
|
252 " 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
|
253 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
|
254 " |
18017
988e5a868b60
patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18000
diff
changeset
|
255 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
|
256 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
257 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
|
258 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
|
259 |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
260 " 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
|
261 " 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
|
262 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
|
263 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
|
264 endif |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
265 |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
266 " 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
|
267 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
|
268 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
|
269 |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
270 " 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
|
271 " 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
|
272 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
|
273 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
|
274 " 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
|
275 if has('unix') |
ca4e6685e2f4
patch 8.1.1568: strftime() test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
17135
diff
changeset
|
276 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
|
277 endif |
17135
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
278 |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
279 " 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
|
280 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
|
281 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
|
282 else |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
283 unlet $TZ |
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
284 endif |
18669
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
285 endfunc |
17135
d03a52e02f1a
patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents:
16945
diff
changeset
|
286 |
18669
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
287 func Test_strptime() |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
288 CheckFunction strptime |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
289 |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
290 if exists('$TZ') |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
291 let tz = $TZ |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
292 endif |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
293 let $TZ = 'UTC' |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
294 |
18821
a9cfb0db187d
patch 8.1.2398: strptime() test fails on Japanese Mac
Bram Moolenaar <Bram@vim.org>
parents:
18669
diff
changeset
|
295 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
|
296 |
20794
2e7acc208a1f
patch 8.2.0949: strptime() does not use DST
Bram Moolenaar <Bram@vim.org>
parents:
20790
diff
changeset
|
297 " Force DST and check that it's considered |
2e7acc208a1f
patch 8.2.0949: strptime() does not use DST
Bram Moolenaar <Bram@vim.org>
parents:
20790
diff
changeset
|
298 let $TZ = 'WINTER0SUMMER,J1,J365' |
2e7acc208a1f
patch 8.2.0949: strptime() does not use DST
Bram Moolenaar <Bram@vim.org>
parents:
20790
diff
changeset
|
299 call assert_equal(1484653763 - 3600, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23')) |
2e7acc208a1f
patch 8.2.0949: strptime() does not use DST
Bram Moolenaar <Bram@vim.org>
parents:
20790
diff
changeset
|
300 |
18669
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
301 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
|
302 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
|
303 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
|
304 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
|
305 |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
306 if exists('tz') |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
307 let $TZ = tz |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
308 else |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
309 unlet $TZ |
9007e9896303
patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents:
18623
diff
changeset
|
310 endif |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
311 endfunc |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
312 |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
313 func Test_resolve_unix() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
314 CheckUnix |
14885
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
315 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
316 " Xlink1 -> Xlink2 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
317 " Xlink2 -> Xlink3 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 " 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
|
324 "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
|
325 "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
|
326 "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
|
327 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
|
328 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
329 " 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
|
330 " Xlink1 -> Xlink2 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
331 " Xlink2 -> Xlink3 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
332 " Xlink3 -> Xlink1 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
342 silent !ln -s -f Xresolvedir//Xfile Xresolvelink |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
343 call assert_equal('Xresolvedir/Xfile', resolve('Xresolvelink')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
344 call delete('Xresolvelink') |
14885
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
345 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 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
|
350 |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
351 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
|
352 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
|
353 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
|
354 call delete('Xlink1') |
22512
aeeee593fe0f
patch 8.2.1804: resolve('/') returns an empty string
Bram Moolenaar <Bram@vim.org>
parents:
22385
diff
changeset
|
355 |
aeeee593fe0f
patch 8.2.1804: resolve('/') returns an empty string
Bram Moolenaar <Bram@vim.org>
parents:
22385
diff
changeset
|
356 call assert_equal('/', resolve('/')) |
14885
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
357 endfunc |
5e47597de905
patch 8.1.0454: resolve() was not tested with a symlink cycle
Bram Moolenaar <Bram@vim.org>
parents:
14883
diff
changeset
|
358 |
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 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
|
360 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
|
361 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
|
362 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
|
363 endfunc |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
364 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
365 func Test_resolve_win32() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
366 CheckMSWindows |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
367 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
368 " 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
|
369 if executable('cscript') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
370 new Xresfile |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
371 wq |
17172
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17137
diff
changeset
|
372 let lines =<< trim END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17137
diff
changeset
|
373 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
|
374 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
|
375 Set shortcut = ws.CreateShortcut("Xlink.lnk") |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
376 shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xresfile") |
17172
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17137
diff
changeset
|
377 shortcut.Save |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17137
diff
changeset
|
378 END |
6990c1160ea5
patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents:
17137
diff
changeset
|
379 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
|
380 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
|
381 call delete('link.vbs') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
382 call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk'))) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
383 call delete('Xresfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
384 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
385 call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk'))) |
15774
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('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
|
387 else |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
388 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
|
389 endif |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
390 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
391 " 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
|
392 call delete('Xlink') |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
393 call delete('Xdir', 'd') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
394 call delete('Xresfile') |
15774
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 symbolic link to a file |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
397 new Xresfile |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
398 wq |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
399 call assert_equal('Xresfile', resolve('Xresfile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
400 silent !mklink Xlink Xresfile |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
401 if !v:shell_error |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
402 call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink'))) |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
403 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
|
404 else |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
405 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
|
406 endif |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
407 call delete('Xresfile') |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
408 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
409 " test for junction to a directory |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
410 call mkdir('Xdir') |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
411 silent !mklink /J Xlink Xdir |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
412 if !v:shell_error |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
413 call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
414 |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
415 call delete('Xdir', 'd') |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
416 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
417 " 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
|
418 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
|
419 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
|
420 else |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
421 echomsg 'skipped test for junction to a directory' |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
422 call delete('Xdir', 'd') |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
423 endif |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
424 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
425 " test for symbolic link to a directory |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
426 call mkdir('Xdir') |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
427 silent !mklink /D Xlink Xdir |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
428 if !v:shell_error |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
429 call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
430 |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
431 call delete('Xdir', 'd') |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
432 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
433 " 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
|
434 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
|
435 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
|
436 else |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
437 echomsg 'skipped test for symbolic link to a directory' |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
438 call delete('Xdir', 'd') |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
439 endif |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
440 |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
441 " test for buffer name |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
442 new Xbuffile |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
443 wq |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
444 silent !mklink Xlink Xbuffile |
15774
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
445 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
|
446 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
|
447 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
|
448 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
|
449 bw! |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
450 else |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
451 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
|
452 endif |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
453 call delete('Xbuffile') |
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
|
454 |
f42aa3d90b12
patch 8.1.1417: MS-Windows: resolve() does not resolve all components of path
Bram Moolenaar <Bram@vim.org>
parents:
16752
diff
changeset
|
455 " test for reparse point |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
456 call mkdir('Xdir') |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
457 call assert_equal('Xdir', resolve('Xdir')) |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
458 silent !mklink /D Xdirlink 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
|
459 if !v:shell_error |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
460 w Xdir/text.txt |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
461 call assert_equal('Xdir/text.txt', resolve('Xdir/text.txt')) |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
462 call assert_equal(s:normalize_fname(getcwd() . '\Xdir\text.txt'), s:normalize_fname(resolve('Xdirlink\text.txt'))) |
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 |
29972
85f4350627a7
patch 9.0.0324: MS-Windows: resolve() test fails
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
469 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
|
470 endfunc |
c4efa095f323
patch 8.1.0894: MS-Windows: resolve() does not return a reparse point
Bram Moolenaar <Bram@vim.org>
parents:
15754
diff
changeset
|
471 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
472 func Test_simplify() |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
473 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
|
474 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
|
475 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
|
476 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
|
477 call assert_equal('/...', simplify('/...')) |
20867
9c24319b4cb2
patch 8.2.0985: simplify() does not remove slashes from "///path"
Bram Moolenaar <Bram@vim.org>
parents:
20794
diff
changeset
|
478 call assert_equal('//path', simplify('//path')) |
20869
738e182aaf29
patch 8.2.0986: MS-Windows: functions test fails
Bram Moolenaar <Bram@vim.org>
parents:
20867
diff
changeset
|
479 if has('unix') |
738e182aaf29
patch 8.2.0986: MS-Windows: functions test fails
Bram Moolenaar <Bram@vim.org>
parents:
20867
diff
changeset
|
480 call assert_equal('/path', simplify('///path')) |
738e182aaf29
patch 8.2.0986: MS-Windows: functions test fails
Bram Moolenaar <Bram@vim.org>
parents:
20867
diff
changeset
|
481 call assert_equal('/path', simplify('////path')) |
738e182aaf29
patch 8.2.0986: MS-Windows: functions test fails
Bram Moolenaar <Bram@vim.org>
parents:
20867
diff
changeset
|
482 endif |
20867
9c24319b4cb2
patch 8.2.0985: simplify() does not remove slashes from "///path"
Bram Moolenaar <Bram@vim.org>
parents:
20794
diff
changeset
|
483 |
19952
82ea10d554fb
patch 8.2.0532: cannot use simplify() as a method
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 call assert_equal('./file', simplify('dir/.././file')) |
20978
2c3e7a6bd6c6
patch 8.2.1040: not enough testing for movement commands
Bram Moolenaar <Bram@vim.org>
parents:
20887
diff
changeset
|
490 call assert_equal('../dir', simplify('./../dir')) |
2c3e7a6bd6c6
patch 8.2.1040: not enough testing for movement commands
Bram Moolenaar <Bram@vim.org>
parents:
20887
diff
changeset
|
491 call assert_equal('..', simplify('../testdir/..')) |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
492 call mkdir('Xsimpdir') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
493 call assert_equal('.', simplify('Xsimpdir/../.')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
494 call delete('Xsimpdir', 'd') |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
495 |
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
496 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
|
497 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
|
498 call assert_fails('call simplify({})', 'E731:') |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
499 call assert_equal('1.2', simplify(1.2)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
500 call v9.CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) |
10555
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
501 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
|
502 |
14487
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
503 func Test_pathshorten() |
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
504 call assert_equal('', pathshorten('')) |
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
505 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
|
506 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
|
507 call assert_equal('f/', pathshorten('foo/')) |
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 call assert_fails('call pathshorten([])', 'E730:') |
22385
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
517 |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
518 " test pathshorten with optional variable to set preferred size of shortening |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
519 call assert_equal('', pathshorten('', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
520 call assert_equal('foo', pathshorten('foo', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
521 call assert_equal('/foo', pathshorten('/foo', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
522 call assert_equal('fo/', pathshorten('foo/', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
523 call assert_equal('fo/bar', pathshorten('foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
524 call assert_equal('fo/ba/foobar', pathshorten('foo/bar/foobar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
525 call assert_equal('/fo/ba/foobar', pathshorten('/foo/bar/foobar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
526 call assert_equal('.fo/bar', pathshorten('.foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
527 call assert_equal('~fo/bar', pathshorten('~foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
528 call assert_equal('~.fo/bar', pathshorten('~.foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
529 call assert_equal('.~fo/bar', pathshorten('.~foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
530 call assert_equal('~/fo/bar', pathshorten('~/foo/bar', 2)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
531 call assert_fails('call pathshorten([],2)', 'E730:') |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
532 call assert_notequal('~/fo/bar', pathshorten('~/foo/bar', 3)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
533 call assert_equal('~/foo/bar', pathshorten('~/foo/bar', 3)) |
770fe121ca64
patch 8.2.1741: pathshorten() only supports using one character
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
534 call assert_equal('~/f/bar', pathshorten('~/foo/bar', 0)) |
14487
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
535 endfunc |
336213a840d9
patch 8.1.0257: no test for pathshorten()
Christian Brabandt <cb@256bit.org>
parents:
14422
diff
changeset
|
536 |
12869
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
537 func Test_strpart() |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 |
15607
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
546 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
|
547 call assert_equal('léphant', strpart('éléphant', 2)) |
21935
62f933f64447
patch 8.2.1517: cannot easily get the character under the cursor
Bram Moolenaar <Bram@vim.org>
parents:
21911
diff
changeset
|
548 |
62f933f64447
patch 8.2.1517: cannot easily get the character under the cursor
Bram Moolenaar <Bram@vim.org>
parents:
21911
diff
changeset
|
549 call assert_equal('é', strpart('éléphant', 0, 1, 1)) |
62f933f64447
patch 8.2.1517: cannot easily get the character under the cursor
Bram Moolenaar <Bram@vim.org>
parents:
21911
diff
changeset
|
550 call assert_equal('ép', strpart('éléphant', 3, 2, v:true)) |
62f933f64447
patch 8.2.1517: cannot easily get the character under the cursor
Bram Moolenaar <Bram@vim.org>
parents:
21911
diff
changeset
|
551 call assert_equal('ó', strpart('cómposed', 1, 1, 1)) |
12869
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
552 endfunc |
a89350ba2a9d
patch 8.0.1311: no test for strpart()
Christian Brabandt <cb@256bit.org>
parents:
12451
diff
changeset
|
553 |
10706
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
554 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
|
555 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
|
556 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
557 " 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
|
558 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
|
559 \ 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
|
560 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
561 " 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 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
|
579 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
|
580 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
589 " 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
|
590 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
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
617 " 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
|
618 " Ⱥ (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
|
619 " 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
|
620 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
|
621 |
d5647746c267
patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents:
13070
diff
changeset
|
622 " 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
|
623 " invalid memory. |
d5647746c267
patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents:
13070
diff
changeset
|
624 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
|
625 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
|
626 |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
627 " Test in latin1 encoding |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
628 let save_enc = &encoding |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
629 set encoding=latin1 |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
630 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
|
631 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
|
632 endfunc |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
633 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
634 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
|
635 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
|
636 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
637 " 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
|
638 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
|
639 \ 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
|
640 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
641 " 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
|
642 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
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 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
|
661 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
|
662 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
|
663 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
|
664 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
|
665 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
|
666 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
|
667 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
|
668 |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
669 " 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 |
10743
8779b4b2e958
patch 8.0.0261: not enough test coverage for eval functions
Christian Brabandt <cb@256bit.org>
parents:
10706
diff
changeset
|
697 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
|
698 |
d5647746c267
patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents:
13070
diff
changeset
|
699 " 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
|
700 " invalid memory. |
d5647746c267
patch 8.0.1421: accessing invalid memory with overlong byte sequence
Christian Brabandt <cb@256bit.org>
parents:
13070
diff
changeset
|
701 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
|
702 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
|
703 |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
704 " Test in latin1 encoding |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
705 let save_enc = &encoding |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
706 set encoding=latin1 |
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
707 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
|
708 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
|
709 endfunc |
056e32b99e93
patch 8.0.0243: tolower() does not work if the byte count changes
Christian Brabandt <cb@256bit.org>
parents:
10555
diff
changeset
|
710 |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
711 func Test_tr() |
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 set encoding=latin1 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
719 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
|
720 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
|
721 call assert_equal('hello', tr('hello', 'xy', 'ab')) |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
722 call assert_fails('call tr("abc", "123", "₁₂")', 'E475:') |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
723 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
|
724 endfunc |
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
725 |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
726 " 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
|
727 let current_modes = '' |
11135
c4e4387bbd50
patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents:
11095
diff
changeset
|
728 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
|
729 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
|
730 return '' |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
731 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
|
732 |
19906
031184ace7c5
patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents:
19902
diff
changeset
|
733 " 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
|
734 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
|
735 new |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
736 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
|
737 |
11135
c4e4387bbd50
patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents:
11095
diff
changeset
|
738 " 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
|
739 set complete=. |
c4e4387bbd50
patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents:
11095
diff
changeset
|
740 |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
741 inoremap <F2> <C-R>=Save_mode()<CR> |
25398
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
742 xnoremap <F2> <Cmd>call Save_mode()<CR> |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
743 |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
744 normal! 3G |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
745 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
|
746 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
|
747 " 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
|
748 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
|
749 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
|
750 " 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
|
751 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
|
752 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
|
753 " 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
|
754 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
|
755 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
|
756 " 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
|
757 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
|
758 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
|
759 " 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
|
760 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
|
761 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
|
762 " 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
|
763 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
|
764 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
|
765 " 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
|
766 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
|
767 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
|
768 " 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
|
769 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
|
770 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
|
771 " 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
|
772 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
|
773 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
|
774 " 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
|
775 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
|
776 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
|
777 " 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
|
778 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
|
779 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
|
780 |
25864
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
781 exe "normal R\<F2>\<Esc>" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
782 call assert_equal('R-R', g:current_modes) |
10833
d66e5446cc48
patch 8.0.0306: mode() not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10787
diff
changeset
|
783 " 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
|
784 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
|
785 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
|
786 " 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
|
787 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
|
788 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
|
789 " 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
|
790 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
|
791 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
|
792 " 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
|
793 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
|
794 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
|
795 " 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
|
796 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
|
797 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
|
798 " 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
|
799 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
|
800 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
|
801 " 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
|
802 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
|
803 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
|
804 " 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
|
805 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
|
806 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
|
807 " 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
|
808 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
|
809 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
|
810 " 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
|
811 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
|
812 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
|
813 " 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
|
814 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
|
815 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
|
816 |
25864
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
817 exe "normal gR\<F2>\<Esc>" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
818 call assert_equal('R-Rv', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
819 " gR_CTRL-P: Multiple matches |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
820 exe "normal gRBa\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
821 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
822 " gR_CTRL-P: Single match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
823 exe "normal gRBro\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
824 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
825 " gR_CTRL-X |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
826 exe "normal gRBa\<C-X>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
827 call assert_equal('R-Rvx', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
828 " gR_CTRL-X CTRL-P: Multiple matches |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
829 exe "normal gRBa\<C-X>\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
830 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
831 " gR_CTRL-X CTRL-P: Single match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
832 exe "normal gRBro\<C-X>\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
833 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
834 " gR_CTRL-X CTRL-P + CTRL-P: Single match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
835 exe "normal gRBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
836 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
837 " gR_CTRL-X CTRL-L: Multiple matches |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
838 exe "normal gR\<C-X>\<C-L>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
839 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
840 " gR_CTRL-X CTRL-L: Single match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
841 exe "normal gRBlu\<C-X>\<C-L>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
842 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
843 " gR_CTRL-P: No match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
844 exe "normal gRCom\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
845 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
846 " gR_CTRL-X CTRL-P: No match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
847 exe "normal gRCom\<C-X>\<C-P>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
848 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
849 " gR_CTRL-X CTRL-L: No match |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
850 exe "normal gRabc\<C-X>\<C-L>\<F2>\<Esc>u" |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
851 call assert_equal('R-Rvc', g:current_modes) |
44e9d98555a9
patch 8.2.3466: completion submode not indicated for virtual replace
Bram Moolenaar <Bram@vim.org>
parents:
25854
diff
changeset
|
852 |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
853 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
|
854 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
|
855 |
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
|
856 " 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
|
857 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
|
858 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
|
859 |
06316dbd66bc
patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents:
14379
diff
changeset
|
860 " 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
|
861 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
|
862 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
|
863 |
06316dbd66bc
patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents:
14379
diff
changeset
|
864 " 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
|
865 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
|
866 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
|
867 |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
868 " 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
|
869 |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
870 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
|
871 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
|
872 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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 |
25398
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
892 " v_CTRL-O |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
893 exe "normal gh\<C-O>\<F2>\<Esc>" |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
894 call assert_equal("v-vs", g:current_modes) |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
895 exe "normal gH\<C-O>\<F2>\<Esc>" |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
896 call assert_equal("V-Vs", g:current_modes) |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
897 exe "normal g\<C-H>\<C-O>\<F2>\<Esc>" |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
898 call assert_equal("\<C-V>-\<C-V>s", g:current_modes) |
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
899 |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
900 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
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 " 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
|
907 |
26007
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
908 " Test mode in operatorfunc (it used to be Operator-pending). |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
909 set operatorfunc=OperatorFunc |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
910 function OperatorFunc(_) |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
911 call Save_mode() |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
912 endfunction |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
913 execute "normal! g@l\<Esc>" |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
914 call assert_equal('n-n', g:current_modes) |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
915 execute "normal! i\<C-o>g@l\<Esc>" |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
916 call assert_equal('n-niI', g:current_modes) |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
917 execute "normal! R\<C-o>g@l\<Esc>" |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
918 call assert_equal('n-niR', g:current_modes) |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
919 execute "normal! gR\<C-o>g@l\<Esc>" |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
920 call assert_equal('n-niV', g:current_modes) |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
921 |
25854
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
922 if has('terminal') |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
923 term |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
924 call feedkeys("\<C-W>N", 'xt') |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
925 call assert_equal('n', mode()) |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
926 call assert_equal('nt', mode(1)) |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
927 call feedkeys("aexit\<CR>", 'xt') |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
928 endif |
2d0bea8aed33
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode
Bram Moolenaar <Bram@vim.org>
parents:
25771
diff
changeset
|
929 |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
930 bwipe! |
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
931 iunmap <F2> |
25398
4101d78f78e2
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
932 xunmap <F2> |
11135
c4e4387bbd50
patch 8.0.0455: the mode test may hang
Christian Brabandt <cb@256bit.org>
parents:
11095
diff
changeset
|
933 set complete& |
26007
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
934 set operatorfunc& |
1d2e1c23e458
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
935 delfunction OperatorFunc |
10787
09926123316b
patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents:
10743
diff
changeset
|
936 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
|
937 |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
938 " Test for append() |
17871
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
939 func Test_append() |
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
940 enew! |
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
941 split |
31004
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
942 call assert_equal(0, append(1, [])) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
943 call assert_equal(0, append(1, test_null_list())) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
944 call assert_equal(0, append(0, ["foo"])) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
945 call assert_equal(0, append(1, [])) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
946 call assert_equal(0, append(1, test_null_list())) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
947 call assert_equal(0, append(8, [])) |
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
31002
diff
changeset
|
948 call assert_equal(0, append(9, test_null_list())) |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
949 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
|
950 split |
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
951 only |
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
952 undo |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
953 undo |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
954 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
955 " 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
|
956 call assert_fails("call append($, 'foobar')", 'E116:') |
30761
c9b31c8eb3b3
patch 9.0.0715: wrong argument for append() gives two error messages
Bram Moolenaar <Bram@vim.org>
parents:
30552
diff
changeset
|
957 |
c9b31c8eb3b3
patch 9.0.0715: wrong argument for append() gives two error messages
Bram Moolenaar <Bram@vim.org>
parents:
30552
diff
changeset
|
958 call assert_fails("call append({}, '')", ['E728:', 'E728:']) |
17871
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
959 endfunc |
521ce0d887e5
patch 8.1.1932: ml_get errors after using append()
Bram Moolenaar <Bram@vim.org>
parents:
17849
diff
changeset
|
960 |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
961 " Test for setline() |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
962 func Test_setline() |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
963 new |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
964 call setline(0, ["foo"]) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
965 call setline(0, []) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
966 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
|
967 call setline(1, ["bar"]) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
968 call setline(1, []) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
969 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
|
970 call setline(2, []) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
971 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
|
972 call setline(3, []) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
973 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
|
974 call setline(2, ["baz"]) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
975 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
|
976 close! |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
977 endfunc |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
978 |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 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
|
985 |
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
986 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
|
987 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
|
988 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
|
989 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
|
990 |
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
991 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
|
992 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
|
993 |
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
994 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
|
995 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
|
996 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
|
997 |
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 |
11197
7f355d8cd634
patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
1003 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
|
1004 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
|
1005 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
|
1006 |
10891
c9d057b7a0ab
patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1007 call assert_equal(0, getbufvar(bnr, '&autoindent')) |
c9d057b7a0ab
patch 8.0.0335: functions test fails
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1008 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
|
1009 |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19554
diff
changeset
|
1010 " 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
|
1011 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
|
1012 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
|
1013 |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
1014 " 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
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 close |
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
1021 |
19902
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1022 " Get the b: dict. |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1023 let b:testvar = 'one' |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1024 new |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1025 let b:testvar = 'two' |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1026 let thebuf = bufnr() |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1027 wincmd w |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1028 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
|
1029 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
|
1030 bwipe! |
481e8fa158b4
patch 8.2.0507: getbufvar() may get the wrong dictionary
Bram Moolenaar <Bram@vim.org>
parents:
19795
diff
changeset
|
1031 |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10833
diff
changeset
|
1032 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
|
1033 endfunc |
11020
50f3e37bc210
patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents:
10891
diff
changeset
|
1034 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1035 func Test_last_buffer_nr() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1036 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
|
1037 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1038 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1039 func Test_stridx() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 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
|
1052 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
|
1053 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
|
1054 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1055 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1056 func Test_strridx() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1057 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
|
1058 call assert_equal(0, strridx('', '')) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1059 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
|
1060 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
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1073 |
12451
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1074 func Test_match_func() |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1075 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
|
1076 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
|
1077 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
|
1078 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
|
1079 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
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 call assert_equal(-1, match(test_null_list(), 2)) |
22375
595ea7f099cd
patch 8.2.1736: failure to compile a pattern not tested much
Bram Moolenaar <Bram@vim.org>
parents:
22357
diff
changeset
|
1087 call assert_equal(-1, match('abc', '\\%(')) |
12451
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1088 endfunc |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1089 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1090 func Test_matchend() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1091 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
|
1092 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 endfunc |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1098 |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1099 func Test_matchlist() |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1100 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
|
1101 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
|
1102 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
|
1103 endfunc |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1104 |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1105 func Test_matchstr() |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 endfunc |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1113 |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1114 func Test_matchstrpos() |
61450cb2b6a1
patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1123 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1124 func Test_nextnonblank_prevnonblank() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1125 new |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1126 insert |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1127 This |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1128 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1129 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1130 is |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1131 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1132 a |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1133 Test |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1134 . |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1135 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
|
1136 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
|
1137 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
|
1138 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
|
1139 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
|
1140 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
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1146 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
|
1147 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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 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
|
1156 bw! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1157 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1158 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1159 func Test_byte2line_line2byte() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1160 new |
14579
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1161 set endofline |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1162 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
|
1163 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1164 set fileformat=unix |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1165 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
|
1166 \ 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
|
1167 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
|
1168 \ 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
|
1169 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1170 set fileformat=mac |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1171 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
|
1172 \ 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
|
1173 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
|
1174 \ 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
|
1175 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1176 set fileformat=dos |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1177 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
|
1178 \ 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
|
1179 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
|
1180 \ 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
|
1181 |
14579
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1182 bw! |
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1183 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
|
1184 normal a- |
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1185 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
|
1186 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
|
1187 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
|
1188 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
|
1189 endfor |
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1190 |
23d6d9e9ae3e
patch 8.1.0303: line2byte() is wrong for last line with 'noeol'
Christian Brabandt <cb@256bit.org>
parents:
14487
diff
changeset
|
1191 set endofline& fixendofline& fileformat& |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1192 bw! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1193 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1194 |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1195 " Test for byteidx() using a character index |
17829
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1196 func Test_byteidx() |
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 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
|
1203 |
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 call assert_equal(-1, b->byteidx(4)) |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1210 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1211 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1212 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1213 call assert_equal(0, byteidx(str, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1214 call assert_equal(1, byteidx(str, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1215 call assert_equal(6, byteidx(str, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1216 call assert_equal(7, byteidx(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1217 call assert_equal(12, byteidx(str, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1218 call assert_equal(-1, byteidx(str, 5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1219 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1220 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1221 call assert_equal(0, byteidx('', 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1222 call assert_equal(-1, byteidx('', 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1223 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1224 " error cases |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1225 call assert_fails("call byteidx([], 0)", 'E730:') |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1226 call assert_fails("call byteidx('abc', [])", 'E745:') |
32381
8b7ba5c63996
patch 9.0.1522: some functions give two error messages
Bram Moolenaar <Bram@vim.org>
parents:
32367
diff
changeset
|
1227 call assert_fails("call byteidx('abc', 0, {})", ['E728:', 'E728:']) |
32385
49a13ac4a1b1
patch 9.0.1524: passing -1 for bool is not always rejected
Bram Moolenaar <Bram@vim.org>
parents:
32381
diff
changeset
|
1228 call assert_fails("call byteidx('abc', 0, -1)", ['E1023:', 'E1023:']) |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1229 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1230 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1231 " Test for byteidxcomp() using a character index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1232 func Test_byteidxcomp() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1233 let a = '.é.' " one char of two bytes |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1234 call assert_equal(0, byteidxcomp(a, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1235 call assert_equal(1, byteidxcomp(a, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1236 call assert_equal(3, byteidxcomp(a, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1237 call assert_equal(4, byteidxcomp(a, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1238 call assert_equal(-1, byteidxcomp(a, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1239 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1240 let b = '.é.' " normal e with composing char |
17829
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1241 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
|
1242 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
|
1243 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
|
1244 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
|
1245 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
|
1246 call assert_equal(-1, b->byteidxcomp(5)) |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1247 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1248 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1249 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1250 call assert_equal(0, byteidxcomp(str, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1251 call assert_equal(1, byteidxcomp(str, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1252 call assert_equal(2, byteidxcomp(str, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1253 call assert_equal(4, byteidxcomp(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1254 call assert_equal(6, byteidxcomp(str, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1255 call assert_equal(7, byteidxcomp(str, 5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1256 call assert_equal(8, byteidxcomp(str, 6)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1257 call assert_equal(10, byteidxcomp(str, 7)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1258 call assert_equal(12, byteidxcomp(str, 8)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1259 call assert_equal(-1, byteidxcomp(str, 9)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1260 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1261 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1262 call assert_equal(0, byteidxcomp('', 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1263 call assert_equal(-1, byteidxcomp('', 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1264 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1265 " error cases |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1266 call assert_fails("call byteidxcomp([], 0)", 'E730:') |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1267 call assert_fails("call byteidxcomp('abc', [])", 'E745:') |
32381
8b7ba5c63996
patch 9.0.1522: some functions give two error messages
Bram Moolenaar <Bram@vim.org>
parents:
32367
diff
changeset
|
1268 call assert_fails("call byteidxcomp('abc', 0, {})", ['E728:', 'E728:']) |
32385
49a13ac4a1b1
patch 9.0.1524: passing -1 for bool is not always rejected
Bram Moolenaar <Bram@vim.org>
parents:
32381
diff
changeset
|
1269 call assert_fails("call byteidxcomp('abc', 0, -1)", ['E1023:', 'E1023:']) |
17829
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1270 endfunc |
1090d6637cfd
patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17783
diff
changeset
|
1271 |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1272 " Test for byteidx() using a UTF-16 index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1273 func Test_byteidx_from_utf16_index() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1274 " string with single byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1275 let str = "abc" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1276 for i in range(3) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1277 call assert_equal(i, byteidx(str, i, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1278 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1279 call assert_equal(3, byteidx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1280 call assert_equal(-1, byteidx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1281 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1282 " string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1283 let str = "a©©b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1284 call assert_equal(0, byteidx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1285 call assert_equal(1, byteidx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1286 call assert_equal(3, byteidx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1287 call assert_equal(5, byteidx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1288 call assert_equal(6, byteidx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1289 call assert_equal(-1, byteidx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1290 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1291 " string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1292 let str = "a😊😊b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1293 call assert_equal(0, byteidx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1294 call assert_equal(1, byteidx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1295 call assert_equal(1, byteidx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1296 call assert_equal(5, byteidx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1297 call assert_equal(5, byteidx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1298 call assert_equal(9, byteidx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1299 call assert_equal(10, byteidx(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1300 call assert_equal(-1, byteidx(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1301 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1302 " string with composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1303 let str = '-á-b́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1304 call assert_equal(0, byteidx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1305 call assert_equal(1, byteidx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1306 call assert_equal(4, byteidx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1307 call assert_equal(5, byteidx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1308 call assert_equal(8, byteidx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1309 call assert_equal(-1, byteidx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1310 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1311 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1312 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1313 call assert_equal(0, byteidx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1314 call assert_equal(1, byteidx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1315 call assert_equal(6, byteidx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1316 call assert_equal(7, byteidx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1317 call assert_equal(12, byteidx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1318 call assert_equal(-1, byteidx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1319 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1320 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1321 call assert_equal(0, byteidx('', 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1322 call assert_equal(-1, byteidx('', 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1323 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1324 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1325 call assert_fails('call byteidx(str, 0, [])', 'E745:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1326 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1327 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1328 " Test for byteidxcomp() using a UTF-16 index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1329 func Test_byteidxcomp_from_utf16_index() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1330 " string with single byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1331 let str = "abc" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1332 for i in range(3) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1333 call assert_equal(i, byteidxcomp(str, i, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1334 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1335 call assert_equal(3, byteidxcomp(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1336 call assert_equal(-1, byteidxcomp(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1337 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1338 " string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1339 let str = "a©©b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1340 call assert_equal(0, byteidxcomp(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1341 call assert_equal(1, byteidxcomp(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1342 call assert_equal(3, byteidxcomp(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1343 call assert_equal(5, byteidxcomp(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1344 call assert_equal(6, byteidxcomp(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1345 call assert_equal(-1, byteidxcomp(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1346 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1347 " string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1348 let str = "a😊😊b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1349 call assert_equal(0, byteidxcomp(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1350 call assert_equal(1, byteidxcomp(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1351 call assert_equal(1, byteidxcomp(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1352 call assert_equal(5, byteidxcomp(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1353 call assert_equal(5, byteidxcomp(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1354 call assert_equal(9, byteidxcomp(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1355 call assert_equal(10, byteidxcomp(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1356 call assert_equal(-1, byteidxcomp(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1357 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1358 " string with composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1359 let str = '-á-b́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1360 call assert_equal(0, byteidxcomp(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1361 call assert_equal(1, byteidxcomp(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1362 call assert_equal(2, byteidxcomp(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1363 call assert_equal(4, byteidxcomp(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1364 call assert_equal(5, byteidxcomp(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1365 call assert_equal(6, byteidxcomp(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1366 call assert_equal(8, byteidxcomp(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1367 call assert_equal(-1, byteidxcomp(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1368 call assert_fails('call byteidxcomp(str, 0, [])', 'E745:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1369 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1370 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1371 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1372 call assert_equal(0, byteidxcomp(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1373 call assert_equal(1, byteidxcomp(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1374 call assert_equal(2, byteidxcomp(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1375 call assert_equal(4, byteidxcomp(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1376 call assert_equal(6, byteidxcomp(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1377 call assert_equal(7, byteidxcomp(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1378 call assert_equal(8, byteidxcomp(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1379 call assert_equal(10, byteidxcomp(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1380 call assert_equal(12, byteidxcomp(str, 8, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1381 call assert_equal(-1, byteidxcomp(str, 9, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1382 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1383 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1384 call assert_equal(0, byteidxcomp('', 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1385 call assert_equal(-1, byteidxcomp('', 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1386 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1387 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1388 call assert_fails('call byteidxcomp(str, 0, [])', 'E745:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1389 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1390 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1391 " Test for charidx() using a byte index |
23380
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1392 func Test_charidx() |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1393 let a = 'xáb́y' |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1394 call assert_equal(0, charidx(a, 0)) |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1395 call assert_equal(1, charidx(a, 3)) |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1396 call assert_equal(2, charidx(a, 4)) |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1397 call assert_equal(3, charidx(a, 7)) |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1398 call assert_equal(-1, charidx(a, 8)) |
24596
acd9220bdd0b
patch 8.2.2837: various code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24448
diff
changeset
|
1399 call assert_equal(-1, charidx(a, -1)) |
23380
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1400 |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1401 " count composing characters |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1402 call assert_equal(0, a->charidx(0, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1403 call assert_equal(2, a->charidx(2, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1404 call assert_equal(3, a->charidx(4, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1405 call assert_equal(5, a->charidx(7, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1406 call assert_equal(-1, a->charidx(8, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1407 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1408 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1409 call assert_equal(-1, charidx('', 0)) |
23380
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1410 call assert_equal(-1, charidx('', 0, 1)) |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1411 |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1412 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1413 call assert_equal(-1, charidx(test_null_string(), 0)) |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
1414 call assert_fails('let x = charidx([], 1)', 'E1174:') |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
1415 call assert_fails('let x = charidx("abc", [])', 'E1210:') |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
1416 call assert_fails('let x = charidx("abc", 1, [])', 'E1212:') |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
1417 call assert_fails('let x = charidx("abc", 1, -1)', 'E1212:') |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
1418 call assert_fails('let x = charidx("abc", 1, 2)', 'E1212:') |
23380
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1419 endfunc |
2351b40af967
patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
1420 |
32307
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1421 " Test for charidx() using a UTF-16 index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1422 func Test_charidx_from_utf16_index() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1423 " string with single byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1424 let str = "abc" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1425 for i in range(3) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1426 call assert_equal(i, charidx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1427 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1428 call assert_equal(-1, charidx(str, 3, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1429 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1430 " string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1431 let str = "a©©b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1432 call assert_equal(0, charidx(str, 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1433 call assert_equal(1, charidx(str, 1, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1434 call assert_equal(2, charidx(str, 2, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1435 call assert_equal(3, charidx(str, 3, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1436 call assert_equal(-1, charidx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1437 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1438 " string with four byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1439 let str = "a😊😊b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1440 call assert_equal(0, charidx(str, 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1441 call assert_equal(1, charidx(str, 1, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1442 call assert_equal(1, charidx(str, 2, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1443 call assert_equal(2, charidx(str, 3, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1444 call assert_equal(2, charidx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1445 call assert_equal(3, charidx(str, 5, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1446 call assert_equal(-1, charidx(str, 6, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1447 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1448 " string with composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1449 let str = '-á-b́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1450 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1451 call assert_equal(i, charidx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1452 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1453 call assert_equal(-1, charidx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1454 for i in str->strchars()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1455 call assert_equal(i, charidx(str, i, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1456 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1457 call assert_equal(-1, charidx(str, 6, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1458 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1459 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1460 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1461 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1462 call assert_equal(i, charidx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1463 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1464 call assert_equal(-1, charidx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1465 for i in str->strchars()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1466 call assert_equal(i, charidx(str, i, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1467 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1468 call assert_equal(-1, charidx(str, 8, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1469 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1470 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1471 call assert_equal(-1, charidx('', 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1472 call assert_equal(-1, charidx('', 0, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1473 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1474 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1475 call assert_equal(-1, charidx('', 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1476 call assert_equal(-1, charidx('', 0, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1477 call assert_equal(-1, charidx(test_null_string(), 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1478 call assert_fails('let x = charidx("abc", 1, v:false, [])', 'E1212:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1479 call assert_fails('let x = charidx("abc", 1, v:true, [])', 'E1212:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1480 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1481 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1482 " Test for utf16idx() using a byte index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1483 func Test_utf16idx_from_byteidx() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1484 " UTF-16 index of a string with single byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1485 let str = "abc" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1486 for i in range(3) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1487 call assert_equal(i, utf16idx(str, i)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1488 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1489 call assert_equal(-1, utf16idx(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1490 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1491 " UTF-16 index of a string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1492 let str = 'a©©b' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1493 call assert_equal(0, str->utf16idx(0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1494 call assert_equal(1, str->utf16idx(1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1495 call assert_equal(1, str->utf16idx(2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1496 call assert_equal(2, str->utf16idx(3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1497 call assert_equal(2, str->utf16idx(4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1498 call assert_equal(3, str->utf16idx(5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1499 call assert_equal(-1, str->utf16idx(6)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1500 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1501 " UTF-16 index of a string with four byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1502 let str = 'a😊😊b' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1503 call assert_equal(0, utf16idx(str, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1504 call assert_equal(2, utf16idx(str, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1505 call assert_equal(2, utf16idx(str, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1506 call assert_equal(2, utf16idx(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1507 call assert_equal(2, utf16idx(str, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1508 call assert_equal(4, utf16idx(str, 5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1509 call assert_equal(4, utf16idx(str, 6)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1510 call assert_equal(4, utf16idx(str, 7)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1511 call assert_equal(4, utf16idx(str, 8)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1512 call assert_equal(5, utf16idx(str, 9)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1513 call assert_equal(-1, utf16idx(str, 10)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1514 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1515 " UTF-16 index of a string with composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1516 let str = '-á-b́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1517 call assert_equal(0, utf16idx(str, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1518 call assert_equal(1, utf16idx(str, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1519 call assert_equal(1, utf16idx(str, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1520 call assert_equal(1, utf16idx(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1521 call assert_equal(2, utf16idx(str, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1522 call assert_equal(3, utf16idx(str, 5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1523 call assert_equal(3, utf16idx(str, 6)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1524 call assert_equal(3, utf16idx(str, 7)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1525 call assert_equal(-1, utf16idx(str, 8)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1526 call assert_equal(0, utf16idx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1527 call assert_equal(1, utf16idx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1528 call assert_equal(2, utf16idx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1529 call assert_equal(2, utf16idx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1530 call assert_equal(3, utf16idx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1531 call assert_equal(4, utf16idx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1532 call assert_equal(5, utf16idx(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1533 call assert_equal(5, utf16idx(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1534 call assert_equal(-1, utf16idx(str, 8, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1535 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1536 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1537 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1538 call assert_equal(0, utf16idx(str, 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1539 call assert_equal(1, utf16idx(str, 1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1540 call assert_equal(1, utf16idx(str, 2)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1541 call assert_equal(1, utf16idx(str, 3)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1542 call assert_equal(1, utf16idx(str, 4)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1543 call assert_equal(1, utf16idx(str, 5)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1544 call assert_equal(2, utf16idx(str, 6)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1545 call assert_equal(3, utf16idx(str, 7)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1546 call assert_equal(3, utf16idx(str, 8)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1547 call assert_equal(3, utf16idx(str, 9)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1548 call assert_equal(3, utf16idx(str, 10)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1549 call assert_equal(3, utf16idx(str, 11)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1550 call assert_equal(-1, utf16idx(str, 12)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1551 call assert_equal(0, utf16idx(str, 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1552 call assert_equal(1, utf16idx(str, 1, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1553 call assert_equal(2, utf16idx(str, 2, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1554 call assert_equal(2, utf16idx(str, 3, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1555 call assert_equal(3, utf16idx(str, 4, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1556 call assert_equal(3, utf16idx(str, 5, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1557 call assert_equal(4, utf16idx(str, 6, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1558 call assert_equal(5, utf16idx(str, 7, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1559 call assert_equal(6, utf16idx(str, 8, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1560 call assert_equal(6, utf16idx(str, 9, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1561 call assert_equal(7, utf16idx(str, 10, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1562 call assert_equal(7, utf16idx(str, 11, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1563 call assert_equal(-1, utf16idx(str, 12, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1564 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1565 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1566 call assert_equal(-1, utf16idx('', 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1567 call assert_equal(-1, utf16idx('', 0, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1568 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1569 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1570 call assert_equal(-1, utf16idx("", 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1571 call assert_equal(-1, utf16idx("abc", -1)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1572 call assert_equal(-1, utf16idx(test_null_string(), 0)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1573 call assert_fails('let l = utf16idx([], 0)', 'E1174:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1574 call assert_fails('let l = utf16idx("ab", [])', 'E1210:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1575 call assert_fails('let l = utf16idx("ab", 0, [])', 'E1212:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1576 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1577 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1578 " Test for utf16idx() using a character index |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1579 func Test_utf16idx_from_charidx() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1580 let str = "abc" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1581 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1582 call assert_equal(i, utf16idx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1583 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1584 call assert_equal(-1, utf16idx(str, 3, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1585 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1586 " UTF-16 index of a string with two byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1587 let str = "a©©b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1588 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1589 call assert_equal(i, utf16idx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1590 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1591 call assert_equal(-1, utf16idx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1592 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1593 " UTF-16 index of a string with four byte characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1594 let str = "a😊😊b" |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1595 call assert_equal(0, utf16idx(str, 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1596 call assert_equal(2, utf16idx(str, 1, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1597 call assert_equal(4, utf16idx(str, 2, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1598 call assert_equal(5, utf16idx(str, 3, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1599 call assert_equal(-1, utf16idx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1600 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1601 " UTF-16 index of a string with composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1602 let str = '-á-b́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1603 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1604 call assert_equal(i, utf16idx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1605 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1606 call assert_equal(-1, utf16idx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1607 for i in str->strchars()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1608 call assert_equal(i, utf16idx(str, i, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1609 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1610 call assert_equal(-1, utf16idx(str, 6, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1611 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1612 " string with multiple composing characters |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1613 let str = '-ą́-ą́' |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1614 for i in str->strcharlen()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1615 call assert_equal(i, utf16idx(str, i, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1616 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1617 call assert_equal(-1, utf16idx(str, 4, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1618 for i in str->strchars()->range() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1619 call assert_equal(i, utf16idx(str, i, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1620 endfor |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1621 call assert_equal(-1, utf16idx(str, 8, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1622 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1623 " empty string |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1624 call assert_equal(-1, utf16idx('', 0, v:false, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1625 call assert_equal(-1, utf16idx('', 0, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1626 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1627 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1628 call assert_equal(-1, utf16idx(test_null_string(), 0, v:true, v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1629 call assert_fails('let l = utf16idx("ab", 0, v:false, [])', 'E1212:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1630 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1631 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1632 " Test for strutf16len() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1633 func Test_strutf16len() |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1634 call assert_equal(3, strutf16len('abc')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1635 call assert_equal(3, 'abc'->strutf16len(v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1636 call assert_equal(4, strutf16len('a©©b')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1637 call assert_equal(4, strutf16len('a©©b', v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1638 call assert_equal(6, strutf16len('a😊😊b')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1639 call assert_equal(6, strutf16len('a😊😊b', v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1640 call assert_equal(4, strutf16len('-á-b́')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1641 call assert_equal(6, strutf16len('-á-b́', v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1642 call assert_equal(4, strutf16len('-ą́-ą́')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1643 call assert_equal(8, strutf16len('-ą́-ą́', v:true)) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1644 call assert_equal(0, strutf16len('')) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1645 |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1646 " error cases |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1647 call assert_fails('let l = strutf16len([])', 'E1174:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1648 call assert_fails('let l = strutf16len("a", [])', 'E1212:') |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1649 call assert_equal(0, strutf16len(test_null_string())) |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1650 endfunc |
8d6f53a07ffd
patch 9.0.1485: no functions for converting from/to UTF-16 index
Bram Moolenaar <Bram@vim.org>
parents:
31890
diff
changeset
|
1651 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1652 func Test_count() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 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
|
1658 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1664 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
|
1665 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
|
1666 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
|
1667 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
|
1668 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
|
1669 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1670 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
|
1671 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
|
1672 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
|
1673 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
|
1674 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1675 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
|
1676 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
|
1677 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
|
1678 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
|
1679 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
|
1680 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1681 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
|
1682 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
|
1683 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
|
1684 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
|
1685 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1686 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
|
1687 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
|
1688 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
|
1689 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
|
1690 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
|
1691 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1692 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
|
1693 |
5a07a3ff56c1
patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents:
11484
diff
changeset
|
1694 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
|
1695 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
|
1696 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
|
1697 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
|
1698 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
|
1699 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
|
1700 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
|
1701 |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
1702 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
|
1703 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1704 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1705 func Test_changenr() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1706 new Xchangenr |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1707 call assert_equal(0, changenr()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1708 norm ifoo |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1709 call assert_equal(1, changenr()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1710 set undolevels=10 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1711 norm Sbar |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1712 call assert_equal(2, changenr()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1713 undo |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1714 call assert_equal(1, changenr()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1715 redo |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1716 call assert_equal(2, changenr()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1717 bw! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1718 set undolevels& |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1719 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1720 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1721 func Test_filewritable() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1722 new Xfilewritable |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1723 write! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1724 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
|
1725 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1726 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
|
1727 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
|
1728 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1729 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
|
1730 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
|
1731 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1732 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
|
1733 |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
1734 call mkdir('Xwritedir', 'D') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
1735 call assert_equal(2, filewritable('Xwritedir')) |
20313
244eb8d8d100
patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
1736 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1737 call delete('Xfilewritable') |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1738 bw! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1739 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1740 |
14883
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1741 func Test_Executable() |
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1742 if has('win32') |
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1743 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
|
1744 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
|
1745 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
|
1746 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
|
1747 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
|
1748 |
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1749 " 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
|
1750 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
|
1751 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
|
1752 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
|
1753 new |
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1754 " 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
|
1755 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
|
1756 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
|
1757 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
|
1758 bwipe |
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1759 |
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1760 " create "notepad.bat" |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
1761 call mkdir('Xnotedir') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
1762 let notepadbat = fnamemodify('Xnotedir/notepad.bat', ':p') |
20593
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1763 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
|
1764 new |
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1765 " check that the path and the pathext order is valid |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
1766 lcd Xnotedir |
20593
89b0f161e6a6
patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
1767 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
|
1768 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
|
1769 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
|
1770 bwipe |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
1771 eval 'Xnotedir'->delete('rf') |
14883
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1772 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
|
1773 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
|
1774 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
|
1775 |
f1fd0b0b335c
patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents:
17278
diff
changeset
|
1776 " 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
|
1777 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
|
1778 new |
17849
73ddc462979d
patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17837
diff
changeset
|
1779 " 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
|
1780 lcd / |
f1fd0b0b335c
patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents:
17278
diff
changeset
|
1781 call assert_equal(1, executable(catcmd)) |
23432
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1782 let result = catcmd->exepath() |
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1783 " when using chroot looking for sbin/cat can return bin/cat, that is OK |
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1784 if catcmd =~ '\<sbin\>' && result =~ '\<bin\>' |
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1785 call assert_equal('/' .. substitute(catcmd, '\<sbin\>', 'bin', ''), result) |
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1786 else |
25439
01feec4a221d
patch 8.2.3256: executable test may fail on new Ubuntu system
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
1787 " /bin/cat and /usr/bin/cat may be hard linked, we could get either |
01feec4a221d
patch 8.2.3256: executable test may fail on new Ubuntu system
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
1788 let result = substitute(result, '/usr/bin/cat', '/bin/cat', '') |
01feec4a221d
patch 8.2.3256: executable test may fail on new Ubuntu system
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
1789 let catcmd = substitute(catcmd, 'usr/bin/cat', 'bin/cat', '') |
23432
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1790 call assert_equal('/' .. catcmd, result) |
a8602bad9e9a
patch 8.2.2259: Test_Executable() fails when using chroot
Bram Moolenaar <Bram@vim.org>
parents:
23380
diff
changeset
|
1791 endif |
17484
f1fd0b0b335c
patch 8.1.1740: exepath() doesn't work for "bin/cat"
Bram Moolenaar <Bram@vim.org>
parents:
17278
diff
changeset
|
1792 bwipe |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
1793 else |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
1794 throw 'Skipped: does not work on this platform' |
14883
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1795 endif |
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1796 endfunc |
1c2ba2b0227e
patch 8.1.0453: MS-Windows: executable() is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
14669
diff
changeset
|
1797 |
28702
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1798 func Test_executable_windows_store_apps() |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1799 CheckMSWindows |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1800 |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1801 " Windows Store apps install some 'decoy' .exe that require some careful |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1802 " handling as they behave similarly to symlinks. |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1803 let app_dir = expand("$LOCALAPPDATA\\Microsoft\\WindowsApps") |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1804 if !isdirectory(app_dir) |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1805 return |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1806 endif |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1807 |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1808 let save_path = $PATH |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1809 let $PATH = app_dir |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1810 " Ensure executable() finds all the app .exes |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1811 for entry in readdir(app_dir) |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1812 if entry =~ '\.exe$' |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1813 call assert_true(executable(entry)) |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1814 endif |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1815 endfor |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1816 |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1817 let $PATH = save_path |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1818 endfunc |
99729fe344f7
patch 8.2.4875: MS-Windows: some .exe files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28672
diff
changeset
|
1819 |
16180
1eaaa82ececf
patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents:
16144
diff
changeset
|
1820 func Test_executable_longname() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
1821 CheckMSWindows |
16180
1eaaa82ececf
patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents:
16144
diff
changeset
|
1822 |
22977
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1823 " Create a temporary .bat file with 205 characters in the name. |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1824 " Maximum length of a filename (including the path) on MS-Windows is 259 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1825 " characters. |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1826 " See https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1827 let len = 259 - getcwd()->len() - 6 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1828 if len > 200 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1829 let len = 200 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1830 endif |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1831 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22568
diff
changeset
|
1832 let fname = 'X' . repeat('あ', len) . '.bat' |
16180
1eaaa82ececf
patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents:
16144
diff
changeset
|
1833 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
|
1834 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
|
1835 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
|
1836 endfunc |
1eaaa82ececf
patch 8.1.1095: MS-Windows: executable() fails on very long filename
Bram Moolenaar <Bram@vim.org>
parents:
16144
diff
changeset
|
1837 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1838 func Test_hostname() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1839 let hostname_vim = hostname() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1840 if has('unix') |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1841 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
|
1842 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
|
1843 endif |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1844 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1845 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1846 func Test_getpid() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1847 " 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
|
1848 call assert_equal(getpid(), getpid()) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1849 if has('unix') |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1850 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
|
1851 endif |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1852 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1853 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1854 func Test_hlexists() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1855 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
|
1856 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
|
1857 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
|
1858 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
|
1859 syntax on |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1860 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
|
1861 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
|
1862 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
|
1863 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
|
1864 syntax off |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1865 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1866 |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1867 " 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
|
1868 func Test_col() |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1869 new |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1870 call setline(1, 'abcdef') |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1871 norm gg4|mx6|mY2| |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1872 call assert_equal(2, col('.')) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1873 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
|
1874 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
|
1875 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
|
1876 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
|
1877 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
|
1878 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
|
1879 |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1880 call assert_equal(0, col('')) |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1881 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
|
1882 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
|
1883 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
|
1884 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
|
1885 call assert_equal(0, col(test_null_list())) |
31057
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1886 call assert_fails('let c = col({})', 'E1222:') |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1887 call assert_fails('let c = col(".", [])', 'E1210:') |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1888 |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1889 " 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
|
1890 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
|
1891 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
|
1892 return '' |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1893 endfunc |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1894 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
|
1895 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
|
1896 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
|
1897 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
|
1898 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
|
1899 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
|
1900 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1901 " 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
|
1902 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
|
1903 "normal! ggVG |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1904 call feedkeys("ggVG\<Esc>", 'xt') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1905 call assert_equal(1, col("'<")) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1906 call assert_equal(14, col("'>")) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1907 " 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
|
1908 $d |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1909 call assert_notequal(14, col("'>")) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1910 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1911 " Test with 'virtualedit' |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1912 set virtualedit=all |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1913 call cursor(1, 10) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1914 call assert_equal(4, col('.')) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1915 set virtualedit& |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
1916 |
31057
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1917 " Test for getting the column number in another window |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1918 let winid = win_getid() |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1919 new |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1920 call win_execute(winid, 'normal 1G$') |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1921 call assert_equal(3, col('.', winid)) |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1922 call win_execute(winid, 'normal 2G') |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1923 call assert_equal(8, col('$', winid)) |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1924 call assert_equal(0, col('.', 5001)) |
1a32f1a4f823
patch 9.0.0863: col() and charcol() only work for the current window
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
1925 |
11095
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1926 bw! |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1927 endfunc |
5763281d212a
patch 8.0.0435: some functions are not tested
Christian Brabandt <cb@256bit.org>
parents:
11024
diff
changeset
|
1928 |
19517
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1929 " 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
|
1930 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
|
1931 " 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
|
1932 redir => v |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1933 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
|
1934 redir END |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1935 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
|
1936 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
|
1937 |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1938 " 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
|
1939 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
|
1940 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
|
1941 |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1942 " 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
|
1943 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
|
1944 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
|
1945 endfunc |
21552
cbc570e66d11
patch 8.2.1326: Vim9: skipping over white space after list
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1946 call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\<CR>" |
19517
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1947 \ .. "\<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
|
1948 delfunc Tcomplete |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1949 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
|
1950 |
24134
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1951 " Test for using special characters as default input |
24204
ec71c859e94c
patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24134
diff
changeset
|
1952 call feedkeys(":let c = input('name? ', \"x\\<BS>y\")\<CR>\<CR>", 'xt') |
24134
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1953 call assert_equal('y', c) |
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1954 |
29073
c7bd1040a1c4
patch 8.2.5058: input() does not handle composing characters properly
Bram Moolenaar <Bram@vim.org>
parents:
28994
diff
changeset
|
1955 " Test for using text with composing characters as default input |
c7bd1040a1c4
patch 8.2.5058: input() does not handle composing characters properly
Bram Moolenaar <Bram@vim.org>
parents:
28994
diff
changeset
|
1956 call feedkeys(":let c = input('name? ', \"ã̳\")\<CR>\<CR>", 'xt') |
c7bd1040a1c4
patch 8.2.5058: input() does not handle composing characters properly
Bram Moolenaar <Bram@vim.org>
parents:
28994
diff
changeset
|
1957 call assert_equal('ã̳', c) |
c7bd1040a1c4
patch 8.2.5058: input() does not handle composing characters properly
Bram Moolenaar <Bram@vim.org>
parents:
28994
diff
changeset
|
1958 |
24134
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1959 " Test for using <CR> as default input |
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1960 call feedkeys(":let c = input('name? ', \"\\<CR>\")\<CR>x\<CR>", 'xt') |
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1961 call assert_equal(' x', c) |
72e9b861bc92
patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
23849
diff
changeset
|
1962 |
19536
bab20768e1fd
patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19517
diff
changeset
|
1963 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
|
1964 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
|
1965 endfunc |
bab20768e1fd
patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19517
diff
changeset
|
1966 |
bab20768e1fd
patch 8.2.0325: ex_getln.c code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19517
diff
changeset
|
1967 " 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
|
1968 func Test_inputdialog() |
20867
9c24319b4cb2
patch 8.2.0985: simplify() does not remove slashes from "///path"
Bram Moolenaar <Bram@vim.org>
parents:
20794
diff
changeset
|
1969 set timeout timeoutlen=10 |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1970 if has('gui_running') |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1971 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
|
1972 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
|
1973 else |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
1978 endif |
20867
9c24319b4cb2
patch 8.2.0985: simplify() does not remove slashes from "///path"
Bram Moolenaar <Bram@vim.org>
parents:
20794
diff
changeset
|
1979 set timeout& timeoutlen& |
19517
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1980 endfunc |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1981 |
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
1982 " Test for inputlist() |
14379
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
1983 func Test_inputlist() |
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
1984 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
|
1985 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
|
1986 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
|
1987 call assert_equal(2, c) |
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
1988 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
|
1989 call assert_equal(3, c) |
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
1990 |
20788
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1991 " CR to cancel |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1992 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<cr>", 'tx') |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1993 call assert_equal(0, c) |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1994 |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1995 " Esc to cancel |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1996 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<Esc>", 'tx') |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1997 call assert_equal(0, c) |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1998 |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
1999 " q to cancel |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
2000 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>q", 'tx') |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
2001 call assert_equal(0, c) |
072ad890c227
patch 8.2.0946: cannot use "q" to cancel a number prompt
Bram Moolenaar <Bram@vim.org>
parents:
20669
diff
changeset
|
2002 |
24673
53fd6370e4fd
patch 8.2.2875: cancelling inputlist() after a digit does not return zero
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
2003 " Cancel after inputting a number |
53fd6370e4fd
patch 8.2.2875: cancelling inputlist() after a digit does not return zero
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
2004 call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>5q", 'tx') |
53fd6370e4fd
patch 8.2.2875: cancelling inputlist() after a digit does not return zero
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
2005 call assert_equal(0, c) |
53fd6370e4fd
patch 8.2.2875: cancelling inputlist() after a digit does not return zero
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
2006 |
19906
031184ace7c5
patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents:
19902
diff
changeset
|
2007 " 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
|
2008 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
|
2009 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
|
2010 |
031184ace7c5
patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents:
19902
diff
changeset
|
2011 " 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
|
2012 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
|
2013 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
|
2014 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
|
2015 " 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
|
2016 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
|
2017 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
|
2018 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
|
2019 |
14379
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
2020 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
|
2021 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
|
2022 endfunc |
0f1446193ded
patch 8.1.0204: inputlist() is not tested
Christian Brabandt <cb@256bit.org>
parents:
14348
diff
changeset
|
2023 |
31594
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2024 func Test_range_inputlist() |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2025 " flush out any garbage left in the buffer |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2026 while getchar(0) |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2027 endwhile |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2028 |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2029 call feedkeys(":let result = inputlist(range(10))\<CR>1\<CR>", 'x') |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2030 call assert_equal(1, result) |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2031 call feedkeys(":let result = inputlist(range(3, 10))\<CR>1\<CR>", 'x') |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2032 call assert_equal(1, result) |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2033 |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2034 unlet result |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2035 endfunc |
db09821e1372
patch 9.0.1129: sporadic Test_range() failure
Bram Moolenaar <Bram@vim.org>
parents:
31093
diff
changeset
|
2036 |
11020
50f3e37bc210
patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents:
10891
diff
changeset
|
2037 func Test_balloon_show() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2038 CheckFeature balloon_eval |
24448
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
2039 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2040 " This won't do anything but must not crash either. |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2041 call balloon_show('hi!') |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2042 if !has('gui_running') |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2043 call balloon_show(range(3)) |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2044 call balloon_show([]) |
11024
973fa964cb91
patch 8.0.0401: test fails with missing balloon feature
Christian Brabandt <cb@256bit.org>
parents:
11020
diff
changeset
|
2045 endif |
11020
50f3e37bc210
patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents:
10891
diff
changeset
|
2046 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
|
2047 |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2048 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
|
2049 " This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the |
31890
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2050 " window layout and cursor position. |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 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
|
2056 |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2057 wincmd j |
22083
c67a9d3b3683
patch 8.2.1591: using winheight('.') in tests works but is wrong
Bram Moolenaar <Bram@vim.org>
parents:
21973
diff
changeset
|
2058 let wh = winheight(0) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2059 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
|
2060 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
|
2061 execute 'belowright vertical split #' . dummy_buf |
22083
c67a9d3b3683
patch 8.2.1591: using winheight('.') in tests works but is wrong
Bram Moolenaar <Bram@vim.org>
parents:
21973
diff
changeset
|
2062 call assert_equal(wh, winheight(0)) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2063 let dum1_id = win_getid() |
31890
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2064 call setline(1, 'foo') |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2065 normal! V$ |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2066 call assert_equal(4, col('.')) |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2067 call setbufvar('dummy_preview', '&buftype', 'nofile') |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2068 call assert_equal(4, col('.')) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2069 |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2070 wincmd h |
22083
c67a9d3b3683
patch 8.2.1591: using winheight('.') in tests works but is wrong
Bram Moolenaar <Bram@vim.org>
parents:
21973
diff
changeset
|
2071 let wh = winheight(0) |
31890
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2072 call setline(1, 'foo') |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2073 normal! V$ |
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2074 call assert_equal(4, col('.')) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2075 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
|
2076 eval 'nofile'->setbufvar(dummy_buf, '&buftype') |
31890
2d96d7f9da7e
patch 9.0.1277: cursor may move with autocmd in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
31594
diff
changeset
|
2077 call assert_equal(4, col('.')) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2078 execute 'belowright vertical split #' . dummy_buf |
22083
c67a9d3b3683
patch 8.2.1591: using winheight('.') in tests works but is wrong
Bram Moolenaar <Bram@vim.org>
parents:
21973
diff
changeset
|
2079 call assert_equal(wh, winheight(0)) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2080 |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2081 bwipe! |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2082 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
|
2083 bwipe! |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2084 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
|
2085 bwipe! |
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11135
diff
changeset
|
2086 endfunc |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2087 |
27360
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2088 func Test_setbufvar_keep_window_title() |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2089 CheckRunVimInTerminal |
27364
3834b8385025
patch 8.2.4210: window title test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
27360
diff
changeset
|
2090 if !has('title') || empty(&t_ts) |
3834b8385025
patch 8.2.4210: window title test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
27360
diff
changeset
|
2091 throw "Skipped: can't get/set title" |
3834b8385025
patch 8.2.4210: window title test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
27360
diff
changeset
|
2092 endif |
27360
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2093 |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2094 let lines =<< trim END |
27368
7ec64e4539af
patch 8.2.4212: window title test still fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
27366
diff
changeset
|
2095 set title |
27360
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2096 edit Xa.txt |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2097 let g:buf = bufadd('Xb.txt') |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2098 inoremap <F2> <C-R>=setbufvar(g:buf, '&autoindent', 1) ?? ''<CR> |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2099 END |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2100 call writefile(lines, 'Xsetbufvar', 'D') |
27360
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2101 let buf = RunVimInTerminal('-S Xsetbufvar', {}) |
27366
66046931fa58
patch 8.2.4211: window title test still fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
27364
diff
changeset
|
2102 call WaitForAssert({-> assert_match('Xa.txt', term_gettitle(buf))}, 1000) |
27360
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2103 |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2104 call term_sendkeys(buf, "i\<F2>") |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2105 call TermWait(buf) |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2106 call term_sendkeys(buf, "\<Esc>") |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2107 call TermWait(buf) |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2108 call assert_match('Xa.txt', term_gettitle(buf)) |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2109 |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2110 call StopVimInTerminal(buf) |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2111 endfunc |
dfaba853a792
patch 8.2.4208: using setbufvar() may change the window title
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
2112 |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2113 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
|
2114 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
|
2115 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
|
2116 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
|
2117 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
|
2118 endfunction |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2119 |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2120 function! Apply() |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2121 5,6normal! . |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2122 endfunction |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2123 |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2124 new |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2125 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
|
2126 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
|
2127 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
|
2128 3,4normal . |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2129 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
|
2130 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
|
2131 call Apply() |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2132 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
|
2133 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
|
2134 bwipe! |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2135 |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2136 nunmap g. |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2137 delfunc Operator |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2138 delfunc Apply |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11197
diff
changeset
|
2139 endfunc |
11484
3933a3bf9385
patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
2140 |
13513
4064f342bea4
patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents:
13092
diff
changeset
|
2141 func Test_trim() |
4064f342bea4
patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents:
13092
diff
changeset
|
2142 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
|
2143 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
|
2144 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
|
2145 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
|
2146 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
|
2147 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
|
2148 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
|
2149 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
|
2150 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
|
2151 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
|
2152 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
|
2153 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
|
2154 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
|
2155 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
|
2156 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
|
2157 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
|
2158 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
|
2159 |
20629
7b8ac5e49451
patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents:
20593
diff
changeset
|
2160 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
|
2161 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
|
2162 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
|
2163 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
|
2164 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
|
2165 call assert_fails('eval trim(" vim ", " ", 3)', 'E475:') |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
2166 call assert_fails('eval trim(" vim ", 0)', 'E1174:') |
20629
7b8ac5e49451
patch 8.2.0868: trim() always trims both ends
Bram Moolenaar <Bram@vim.org>
parents:
20593
diff
changeset
|
2167 |
17976
6d11a0d5751d
patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17952
diff
changeset
|
2168 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
|
2169 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
|
2170 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
2171 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
|
2172 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
|
2173 |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2174 " 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
|
2175 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
|
2176 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
|
2177 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
|
2178 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
|
2179 return '' |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2180 endfunc |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2181 |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2182 new |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2183 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
|
2184 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
|
2185 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
|
2186 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
|
2187 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
|
2188 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
|
2189 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
|
2190 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
|
2191 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
|
2192 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
|
2193 |
15973
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15774
diff
changeset
|
2194 " :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
|
2195 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
|
2196 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
|
2197 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
|
2198 normal! ia |
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15774
diff
changeset
|
2199 endfunc |
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15774
diff
changeset
|
2200 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
|
2201 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
|
2202 delfunc TestFunc |
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15774
diff
changeset
|
2203 |
15979
72987a858c96
patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
2204 " 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
|
2205 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
|
2206 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
|
2207 let g:typed = '' |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2208 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
|
2209 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
|
2210 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
|
2211 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
|
2212 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
|
2213 endfunc |
72987a858c96
patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
2214 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
|
2215 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
|
2216 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
|
2217 delfunc TestFunc |
72987a858c96
patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
2218 unmap W |
72987a858c96
patch 8.1.0995: a getchar() call resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
2219 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
|
2220 unlet g:regs |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2221 |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2222 " 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
|
2223 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
|
2224 let @q = "W" |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2225 let g:typed = '' |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2226 let g:regs = [] |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2227 func TestFunc() abort |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2228 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
|
2229 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
|
2230 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
|
2231 endfunc |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2232 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
|
2233 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
|
2234 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
|
2235 delfunc TestFunc |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2236 unmap W |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2237 unlet g:typed |
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15979
diff
changeset
|
2238 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
|
2239 |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2240 bwipe! |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13980
diff
changeset
|
2241 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
|
2242 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
|
2243 endfunc |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2244 |
17914
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17871
diff
changeset
|
2245 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
|
2246 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
|
2247 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
|
2248 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
|
2249 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
|
2250 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
|
2251 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
|
2252 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
|
2253 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
|
2254 endfunc |
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17871
diff
changeset
|
2255 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
|
2256 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
|
2257 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
|
2258 delfunc TestFunc |
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17871
diff
changeset
|
2259 unmap W |
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17871
diff
changeset
|
2260 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
|
2261 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
|
2262 endfunc |
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17871
diff
changeset
|
2263 |
17952
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2264 func Test_getchar() |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2265 call feedkeys('a', '') |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2266 call assert_equal(char2nr('a'), getchar()) |
24838
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2267 call assert_equal(0, getchar(0)) |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2268 call assert_equal(0, getchar(1)) |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2269 |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2270 call feedkeys('a', '') |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2271 call assert_equal('a', getcharstr()) |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2272 call assert_equal('', getcharstr(0)) |
3f9053c21765
patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
2273 call assert_equal('', getcharstr(1)) |
17952
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2274 |
27802
9b01fea87065
patch 8.2.4427: getchar() may return modifiers if no character is available
Bram Moolenaar <Bram@vim.org>
parents:
27671
diff
changeset
|
2275 call feedkeys("\<M-F2>", '') |
9b01fea87065
patch 8.2.4427: getchar() may return modifiers if no character is available
Bram Moolenaar <Bram@vim.org>
parents:
27671
diff
changeset
|
2276 call assert_equal("\<M-F2>", getchar(0)) |
9b01fea87065
patch 8.2.4427: getchar() may return modifiers if no character is available
Bram Moolenaar <Bram@vim.org>
parents:
27671
diff
changeset
|
2277 call assert_equal(0, getchar(0)) |
9b01fea87065
patch 8.2.4427: getchar() may return modifiers if no character is available
Bram Moolenaar <Bram@vim.org>
parents:
27671
diff
changeset
|
2278 |
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
|
2279 call setline(1, 'xxxx') |
17952
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2280 call test_setmouse(1, 3) |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2281 let v:mouse_win = 9 |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2282 let v:mouse_winid = 9 |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2283 let v:mouse_lnum = 9 |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2284 let v:mouse_col = 9 |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2285 call feedkeys("\<S-LeftMouse>", '') |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2286 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
|
2287 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
|
2288 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
|
2289 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
|
2290 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
|
2291 enew! |
17952
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2292 endfunc |
4754339d9aee
patch 8.1.1972: no proper test for getchar()
Bram Moolenaar <Bram@vim.org>
parents:
17944
diff
changeset
|
2293 |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2294 func Test_libcall_libcallnr() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21552
diff
changeset
|
2295 CheckFeature libcall |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2296 |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2297 if has('win32') |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2298 let libc = 'msvcrt.dll' |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2299 elseif has('mac') |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2300 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
|
2301 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
|
2302 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
|
2303 endif |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2304 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
|
2305 " 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
|
2306 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
|
2307 " 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
|
2308 " 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
|
2309 " 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
|
2310 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
|
2311 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
|
2312 " 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
|
2313 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
|
2314 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
|
2315 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
|
2316 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
|
2317 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
|
2318 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
|
2319 else |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2320 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
|
2321 endif |
14669
63d5ae57a663
patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents:
14579
diff
changeset
|
2322 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
|
2323 " 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
|
2324 return |
14669
63d5ae57a663
patch 8.1.0347: some tests fail on Solaris
Christian Brabandt <cb@256bit.org>
parents:
14579
diff
changeset
|
2325 endif |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2326 endif |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2327 |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2328 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
|
2329 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
|
2330 else |
17916
2e53305f2239
patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
2331 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
|
2332 endif |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2333 |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2334 " 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
|
2335 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
|
2336 |
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2337 " 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
|
2338 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
|
2339 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
|
2340 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
2341 call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", ['', 'E364:']) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
2342 call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", ['', 'E364:']) |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2343 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
2344 call assert_fails("call libcall('Xdoesnotexist_', 'getenv', 'HOME')", ['', 'E364:']) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
2345 call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", ['', 'E364:']) |
14137
0d534adbcc2f
patch 8.1.0086: no tests for libcall() and libcallnr()
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2346 endfunc |
14348
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2347 |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2348 sandbox function Fsandbox() |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2349 normal ix |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2350 endfunc |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2351 |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2352 func Test_func_sandbox() |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2353 sandbox let F = {-> 'hello'} |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2354 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
|
2355 |
17849
73ddc462979d
patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17837
diff
changeset
|
2356 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
|
2357 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
|
2358 unlet F |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2359 |
e73c0a0e7e87
patch 8.1.0189: function defined in sandbox not tested
Christian Brabandt <cb@256bit.org>
parents:
14137
diff
changeset
|
2360 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
|
2361 delfunc Fsandbox |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19554
diff
changeset
|
2362 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19554
diff
changeset
|
2363 " 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
|
2364 " from a sandbox) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19554
diff
changeset
|
2365 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
|
2366 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
|
2367 |
32787e326de2
patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents:
14895
diff
changeset
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 |
32787e326de2
patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents:
14895
diff
changeset
|
2373 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
|
2374 " 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
|
2375 " is invalid in that buffer. |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2376 call writefile(['just one line'], 'Xfuncrange2', 'D') |
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
|
2377 new |
17994
0dcc2ee838dd
patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17982
diff
changeset
|
2378 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
|
2379 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
|
2380 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
|
2381 |
32787e326de2
patch 8.1.0511: ml_get error when calling a function with a range
Bram Moolenaar <Bram@vim.org>
parents:
14895
diff
changeset
|
2382 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
|
2383 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
|
2384 endfunc |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2385 |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2386 func Test_func_exists_on_reload() |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2387 call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists', 'D') |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2388 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
|
2389 source Xfuncexists |
17849
73ddc462979d
patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17837
diff
changeset
|
2390 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
|
2391 " 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
|
2392 source Xfuncexists |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2393 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
|
2394 |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2395 " But redefining in another script is not OK. |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2396 call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2', 'D') |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2397 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
|
2398 |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24673
diff
changeset
|
2399 " Defining a new function from the cmdline should fail if the function is |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24673
diff
changeset
|
2400 " already defined |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24673
diff
changeset
|
2401 call assert_fails('call feedkeys(":func ExistingFunction()\<CR>", "xt")', 'E122:') |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24673
diff
changeset
|
2402 |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2403 delfunc ExistingFunction |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2404 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
|
2405 call writefile([ |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2406 \ '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
|
2407 \ '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
|
2408 \ ], 'Xfuncexists') |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2409 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
|
2410 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
|
2411 |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2412 delfunc ExistingFunction |
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
15000
diff
changeset
|
2413 endfunc |
15649
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2414 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2415 " Test confirm({msg} [, {choices} [, {default} [, {type}]]]) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2416 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
|
2417 CheckUnix |
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17484
diff
changeset
|
2418 CheckNotGui |
15649
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2419 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2420 call feedkeys('o', 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2421 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
|
2422 call assert_equal(1, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2423 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2424 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
|
2425 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
|
2426 call assert_equal(1, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2427 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2428 call feedkeys('n', 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2429 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
|
2430 call assert_equal(2, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2431 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2432 " 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
|
2433 call feedkeys("\<C-C>", 'L') |
15649
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2434 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
|
2435 call assert_equal(0, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2436 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2437 " <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
|
2438 " 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
|
2439 eval "\<Esc>0"->feedkeys('L') |
15649
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2440 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
|
2441 call assert_equal(0, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2442 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2443 " 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
|
2444 call feedkeys("\<CR>", 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2445 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
|
2446 call assert_equal(1, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2447 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2448 call feedkeys("\<CR>", 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2449 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
|
2450 call assert_equal(2, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2451 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2452 call feedkeys("\<CR>", 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2453 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
|
2454 call assert_equal(0, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2455 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2456 " Test with the {type} 4th argument |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2457 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
|
2458 call feedkeys('y', 'L') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2459 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
|
2460 call assert_equal(1, a) |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2461 endfor |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2462 |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2463 call assert_fails('call confirm([])', 'E730:') |
e649df212461
patch 8.1.0832: confirm() is not tested
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
2464 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
|
2465 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
|
2466 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
|
2467 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
|
2468 |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2469 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
|
2470 " 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
|
2471 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
|
2472 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
|
2473 |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2474 " 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
|
2475 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
|
2476 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
|
2477 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
|
2478 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
|
2479 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
|
2480 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
|
2481 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
|
2482 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
|
2483 |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2484 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
|
2485 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
|
2486 " 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
|
2487 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
|
2488 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
|
2489 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
|
2490 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
|
2491 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
|
2492 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
|
2493 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
|
2494 endif |
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15649
diff
changeset
|
2495 endfunc |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2496 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2497 func Test_readdir() |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2498 call mkdir('Xreaddir', 'R') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2499 call writefile([], 'Xreaddir/foo.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2500 call writefile([], 'Xreaddir/bar.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2501 call mkdir('Xreaddir/dir') |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2502 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2503 " All results |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2504 let files = readdir('Xreaddir') |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2505 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
|
2506 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2507 " Only results containing "f" |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2508 let files = 'Xreaddir'->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
|
2509 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
|
2510 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2511 " Only .txt files |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2512 let files = readdir('Xreaddir', { x -> x =~ '.txt$' }) |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2513 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
|
2514 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2515 " Only .txt files with string |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2516 let files = readdir('Xreaddir', 'v:val =~ ".txt$"') |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2517 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
|
2518 |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2519 " Limit to 1 result. |
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2520 let l = [] |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2521 let files = readdir('Xreaddir', {x -> len(add(l, x)) == 2 ? -1 : 1}) |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2522 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
|
2523 |
17944
745c02392844
patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
2524 " Nested readdir() must not crash |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2525 let files = readdir('Xreaddir', 'readdir("Xreaddir", "1") != []') |
17944
745c02392844
patch 8.1.1968: crash when using nested map()
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
2526 call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt']) |
16231
0761a4c111a7
patch 8.1.1120: cannot easily get directory entry matches
Bram Moolenaar <Bram@vim.org>
parents:
16180
diff
changeset
|
2527 endfunc |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2528 |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2529 func Test_readdirex() |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2530 call mkdir('Xexdir', 'R') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2531 call writefile(['foo'], 'Xexdir/foo.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2532 call writefile(['barbar'], 'Xexdir/bar.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2533 call mkdir('Xexdir/dir') |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2534 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2535 " All results |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2536 let files = readdirex('Xexdir')->map({-> v:val.name}) |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2537 call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files)) |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2538 let sizes = readdirex('Xexdir')->map({-> v:val.size}) |
20669
2407ffaefc02
patch 8.2.0888: readdirex() returns size -2 for a directory
Bram Moolenaar <Bram@vim.org>
parents:
20665
diff
changeset
|
2539 call assert_equal([0, 4, 7], sort(sizes)) |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2540 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2541 " Only results containing "f" |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2542 let files = 'Xexdir'->readdirex({ e -> stridx(e.name, 'f') != -1 }) |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2543 \ ->map({-> v:val.name}) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2544 call assert_equal(['foo.txt'], sort(files)) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2545 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2546 " Only .txt files |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2547 let files = readdirex('Xexdir', { e -> e.name =~ '.txt$' }) |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2548 \ ->map({-> v:val.name}) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2549 call assert_equal(['bar.txt', 'foo.txt'], sort(files)) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2550 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2551 " Only .txt files with string |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2552 let files = readdirex('Xexdir', 'v:val.name =~ ".txt$"') |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2553 \ ->map({-> v:val.name}) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2554 call assert_equal(['bar.txt', 'foo.txt'], sort(files)) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2555 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2556 " Limit to 1 result. |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2557 let l = [] |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2558 let files = readdirex('Xexdir', {e -> len(add(l, e.name)) == 2 ? -1 : 1}) |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2559 \ ->map({-> v:val.name}) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2560 call assert_equal(1, len(files)) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2561 |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2562 " Nested readdirex() must not crash |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2563 let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []') |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2564 \ ->map({-> v:val.name}) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2565 call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt']) |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2566 |
20867
9c24319b4cb2
patch 8.2.0985: simplify() does not remove slashes from "///path"
Bram Moolenaar <Bram@vim.org>
parents:
20794
diff
changeset
|
2567 " report broken link correctly |
20790
5a9c42c6a69e
patch 8.2.0947: readdirex() doesn't handle broken link properly
Bram Moolenaar <Bram@vim.org>
parents:
20788
diff
changeset
|
2568 if has("unix") |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2569 call writefile([], 'Xexdir/abc.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2570 call system("ln -s Xexdir/abc.txt Xexdir/link") |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2571 call delete('Xexdir/abc.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2572 let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []') |
20790
5a9c42c6a69e
patch 8.2.0947: readdirex() doesn't handle broken link properly
Bram Moolenaar <Bram@vim.org>
parents:
20788
diff
changeset
|
2573 \ ->map({-> v:val.name .. '_' .. v:val.type}) |
5a9c42c6a69e
patch 8.2.0947: readdirex() doesn't handle broken link properly
Bram Moolenaar <Bram@vim.org>
parents:
20788
diff
changeset
|
2574 call sort(files)->assert_equal( |
5a9c42c6a69e
patch 8.2.0947: readdirex() doesn't handle broken link properly
Bram Moolenaar <Bram@vim.org>
parents:
20788
diff
changeset
|
2575 \ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link']) |
5a9c42c6a69e
patch 8.2.0947: readdirex() doesn't handle broken link properly
Bram Moolenaar <Bram@vim.org>
parents:
20788
diff
changeset
|
2576 endif |
22568
fdc72bf4de35
patch 8.2.1832: readdirex() error is displayed as a message
Bram Moolenaar <Bram@vim.org>
parents:
22512
diff
changeset
|
2577 |
fdc72bf4de35
patch 8.2.1832: readdirex() error is displayed as a message
Bram Moolenaar <Bram@vim.org>
parents:
22512
diff
changeset
|
2578 call assert_fails('call readdirex("doesnotexist")', 'E484:') |
20643
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2579 endfunc |
c2beb6baa42c
patch 8.2.0875: getting attributes for directory entries is slow
Bram Moolenaar <Bram@vim.org>
parents:
20629
diff
changeset
|
2580 |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2581 func Test_readdirex_sort() |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2582 CheckUnix |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2583 " Skip tests on Mac OS X and Cygwin (does not allow several files with different casing) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2584 if has("osxdarwin") || has("osx") || has("macunix") || has("win32unix") |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2585 throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem' |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2586 endif |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2587 let _collate = v:collate |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2588 call mkdir('Xsortdir2', 'R') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2589 call writefile(['1'], 'Xsortdir2/README.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2590 call writefile(['2'], 'Xsortdir2/Readme.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2591 call writefile(['3'], 'Xsortdir2/readme.txt') |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2592 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2593 " 1) default |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2594 let files = readdirex('Xsortdir2')->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2595 let default = copy(files) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2596 call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort using default') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2597 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2598 " 2) no sorting |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2599 let files = readdirex('Xsortdir2', 1, #{sort: 'none'})->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2600 let unsorted = copy(files) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2601 call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], sort(files), 'unsorted') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2602 call assert_fails("call readdirex('Xsortdir2', 1, #{slort: 'none'})", 'E857: Dictionary key "sort" required') |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2603 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2604 " 3) sort by case (same as default) |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2605 let files = readdirex('Xsortdir2', 1, #{sort: 'case'})->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2606 call assert_equal(default, files, 'sort by case') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2607 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2608 " 4) sort by ignoring case |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2609 let files = readdirex('Xsortdir2', 1, #{sort: 'icase'})->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2610 call assert_equal(unsorted->sort('i'), files, 'sort by icase') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2611 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2612 " 5) Default Collation |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2613 let collate = v:collate |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2614 lang collate C |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2615 let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2616 call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort by C collation') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2617 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2618 " 6) Collation de_DE |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2619 " Switch locale, this may not work on the CI system, if the locale isn't |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2620 " available |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2621 try |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2622 lang collate de_DE |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2623 let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name}) |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2624 call assert_equal(['readme.txt', 'Readme.txt', 'README.txt'], files, 'sort by de_DE collation') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2625 catch |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2626 throw 'Skipped: de_DE collation is not available' |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2627 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2628 finally |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2629 exe 'lang collate' collate |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2630 endtry |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2631 endfunc |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2632 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2633 func Test_readdir_sort() |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2634 " some more cases for testing sorting for readdirex |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2635 let dir = 'Xsortdir3' |
30552
a7a9e8b9af89
patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
2636 call mkdir(dir, 'R') |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2637 call writefile(['1'], dir .. '/README.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2638 call writefile(['2'], dir .. '/Readm.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2639 call writefile(['3'], dir .. '/read.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2640 call writefile(['4'], dir .. '/Z.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2641 call writefile(['5'], dir .. '/a.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2642 call writefile(['6'], dir .. '/b.txt') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2643 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2644 " 1) default |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2645 let files = readdir(dir) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2646 let default = copy(files) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2647 call assert_equal(default->sort(), files, 'sort using default') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2648 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2649 " 2) sort by case (same as default) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2650 let files = readdir(dir, '1', #{sort: 'case'}) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2651 call assert_equal(default, files, 'sort using default') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2652 |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2653 " 3) sort by ignoring case |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2654 let files = readdir(dir, '1', #{sort: 'icase'}) |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2655 call assert_equal(default->sort('i'), files, 'sort by ignoring case') |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2656 |
20887
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2657 " 4) collation |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2658 let collate = v:collate |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2659 lang collate C |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2660 let files = readdir(dir, 1, #{sort: 'collate'}) |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2661 call assert_equal(default->sort(), files, 'sort by C collation') |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2662 exe "lang collate" collate |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2663 |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2664 " 5) Errors |
30015
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2665 call assert_fails('call readdir(dir, 1, 1)', 'E1206:') |
20887
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2666 call assert_fails('call readdir(dir, 1, #{sorta: 1})') |
30015
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2667 call assert_fails('call readdir(dir, 1, test_null_dict())', 'E1297:') |
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2668 call assert_fails('call readdirex(dir, 1, 1)', 'E1206:') |
20887
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2669 call assert_fails('call readdirex(dir, 1, #{sorta: 1})') |
30015
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2670 call assert_fails('call readdirex(dir, 1, test_null_dict())', 'E1297:') |
20887
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2671 |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2672 " 6) ignore other values in dict |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2673 let files = readdir(dir, '1', #{sort: 'c'}) |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2674 call assert_equal(default, files, 'sort using default2') |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2675 |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2676 " Cleanup |
5dd8e741060b
patch 8.2.0995: insufficient testing for the readdir() sort option
Bram Moolenaar <Bram@vim.org>
parents:
20877
diff
changeset
|
2677 exe "lang collate" collate |
20873
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2678 endfunc |
69055d27e85e
patch 8.2.0988: getting directory contents is always case sorted
Bram Moolenaar <Bram@vim.org>
parents:
20869
diff
changeset
|
2679 |
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
|
2680 func Test_delete_rf() |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2681 call mkdir('Xrfdir') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2682 call writefile([], 'Xrfdir/foo.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2683 call writefile([], 'Xrfdir/bar.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2684 call mkdir('Xrfdir/[a-1]') " issue #696 |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2685 call writefile([], 'Xrfdir/[a-1]/foo.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2686 call writefile([], 'Xrfdir/[a-1]/bar.txt') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2687 call assert_true(filereadable('Xrfdir/foo.txt')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2688 call assert_true('Xrfdir/[a-1]/foo.txt'->filereadable()) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2689 |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2690 call assert_equal(0, delete('Xrfdir', 'rf')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2691 call assert_false(filereadable('Xrfdir/foo.txt')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2692 call assert_false(filereadable('Xrfdir/[a-1]/foo.txt')) |
28341
0390c4848b27
patch 8.2.4696: delete() with "rf" argument does not report a failure
Bram Moolenaar <Bram@vim.org>
parents:
28291
diff
changeset
|
2693 |
0390c4848b27
patch 8.2.4696: delete() with "rf" argument does not report a failure
Bram Moolenaar <Bram@vim.org>
parents:
28291
diff
changeset
|
2694 if has('unix') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2695 call mkdir('Xrfdir/Xdir2', 'p') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2696 silent !chmod 555 Xrfdir |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2697 call assert_equal(-1, delete('Xrfdir/Xdir2', 'rf')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2698 call assert_equal(-1, delete('Xrfdir', 'rf')) |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2699 silent !chmod 755 Xrfdir |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
29875
diff
changeset
|
2700 call assert_equal(0, delete('Xrfdir', 'rf')) |
28341
0390c4848b27
patch 8.2.4696: delete() with "rf" argument does not report a failure
Bram Moolenaar <Bram@vim.org>
parents:
28291
diff
changeset
|
2701 endif |
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
|
2702 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
|
2703 |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2704 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
|
2705 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
|
2706 call assert_equal(3, 'len'->call([123])) |
30015
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2707 call assert_fails("call call('len', 123)", 'E1211:') |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2708 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
|
2709 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
|
2710 |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2711 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
|
2712 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
|
2713 endfunction |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2714 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
|
2715 eval mydict.len->call([], mydict)->assert_equal(4) |
29994
86eb4aba16c3
patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents:
29972
diff
changeset
|
2716 call assert_fails("call call('Mylen', [], 0)", 'E1206:') |
23108
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
23037
diff
changeset
|
2717 call assert_fails('call foo', 'E107:') |
24618
4aebea72c397
patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents:
24596
diff
changeset
|
2718 |
24878
f67773e26cfa
patch 8.2.2977: crash when using a null function reference
Bram Moolenaar <Bram@vim.org>
parents:
24838
diff
changeset
|
2719 " These once caused a crash. |
24618
4aebea72c397
patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents:
24596
diff
changeset
|
2720 call call(test_null_function(), []) |
4aebea72c397
patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents:
24596
diff
changeset
|
2721 call call(test_null_partial(), []) |
24878
f67773e26cfa
patch 8.2.2977: crash when using a null function reference
Bram Moolenaar <Bram@vim.org>
parents:
24838
diff
changeset
|
2722 call assert_fails('call test_null_function()()', 'E1192:') |
f67773e26cfa
patch 8.2.2977: crash when using a null function reference
Bram Moolenaar <Bram@vim.org>
parents:
24838
diff
changeset
|
2723 call assert_fails('call test_null_partial()()', 'E117:') |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26472
diff
changeset
|
2724 |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26472
diff
changeset
|
2725 let lines =<< trim END |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26472
diff
changeset
|
2726 let Time = 'localtime' |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26472
diff
changeset
|
2727 call Time() |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26472
diff
changeset
|
2728 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27412
diff
changeset
|
2729 call v9.CheckScriptFailure(lines, 'E1085:') |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2730 endfunc |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2731 |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2732 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
|
2733 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
|
2734 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
|
2735 set encoding=latin1 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
2736 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
|
2737 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
|
2738 endfunc |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2739 |
21973
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2740 func Test_charclass() |
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2741 call assert_equal(0, charclass(' ')) |
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2742 call assert_equal(1, charclass('.')) |
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2743 call assert_equal(2, charclass('x')) |
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2744 call assert_equal(3, charclass("\u203c")) |
25092
cd5e8df05a64
patch 8.2.3083: crash when passing null string to charclass()
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
2745 " this used to crash vim |
cd5e8df05a64
patch 8.2.3083: crash when passing null string to charclass()
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
2746 call assert_equal(0, "xxx"[-1]->charclass()) |
21973
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2747 endfunc |
85add08e6a2d
patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Bram Moolenaar <Bram@vim.org>
parents:
21935
diff
changeset
|
2748 |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
16231
diff
changeset
|
2749 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
|
2750 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
|
2751 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
|
2752 |
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
|
2753 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
|
2754 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
|
2755 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
|
2756 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
|
2757 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
|
2758 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
|
2759 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
|
2760 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
|
2761 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
|
2762 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
|
2763 |
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
|
2764 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
|
2765 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
|
2766 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
|
2767 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
|
2768 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
|
2769 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
|
2770 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
|
2771 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
|
2772 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
|
2773 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
|
2774 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
|
2775 |
17223
07bbe73b8e74
patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents:
17221
diff
changeset
|
2776 let buf1 = bufadd('') |
07bbe73b8e74
patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents:
17221
diff
changeset
|
2777 let buf2 = bufadd('') |
07bbe73b8e74
patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents:
17221
diff
changeset
|
2778 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
|
2779 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
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 exe 'bwipe ' .. buf1 |
07bbe73b8e74
patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents:
17221
diff
changeset
|
2785 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
|
2786 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
|
2787 exe 'bwipe ' .. buf2 |
07bbe73b8e74
patch 8.1.1611: bufadd() reuses existing buffer without a name
Bram Moolenaar <Bram@vim.org>
parents:
17221
diff
changeset
|
2788 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
|
2789 |
29875
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2790 " When 'buftype' is "nofile" then bufload() does not read the file. |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2791 " Other values too. |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2792 for val in [['nofile', 0], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2793 \ ['nowrite', 1], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2794 \ ['acwrite', 1], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2795 \ ['quickfix', 0], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2796 \ ['help', 1], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2797 \ ['terminal', 0], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2798 \ ['prompt', 0], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2799 \ ['popup', 0], |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2800 \ ] |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2801 bwipe! XotherName |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2802 let buf = bufadd('XotherName') |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2803 call setbufvar(buf, '&bt', val[0]) |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2804 call bufload(buf) |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2805 call assert_equal(val[1] ? ['some', 'text'] : [''], getbufline(buf, 1, '$'), val[0]) |
cb4d95b545f1
patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
29871
diff
changeset
|
2806 endfor |
29871
a4eab0d846dc
patch 9.0.0274: netrw plugin does not show remote files
Bram Moolenaar <Bram@vim.org>
parents:
29845
diff
changeset
|
2807 |
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
|
2808 bwipe someName |
17278
b6de6181e5ab
patch 8.1.1638: running tests leaves some files behind
Bram Moolenaar <Bram@vim.org>
parents:
17223
diff
changeset
|
2809 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
|
2810 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
|
2811 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
|
2812 endfunc |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2813 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2814 func Test_state() |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2815 CheckRunVimInTerminal |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2816 |
19795
1c7f92a1100e
patch 8.2.0454: some tests fail when the system is slow
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
2817 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
|
2818 |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2819 let lines =<< trim END |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2820 call setline(1, ['one', 'two', 'three']) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2821 map ;; gg |
18209
9a7bbad64376
patch 8.1.2099: state() test fails on some Mac systems
Bram Moolenaar <Bram@vim.org>
parents:
18143
diff
changeset
|
2822 set complete=. |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2823 func RunTimer() |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2824 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
|
2825 endfunc |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2826 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
|
2827 END |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2828 call writefile(lines, 'XState') |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2829 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
|
2830 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2831 " 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
|
2832 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
|
2833 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
|
2834 call term_sendkeys(buf, ":\<CR>") |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2835 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2836 " Using a timer callback |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2837 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
|
2838 call TermWait(buf, 25) |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2839 call term_sendkeys(buf, getstate) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2840 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
|
2841 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2842 " Halfway a mapping |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2843 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
|
2844 call TermWait(buf, 25) |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2845 call term_sendkeys(buf, ";") |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2846 call term_sendkeys(buf, getstate) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2847 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
|
2848 |
18209
9a7bbad64376
patch 8.1.2099: state() test fails on some Mac systems
Bram Moolenaar <Bram@vim.org>
parents:
18143
diff
changeset
|
2849 " 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
|
2850 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
|
2851 call TermWait(buf, 25) |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2852 call term_sendkeys(buf, "\<Esc>") |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2853 call term_sendkeys(buf, getstate) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2854 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
|
2855 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2856 " Autocommand executing |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2857 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
|
2858 call TermWait(buf, 25) |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2859 call term_sendkeys(buf, getstate) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2860 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
|
2861 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2862 " Todo: "w" - waiting for ch_evalexpr() |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2863 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2864 " messages scrolled |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2865 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
|
2866 call TermWait(buf, 25) |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2867 call term_sendkeys(buf, "\<CR>") |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2868 call term_sendkeys(buf, getstate) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2869 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
|
2870 |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2871 call StopVimInTerminal(buf) |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2872 call delete('XState') |
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18096
diff
changeset
|
2873 endfunc |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2874 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2875 func Test_range() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2876 " destructuring |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2877 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
|
2878 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
|
2879 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2880 " index |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2881 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
|
2882 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2883 " add() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2884 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
|
2885 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
|
2886 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
|
2887 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2888 " append() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2889 new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2890 call append('.', range(5)) |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2891 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
|
2892 bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2893 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2894 " appendbufline() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2895 new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2896 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
|
2897 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
|
2898 bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2899 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2900 " call() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2901 func TwoArgs(a, b) |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2902 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
|
2903 endfunc |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2904 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
|
2905 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2906 " col() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2907 new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2908 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
|
2909 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
|
2910 bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2911 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2912 " complete() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2913 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
|
2914 " complete_info() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2915 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
|
2916 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2917 " copy() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2918 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
|
2919 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2920 " count() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2921 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
|
2922 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
|
2923 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
|
2924 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2925 " cursor() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2926 new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2927 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
|
2928 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
|
2929 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
|
2930 bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2931 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2932 " deepcopy() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2933 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
|
2934 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2935 " empty() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2936 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
|
2937 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
|
2938 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2939 " execute() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2940 new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2941 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
|
2942 call execute(range(3)) |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2943 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
|
2944 bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2945 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2946 " extend() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2947 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
|
2948 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
|
2949 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
|
2950 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2951 " filter() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2952 call assert_equal([1, 3], filter(range(5), 'v:val % 2')) |
23037
4ba6c5eebb28
patch 8.2.2065: using map() and filter() on a range() is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
2953 call assert_equal([1, 5, 7, 11, 13], filter(filter(range(15), 'v:val % 2'), 'v:val % 3')) |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2954 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2955 " funcref() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2956 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
|
2957 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2958 " function() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2959 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
|
2960 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2961 " garbagecollect() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2962 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
|
2963 let otherlist = range(3) |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2964 call test_garbagecollect_now() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2965 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2966 " get() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2967 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
|
2968 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
|
2969 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2970 " index() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2971 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
|
2972 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
|
2973 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2974 " insert() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2975 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
|
2976 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
|
2977 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
|
2978 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
|
2979 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
|
2980 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
|
2981 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2982 " join() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2983 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
|
2984 |
19209
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19207
diff
changeset
|
2985 " json_encode() |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19207
diff
changeset
|
2986 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
|
2987 |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2988 " len() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2989 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
|
2990 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
|
2991 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
|
2992 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
|
2993 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2994 " list2str() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2995 call assert_equal('ABC', list2str(range(65, 67))) |
30015
adb0de8be4ce
patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
2996 call assert_fails('let s = list2str(5)', 'E1211:') |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2997 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2998 " lock() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
2999 let thelist = range(5) |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3000 lockvar thelist |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3001 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3002 " map() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3003 call assert_equal([0, 2, 4, 6, 8], map(range(5), 'v:val * 2')) |
23037
4ba6c5eebb28
patch 8.2.2065: using map() and filter() on a range() is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
3004 call assert_equal([3, 5, 7, 9, 11], map(map(range(5), 'v:val * 2'), 'v:val + 3')) |
4ba6c5eebb28
patch 8.2.2065: using map() and filter() on a range() is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
3005 call assert_equal([2, 6], map(filter(range(5), 'v:val % 2'), 'v:val * 2')) |
4ba6c5eebb28
patch 8.2.2065: using map() and filter() on a range() is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
3006 call assert_equal([2, 4, 8], filter(map(range(5), 'v:val * 2'), 'v:val % 3')) |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3007 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3008 " match() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3009 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
|
3010 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3011 " matchaddpos() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3012 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
|
3013 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
|
3014 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3015 " matchend() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3016 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
|
3017 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
|
3018 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
|
3019 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3020 " matchstrpos() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3021 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
|
3022 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
|
3023 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
|
3024 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3025 " max() reverse() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3026 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
|
3027 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
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 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
|
3033 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
|
3034 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
|
3035 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3036 " min() reverse() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3037 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
|
3038 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
|
3039 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
|
3040 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
|
3041 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
|
3042 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
|
3043 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
|
3044 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
|
3045 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
|
3046 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3047 " remove() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 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
|
3053 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
|
3054 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3055 " repeat() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3056 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
|
3057 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
|
3058 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
|
3059 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
|
3060 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
|
3061 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3062 " reverse() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 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
|
3070 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
|
3071 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
|
3072 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3073 " TODO: setpos() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3074 " new |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3075 " 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
|
3076 " 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
|
3077 " 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
|
3078 " bwipe! |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3079 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3080 " setreg() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3081 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
|
3082 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
|
3083 |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3084 " settagstack() |
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3085 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
|
3086 |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3087 " 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
|
3088 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
|
3089 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
|
3090 |
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3091 " 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
|
3092 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
|
3093 |
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3094 " 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
|
3095 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
|
3096 |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3097 " sort() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3098 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
|
3099 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3100 " string() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3101 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
|
3102 |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3103 " 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
|
3104 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
|
3105 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
|
3106 endfunc |
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3107 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
|
3108 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
|
3109 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
|
3110 |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3111 " 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
|
3112 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
|
3113 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
|
3114 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
|
3115 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
|
3116 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
|
3117 else |
e4a155edc9cb
patch 8.2.0211: test for ANSI colors fails without an "ls" command
Bram Moolenaar <Bram@vim.org>
parents:
19255
diff
changeset
|
3118 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
|
3119 endif |
28919
99c1356f4210
patch 8.2.4982: colors in terminal window are not 100% correct
Bram Moolenaar <Bram@vim.org>
parents:
28702
diff
changeset
|
3120 call assert_fails('call term_start("' .. cmd .. '", #{term_finish: "close"' |
99c1356f4210
patch 8.2.4982: colors in terminal window are not 100% correct
Bram Moolenaar <Bram@vim.org>
parents:
28702
diff
changeset
|
3121 \ .. ', ansi_colors: range(16)})', 'E475:') |
28921
995bc7ba8d5b
patch 8.2.4983: colors test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3122 unlet g:terminal_ansi_colors |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3123 endif |
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19209
diff
changeset
|
3124 |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3125 " type() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3126 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
|
3127 |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3128 " uniq() |
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
18821
diff
changeset
|
3129 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
|
3130 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3131 " errors |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3132 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
|
3133 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
|
3134 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
|
3135 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
|
3136 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
|
3137 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
|
3138 endfunc |
19400
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3139 |
27412
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3140 func Test_garbagecollect_now_fails() |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3141 let v:testing = 0 |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3142 call assert_fails('call test_garbagecollect_now()', 'E1142:') |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3143 let v:testing = 1 |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3144 endfunc |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27368
diff
changeset
|
3145 |
19400
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3146 func Test_echoraw() |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3147 CheckScreendump |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3148 |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3149 " 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
|
3150 let lines =<< trim END |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3151 call echoraw("hello\<CR>x") |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3152 END |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3153 call writefile(lines, 'XTest_echoraw') |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3154 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
|
3155 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
|
3156 |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3157 " clean up |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3158 call StopVimInTerminal(buf) |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3159 call delete('XTest_echoraw') |
bd9069d21c5d
patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents:
19306
diff
changeset
|
3160 endfunc |
19517
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
3161 |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3162 " Test for echo highlighting |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3163 func Test_echohl() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3164 echohl Search |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3165 echo 'Vim' |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3166 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
|
3167 " 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
|
3168 " ScreenAttrs() returns all zeros. |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3169 echohl None |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3170 endfunc |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3171 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3172 " Test for the eval() function |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3173 func Test_eval() |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3174 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
|
3175 endfunc |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3176 |
30226
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3177 " Test for the keytrans() function |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3178 func Test_keytrans() |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3179 call assert_equal('<Space>', keytrans(' ')) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3180 call assert_equal('<lt>', keytrans('<')) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3181 call assert_equal('<lt>Tab>', keytrans('<Tab>')) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3182 call assert_equal('<Tab>', keytrans("\<Tab>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3183 call assert_equal('<C-V>', keytrans("\<C-V>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3184 call assert_equal('<BS>', keytrans("\<BS>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3185 call assert_equal('<Home>', keytrans("\<Home>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3186 call assert_equal('<C-Home>', keytrans("\<C-Home>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3187 call assert_equal('<M-Home>', keytrans("\<M-Home>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3188 call assert_equal('<C-Space>', keytrans("\<C-Space>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3189 call assert_equal('<M-Space>', keytrans("\<*M-Space>")) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3190 call assert_equal('<M-x>', "\<*M-x>"->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3191 call assert_equal('<C-I>', "\<*C-I>"->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3192 call assert_equal('<S-3>', "\<*S-3>"->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3193 call assert_equal('π', 'π'->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3194 call assert_equal('<M-π>', "\<M-π>"->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3195 call assert_equal('ě', 'ě'->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3196 call assert_equal('<M-ě>', "\<M-ě>"->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3197 call assert_equal('', ''->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3198 call assert_equal('', test_null_string()->keytrans()) |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3199 call assert_fails('call keytrans(1)', 'E1174:') |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3200 call assert_fails('call keytrans()', 'E119:') |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3201 endfunc |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
3202 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3203 " Test for the nr2char() function |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3204 func Test_nr2char() |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3205 set encoding=latin1 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3206 call assert_equal('@', nr2char(64)) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3207 set encoding=utf8 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3208 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
|
3209 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
|
3210 |
28668
53c608c7ea9e
patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents:
28629
diff
changeset
|
3211 call assert_equal("\x80\xfc\b" .. nr2char(0x100000), eval('"\<M-' .. nr2char(0x100000) .. '>"')) |
53c608c7ea9e
patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents:
28629
diff
changeset
|
3212 call assert_equal("\x80\xfc\b" .. nr2char(0x40000000), eval('"\<M-' .. nr2char(0x40000000) .. '>"')) |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3213 endfunc |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3214 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3215 " 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
|
3216 func Test_screen_functions() |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3217 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
|
3218 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
|
3219 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
|
3220 endfunc |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19742
diff
changeset
|
3221 |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3222 " 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
|
3223 func Test_getcurpos_setpos() |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3224 new |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3225 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
|
3226 normal gg6l |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3227 let sp = getcurpos() |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3228 normal 0 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3229 call setpos('.', sp) |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3230 normal jyl |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3231 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
|
3232 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
|
3233 call assert_equal(-1, setpos('.', {})) |
22357
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3234 |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3235 let winid = win_getid() |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3236 normal G$ |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3237 let pos = getcurpos() |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3238 wincmd w |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3239 call assert_equal(pos, getcurpos(winid)) |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3240 |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3241 wincmd w |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3242 close! |
22357
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3243 |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3244 call assert_equal(getcurpos(), getcurpos(0)) |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3245 call assert_equal([0, 0, 0, 0, 0], getcurpos(-1)) |
0e231e8e70f8
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Bram Moolenaar <Bram@vim.org>
parents:
22355
diff
changeset
|
3246 call assert_equal([0, 0, 0, 0, 0], getcurpos(1999)) |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3247 endfunc |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
3248 |
28061
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3249 func Test_getmousepos() |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3250 enew! |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3251 call setline(1, "\t\t\t1234") |
28069
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3252 call test_setmouse(1, 1) |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3253 call assert_equal(#{ |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3254 \ screenrow: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3255 \ screencol: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3256 \ winid: win_getid(), |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3257 \ winrow: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3258 \ wincol: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3259 \ line: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3260 \ column: 1, |
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3261 \ }, getmousepos()) |
28061
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3262 call test_setmouse(1, 25) |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3263 call assert_equal(#{ |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3264 \ screenrow: 1, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3265 \ screencol: 25, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3266 \ winid: win_getid(), |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3267 \ winrow: 1, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3268 \ wincol: 25, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3269 \ line: 1, |
28069
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3270 \ column: 4, |
28061
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3271 \ }, getmousepos()) |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3272 call test_setmouse(1, 50) |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3273 call assert_equal(#{ |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3274 \ screenrow: 1, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3275 \ screencol: 50, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3276 \ winid: win_getid(), |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3277 \ winrow: 1, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3278 \ wincol: 50, |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3279 \ line: 1, |
28069
236b80af9833
patch 8.2.4559: getmousepos() returns the screen column
Bram Moolenaar <Bram@vim.org>
parents:
28061
diff
changeset
|
3280 \ column: 8, |
28061
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3281 \ }, getmousepos()) |
28087
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3282 |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3283 " If the mouse is positioned past the last buffer line, "line" and "column" |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3284 " should act like it's positioned on the last buffer line. |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3285 call test_setmouse(2, 25) |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3286 call assert_equal(#{ |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3287 \ screenrow: 2, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3288 \ screencol: 25, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3289 \ winid: win_getid(), |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3290 \ winrow: 2, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3291 \ wincol: 25, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3292 \ line: 1, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3293 \ column: 4, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3294 \ }, getmousepos()) |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3295 call test_setmouse(2, 50) |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3296 call assert_equal(#{ |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3297 \ screenrow: 2, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3298 \ screencol: 50, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3299 \ winid: win_getid(), |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3300 \ winrow: 2, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3301 \ wincol: 50, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3302 \ line: 1, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3303 \ column: 8, |
4c60e656e054
patch 8.2.4568: getmousepos() does not compute the column below the last line
Bram Moolenaar <Bram@vim.org>
parents:
28069
diff
changeset
|
3304 \ }, getmousepos()) |
28061
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3305 bwipe! |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3306 endfunc |
050d49de7a66
patch 8.2.4555: getmousepos() returns the wrong column
Bram Moolenaar <Bram@vim.org>
parents:
27802
diff
changeset
|
3307 |
31093
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3308 func Test_getmouseshape() |
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3309 CheckFeature mouseshape |
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3310 |
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3311 call assert_equal('arrow', getmouseshape()) |
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3312 endfunc |
004aee2845d2
patch 9.0.0881: cannot get the currently showing mouse shape
Bram Moolenaar <Bram@vim.org>
parents:
31081
diff
changeset
|
3313 |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3314 " Test for glob() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3315 func Test_glob() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3316 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
|
3317 call assert_equal('', globpath(test_null_string(), test_null_string())) |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24618
diff
changeset
|
3318 call assert_fails("let x = globpath(&rtp, 'syntax/c.vim', [])", 'E745:') |
21911
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3319 |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3320 call writefile([], 'Xglob1') |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3321 call writefile([], 'XGLOB2') |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3322 set wildignorecase |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3323 " Sort output of glob() otherwise we end up with different |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3324 " ordering depending on whether file system is case-sensitive. |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3325 call assert_equal(['XGLOB2', 'Xglob1'], sort(glob('Xglob[12]', 0, 1))) |
28291
1c97a31f8f22
patch 8.2.4671: 'wildignorecase' is sometimes not used for glob()
Bram Moolenaar <Bram@vim.org>
parents:
28087
diff
changeset
|
3326 " wildignorecase shall be applied even when the pattern contains no wildcards. |
1c97a31f8f22
patch 8.2.4671: 'wildignorecase' is sometimes not used for glob()
Bram Moolenaar <Bram@vim.org>
parents:
28087
diff
changeset
|
3327 call assert_equal('XGLOB2', glob('xglob2')) |
21911
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3328 set wildignorecase& |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3329 |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3330 call delete('Xglob1') |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3331 call delete('XGLOB2') |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3332 |
0c0e8cd8c177
patch 8.2.1505: not all file read and writecode is tested
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
3333 call assert_fails("call glob('*', 0, {})", 'E728:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3334 endfunc |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3335 |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3336 " Test for browse() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3337 func Test_browse() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3338 CheckFeature browse |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3339 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
|
3340 endfunc |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3341 |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3342 " Test for browsedir() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3343 func Test_browsedir() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3344 CheckFeature browse |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3345 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
|
3346 endfunc |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
3347 |
24448
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3348 func HasDefault(msg = 'msg') |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3349 return a:msg |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3350 endfunc |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3351 |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3352 func Test_default_arg_value() |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3353 call assert_equal('msg', HasDefault()) |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3354 endfunc |
faac16c365b6
patch 8.2.2764: memory leak when default function argument is allocated
Bram Moolenaar <Bram@vim.org>
parents:
24204
diff
changeset
|
3355 |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
3356 " Test for gettext() |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
3357 func Test_gettext() |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30015
diff
changeset
|
3358 call assert_fails('call gettext(1)', 'E1174:') |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
3359 endfunc |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
3360 |
24760
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3361 func Test_builtin_check() |
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3362 call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:') |
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3363 call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:') |
24766
29ed95687f74
patch 8.2.2921: E704 for script local variable is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
24764
diff
changeset
|
3364 call assert_fails('let l:["trim"] = {x -> " " .. x}', 'E704:') |
29ed95687f74
patch 8.2.2921: E704 for script local variable is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
24764
diff
changeset
|
3365 call assert_fails('let l:.trim = {x -> " " .. x}', 'E704:') |
29ed95687f74
patch 8.2.2921: E704 for script local variable is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
24764
diff
changeset
|
3366 let lines =<< trim END |
29ed95687f74
patch 8.2.2921: E704 for script local variable is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
24764
diff
changeset
|
3367 vim9script |
27671
19367412787c
patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
3368 var trim = (x) => " " .. x |
24766
29ed95687f74
patch 8.2.2921: E704 for script local variable is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
24764
diff
changeset
|
3369 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27412
diff
changeset
|
3370 call v9.CheckScriptFailure(lines, 'E704:') |
24764
3907cf9be745
patch 8.2.2920: still a way to shadow a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
24760
diff
changeset
|
3371 |
3907cf9be745
patch 8.2.2920: still a way to shadow a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
24760
diff
changeset
|
3372 call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:') |
3907cf9be745
patch 8.2.2920: still a way to shadow a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
24760
diff
changeset
|
3373 let g:bar = 123 |
3907cf9be745
patch 8.2.2920: still a way to shadow a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
24760
diff
changeset
|
3374 call extend(g:, #{bar: { -> "foo" }}, "keep") |
3907cf9be745
patch 8.2.2920: still a way to shadow a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
24760
diff
changeset
|
3375 call assert_fails('call extend(g:, #{bar: { -> "foo" }}, "force")', 'E704:') |
31002
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3376 unlet g:bar |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3377 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3378 call assert_fails('call extend(l:, #{foo: { -> "foo" }})', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3379 let bar = 123 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3380 call extend(l:, #{bar: { -> "foo" }}, "keep") |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3381 call assert_fails('call extend(l:, #{bar: { -> "foo" }}, "force")', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3382 unlet bar |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3383 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3384 call assert_fails('call extend(g:, #{foo: function("extend")})', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3385 let g:bar = 123 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3386 call extend(g:, #{bar: function("extend")}, "keep") |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3387 call assert_fails('call extend(g:, #{bar: function("extend")}, "force")', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3388 unlet g:bar |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3389 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3390 call assert_fails('call extend(l:, #{foo: function("extend")})', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3391 let bar = 123 |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3392 call extend(l:, #{bar: function("extend")}, "keep") |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3393 call assert_fails('call extend(l:, #{bar: function("extend")}, "force")', 'E704:') |
a09404dad917
patch 9.0.0836: wrong error when using extend() with funcref
Bram Moolenaar <Bram@vim.org>
parents:
30761
diff
changeset
|
3394 unlet bar |
24760
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3395 endfunc |
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3396 |
26472
cc95e10e1cf2
patch 8.2.3766: converting a funcref to a string leaves out "g:"
Bram Moolenaar <Bram@vim.org>
parents:
26007
diff
changeset
|
3397 func Test_funcref_to_string() |
cc95e10e1cf2
patch 8.2.3766: converting a funcref to a string leaves out "g:"
Bram Moolenaar <Bram@vim.org>
parents:
26007
diff
changeset
|
3398 let Fn = funcref('g:Test_funcref_to_string') |
cc95e10e1cf2
patch 8.2.3766: converting a funcref to a string leaves out "g:"
Bram Moolenaar <Bram@vim.org>
parents:
26007
diff
changeset
|
3399 call assert_equal("function('g:Test_funcref_to_string')", string(Fn)) |
cc95e10e1cf2
patch 8.2.3766: converting a funcref to a string leaves out "g:"
Bram Moolenaar <Bram@vim.org>
parents:
26007
diff
changeset
|
3400 endfunc |
cc95e10e1cf2
patch 8.2.3766: converting a funcref to a string leaves out "g:"
Bram Moolenaar <Bram@vim.org>
parents:
26007
diff
changeset
|
3401 |
28629
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3402 " Test for isabsolutepath() |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3403 func Test_isabsolutepath() |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3404 call assert_false(isabsolutepath('')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3405 call assert_false(isabsolutepath('.')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3406 call assert_false(isabsolutepath('../Foo')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3407 call assert_false(isabsolutepath('Foo/')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3408 if has('win32') |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3409 call assert_true(isabsolutepath('A:\')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3410 call assert_true(isabsolutepath('A:\Foo')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3411 call assert_true(isabsolutepath('A:/Foo')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3412 call assert_false(isabsolutepath('A:Foo')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3413 call assert_false(isabsolutepath('\Windows')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3414 call assert_true(isabsolutepath('\\Server2\Share\Test\Foo.txt')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3415 else |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3416 call assert_true(isabsolutepath('/')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3417 call assert_true(isabsolutepath('/usr/share/')) |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3418 endif |
5ef46b938c6e
patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents:
28341
diff
changeset
|
3419 endfunc |
24760
ca0f983f08cf
patch 8.2.2918: builtin function can be shadowed by global variable
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3420 |
28672
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3421 " Test for exepath() |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3422 func Test_exepath() |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3423 if has('win32') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3424 call assert_notequal(exepath('cmd'), '') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3425 |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3426 let oldNoDefaultCurrentDirectoryInExePath = $NoDefaultCurrentDirectoryInExePath |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3427 call writefile(['@echo off', 'echo Evil'], 'vim-test-evil.bat') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3428 let $NoDefaultCurrentDirectoryInExePath = '' |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3429 call assert_notequal(exepath("vim-test-evil.bat"), '') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3430 let $NoDefaultCurrentDirectoryInExePath = '1' |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3431 call assert_equal(exepath("vim-test-evil.bat"), '') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3432 let $NoDefaultCurrentDirectoryInExePath = oldNoDefaultCurrentDirectoryInExePath |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3433 call delete('vim-test-evil.bat') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3434 else |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3435 call assert_notequal(exepath('sh'), '') |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3436 endif |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3437 endfunc |
e4de5b5193b4
patch 8.2.4860: MS-Windows: always uses current directory for executables
Bram Moolenaar <Bram@vim.org>
parents:
28668
diff
changeset
|
3438 |
28994
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3439 " Test for virtcol() |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3440 func Test_virtcol() |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3441 enew! |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3442 call setline(1, "the\tquick\tbrown\tfox") |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3443 norm! 4| |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3444 call assert_equal(8, virtcol('.')) |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3445 call assert_equal(8, virtcol('.', v:false)) |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3446 call assert_equal([4, 8], virtcol('.', v:true)) |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3447 bwipe! |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3448 endfunc |
644b0f0541de
patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents:
28921
diff
changeset
|
3449 |
31081
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3450 func Test_delfunc_while_listing() |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3451 CheckRunVimInTerminal |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3452 |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3453 let lines =<< trim END |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3454 set nocompatible |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3455 for i in range(1, 999) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3456 exe 'func ' .. 'MyFunc' .. i .. '()' |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3457 endfunc |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3458 endfor |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3459 au CmdlineLeave : call timer_start(0, {-> execute('delfunc MyFunc622')}) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3460 END |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3461 call writefile(lines, 'Xfunctionclear', 'D') |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3462 let buf = RunVimInTerminal('-S Xfunctionclear', {'rows': 12}) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3463 |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3464 " This was using freed memory. The height of the terminal must be so that |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3465 " the next function to be listed with "j" is the one that is deleted in the |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3466 " timer callback, tricky! |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3467 call term_sendkeys(buf, ":func /MyFunc\<CR>") |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3468 call TermWait(buf, 50) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3469 call term_sendkeys(buf, "j") |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3470 call TermWait(buf, 50) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3471 call term_sendkeys(buf, "\<CR>") |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3472 |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3473 call StopVimInTerminal(buf) |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3474 endfunc |
c12069d28719
patch 9.0.0875: using freed memory when executing delfunc at more prompt
Bram Moolenaar <Bram@vim.org>
parents:
31057
diff
changeset
|
3475 |
32367
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3476 " Test for the reverse() function with a string |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3477 func Test_string_reverse() |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3478 call assert_equal('', reverse(test_null_string())) |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3479 for [s1, s2] in [['', ''], ['a', 'a'], ['ab', 'ba'], ['abc', 'cba'], |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3480 \ ['abcd', 'dcba'], ['«-«-»-»', '»-»-«-«'], |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3481 \ ['🇦', '🇦'], ['🇦🇧', '🇧🇦'], ['🇦🇧🇨', '🇨🇧🇦'], |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3482 \ ['🇦«🇧-🇨»🇩', '🇩»🇨-🇧«🇦']] |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3483 call assert_equal(s2, reverse(s1)) |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3484 endfor |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3485 |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3486 " test in latin1 encoding |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3487 let save_enc = &encoding |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3488 set encoding=latin1 |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3489 call assert_equal('dcba', reverse('abcd')) |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3490 let &encoding = save_enc |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3491 endfunc |
d5e673b941cd
patch 9.0.1515: reverse() does not work for a String
Bram Moolenaar <Bram@vim.org>
parents:
32307
diff
changeset
|
3492 |
19517
738a4fe2c8c5
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19400
diff
changeset
|
3493 " vim: shiftwidth=2 sts=2 expandtab |