robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

dundargoctest: move oldtests to test directory (#22536)af23d17388

master
2.2 KiB89 linesraw
1" tests for 'langmap'
2
3source check.vim
4CheckFeature langmap
5
6func Test_langmap()
7  new
8  set langmap=}l,^x,%v
9
10  call setline(1, ['abc'])
11  call feedkeys('gg0}^', 'tx')
12  call assert_equal('ac', getline(1))
13
14  " in Replace mode
15  " need silent! to avoid a delay when entering Insert mode
16  call setline(1, ['abcde'])
17  silent! call feedkeys("gg0lR%{z\<Esc>00", 'tx')
18  call assert_equal('a%{ze', getline(1))
19
20  " in Select mode
21  " need silent! to avoid a delay when entering Insert mode
22  call setline(1, ['abcde'])
23  silent! call feedkeys("gg0}%}\<C-G>}^\<Esc>00", 'tx')
24  call assert_equal('a}^de', getline(1))
25
26  " Error cases
27  call assert_fails('set langmap=aA,b', 'E357:')
28  call assert_fails('set langmap=z;y;y;z', 'E358:')
29
30  " Map character > 256
31  enew!
32  set langmap=āx,ăl,āx
33  call setline(1, ['abcde'])
34  call feedkeys('gg2lā', 'tx')
35  call assert_equal('abde', getline(1))
36
37  " special characters in langmap
38  enew!
39  call setline(1, ['Hello World'])
40  set langmap=\\;\\,,\\,\\;
41  call feedkeys('ggfo,', 'tx')
42  call assert_equal(8, col('.'))
43  call feedkeys(';', 'tx')
44  call assert_equal(5, col('.'))
45  set langmap&
46  set langmap=\\;\\,;\\,\\;
47  call feedkeys('ggfo,', 'tx')
48  call assert_equal(8, col('.'))
49  call feedkeys(';', 'tx')
50  call assert_equal(5, col('.'))
51
52  set langmap=RL
53  let g:counter = 0
54  nnoremap L;L <Cmd>let g:counter += 1<CR>
55  nnoremap <C-L> <Cmd>throw 'This mapping should not be triggered'<CR>
56
57  " 'langmap' is applied to keys without modifiers when matching a mapping
58  call feedkeys('R;R', 'tx')
59  call assert_equal(1, g:counter)
60  nunmap L;L
61  unlet g:counter
62
63  delete
64  call assert_equal('', getline(1))
65  undo
66  call assert_equal('Hello World', getline(1))
67  " 'langmap' does not change Ctrl-R to Ctrl-L for consistency
68  call feedkeys("\<*C-R>", 'tx')
69  call assert_equal('', getline(1))
70
71  set langmap=6L
72  undo
73  setlocal bufhidden=hide
74  let oldbuf = bufnr()
75  enew
76  call assert_notequal(oldbuf, bufnr())
77  " 'langmap' does not change Ctrl-6 to Ctrl-L for consistency
78  " Ctrl-6 becomes Ctrl-^ after merging the Ctrl modifier
79  call feedkeys("\<*C-6>", 'tx')
80  call assert_equal(oldbuf, bufnr())
81  setlocal bufhidden&
82
83  nunmap <C-L>
84
85  set langmap&
86  quit!
87endfunc
88
89" vim: shiftwidth=2 sts=2 expandtab