annotate src/testdir/test_iminsert.vim @ 20941:505d97ea54da v8.2.1022

patch 8.2.1022: various parts of code not covered by tests Commit: https://github.com/vim/vim/commit/845e0ee59430eac07e74b6cb92020e420d17953d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 20 16:05:32 2020 +0200 patch 8.2.1022: various parts of code not covered by tests Problem: Various parts of code not covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6300)
author Bram Moolenaar <Bram@vim.org>
date Sat, 20 Jun 2020 16:15:04 +0200
parents f70a3c1000bb
children 2d3cd9acf853
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 source view_util.vim
18846
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
2 source check.vim
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 let s:imactivatefunc_called = 0
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 let s:imstatusfunc_called = 0
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
6 let s:imstatus_active = 0
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func IM_activatefunc(active)
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let s:imactivatefunc_called = 1
20941
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
10 let s:imstatus_active = a:active
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endfunc
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 func IM_statusfunc()
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let s:imstatusfunc_called = 1
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
15 return s:imstatus_active
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endfunc
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 func Test_iminsert2()
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
19 let s:imactivatefunc_called = 0
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
20 let s:imstatusfunc_called = 0
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
21
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 set imactivatefunc=IM_activatefunc
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 set imstatusfunc=IM_statusfunc
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 set iminsert=2
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 normal! i
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 set iminsert=0
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 set imactivatefunc=
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 set imstatusfunc=
12936
c53a80f39a52 patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents: 12930
diff changeset
29
c53a80f39a52 patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents: 12930
diff changeset
30 let expected = has('gui_running') ? 0 : 1
c53a80f39a52 patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents: 12930
diff changeset
31 call assert_equal(expected, s:imactivatefunc_called)
c53a80f39a52 patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Christian Brabandt <cb@256bit.org>
parents: 12930
diff changeset
32 call assert_equal(expected, s:imstatusfunc_called)
12920
327e1264b9bf patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endfunc
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
34
18846
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
35 func Test_getimstatus()
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
36 if has('win32')
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
37 CheckFeature multi_byte_ime
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
38 elseif !has('gui_mac')
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
39 CheckFeature xim
67eb9bc32434 patch 8.1.2410: MS-Windows: test_iminsert fails without IME support
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
40 endif
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
41 if has('gui_running')
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
42 if !has('win32')
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
43 throw 'Skipped: running in the GUI, only works on MS-Windows'
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
44 endif
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
45 set imactivatefunc=
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
46 set imstatusfunc=
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
47 else
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
48 set imactivatefunc=IM_activatefunc
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
49 set imstatusfunc=IM_statusfunc
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
50 let s:imstatus_active = 0
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
51 endif
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
52
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
53 new
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
54 set iminsert=2
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
55 call feedkeys("i\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
56 call assert_equal('1', getline(1))
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
57 set iminsert=0
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
58 call feedkeys("o\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
59 call assert_equal('0', getline(2))
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
60 bw!
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
61
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
62 set imactivatefunc=
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
63 set imstatusfunc=
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
64 endfunc
19570
43c04edcafec patch 8.2.0342: some code in ex_getln.c not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18846
diff changeset
65
19625
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
66 " Test for using an lmap in insert mode
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
67 func Test_lmap_in_insert_mode()
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
68 new
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
69 call setline(1, 'abc')
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
70 lmap { w
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
71 set iminsert=1
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
72 call feedkeys('r{', 'xt')
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
73 call assert_equal('wbc', getline(1))
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
74 set iminsert=2
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
75 call feedkeys('$r{', 'xt')
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
76 call assert_equal('wb{', getline(1))
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
77 call setline(1, 'vim web')
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
78 set iminsert=1
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
79 call feedkeys('0f{', 'xt')
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
80 call assert_equal(5, col('.'))
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
81 set iminsert&
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
82 lunmap {
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
83 close!
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
84 endfunc
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19570
diff changeset
85
20941
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
86 " Test for using CTRL-^ to toggle iminsert in insert mode
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
87 func Test_iminsert_toggle()
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
88 CheckGui
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
89 if has('win32')
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
90 CheckFeature multi_byte_ime
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
91 elseif !has('gui_mac')
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
92 CheckFeature xim
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
93 endif
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
94 if has('gui_running') && !has('win32')
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
95 " this works only in Win32 GUI version (for some reason)
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
96 return
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
97 endif
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
98 new
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
99 let save_imdisable = &imdisable
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
100 let save_iminsert = &iminsert
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
101 set noimdisable
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
102 set iminsert=0
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
103 exe "normal i\<C-^>"
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
104 call assert_equal(2, &iminsert)
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
105 exe "normal i\<C-^>"
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
106 call assert_equal(0, &iminsert)
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
107 let &iminsert = save_iminsert
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
108 let &imdisable = save_imdisable
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
109 close!
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
110 endfunc
505d97ea54da patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
111
19570
43c04edcafec patch 8.2.0342: some code in ex_getln.c not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18846
diff changeset
112 " vim: shiftwidth=2 sts=2 expandtab