Mercurial > vim
annotate src/testdir/test_maparg.vim @ 18832:b3eb5102447a v8.1.2403
patch 8.1.2403: autocmd test fails under valgrind
Commit: https://github.com/vim/vim/commit/3c47e8384de62dd67748454a853677e32ee7842c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 7 17:05:31 2019 +0100
patch 8.1.2403: autocmd test fails under valgrind
Problem: Autocmd test fails under valgrind.
Solution: Wait a bit longer.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 07 Dec 2019 17:15:04 +0100 |
parents | 0cdb6ac20748 |
children | 643c6c3c0da4 |
rev | line source |
---|---|
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for maparg(). |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Also test utf8 map with a 0x80 byte. |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
3 " Also test mapcheck() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 function s:SID() |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 endfun |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 function Test_maparg() |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 set cpo-=< |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 set encoding=utf8 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " Test maparg() with a string result |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
14 let sid = s:SID() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
15 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 map foo<C-V> is<F4>foo |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 vnoremap <script> <buffer> <expr> <silent> bar isbar |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_equal("is<F4>foo", maparg('foo<C-V>')) |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
20 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
21 \ 'rhs': 'is<F4>foo', 'buffer': 0}, |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
22 \ maparg('foo<C-V>', '', 0, 1)) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
25 \ 'rhs': 'isbar', 'buffer': 1}, |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
26 \ 'bar'->maparg('', 0, 1)) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
27 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 map <buffer> <nowait> foo bar |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
30 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
31 \ 'buffer': 1}, |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ maparg('foo', '', 0, 1)) |
17522
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
33 let lnum = expand('<sflnum>') |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
34 tmap baz foo |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
35 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'baz', 'mode': 't', |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
36 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo', |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
37 \ 'buffer': 0}, |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
38 \ maparg('baz', 't', 0, 1)) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 map abc x<char-114>x |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
41 call assert_equal("xrx", maparg('abc')) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 map abc y<S-char-114>y |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
43 call assert_equal("yRy", maparg('abc')) |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
44 |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
45 map abc <Nop> |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
46 call assert_equal("<Nop>", maparg('abc')) |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
47 unmap abc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 endfunction |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
50 func Test_mapcheck() |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
51 call assert_equal('', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
52 call assert_equal('', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
53 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
54 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
55 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
56 map a something |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
57 call assert_equal('something', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
58 call assert_equal('something', mapcheck('a', 'n')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
59 call assert_equal('', mapcheck('a', 'c')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
60 call assert_equal('', mapcheck('a', 'i')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
61 call assert_equal('something', 'abc'->mapcheck()) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
62 call assert_equal('something', 'ax'->mapcheck()) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
63 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
64 unmap a |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
65 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
66 map ab foobar |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
67 call assert_equal('foobar', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
68 call assert_equal('foobar', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
69 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
70 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
71 unmap ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
72 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
73 map abc barfoo |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
74 call assert_equal('barfoo', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
75 call assert_equal('barfoo', mapcheck('a', 'n', 0)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
76 call assert_equal('', mapcheck('a', 'n', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
77 call assert_equal('barfoo', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
78 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
79 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
80 unmap abc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
81 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
82 abbr ab abbrev |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
83 call assert_equal('abbrev', mapcheck('a', 'i', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
84 call assert_equal('', mapcheck('a', 'n', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
85 call assert_equal('', mapcheck('a', 'i', 0)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
86 unabbr ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
87 endfunc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
88 |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 function Test_range_map() |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 " Outside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 inoremap <Char-0x1040> a |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 execute "normal a\u1040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 " Inside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 inoremap <Char-0x103f> b |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 execute "normal a\u103f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 " Inside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 inoremap <Char-0xf03f> c |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 execute "normal a\uf03f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 " Outside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 inoremap <Char-0xf040> d |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 execute "normal a\uf040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 call assert_equal("abcd", getline(1)) |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 endfunction |