annotate src/testdir/test_menu.vim @ 19852:12518b40c161 v8.2.0482

patch 8.2.0482: channel and sandbox code not sufficiently tested Commit: https://github.com/vim/vim/commit/ca68ae13114619df3e4c195b41ad0575516f5ff6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 30 19:32:53 2020 +0200 patch 8.2.0482: channel and sandbox code not sufficiently tested Problem: Channel and sandbox code not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5855)
author Bram Moolenaar <Bram@vim.org>
date Mon, 30 Mar 2020 19:45:05 +0200
parents d53e8428a79a
children 2fb397573541
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test that the system menu can be loaded.
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
3 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 CheckFeature menu
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
5
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func Test_load_menu()
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 try
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 source $VIMRUNTIME/menu.vim
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 catch
11183
1c4ebbae41d2 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents: 11048
diff changeset
10 call assert_report('error while loading menus: ' . v:exception)
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endtry
11048
860d023f0fc8 patch 8.0.0413: menu test fails on MS-Windows using gvim
Christian Brabandt <cb@256bit.org>
parents: 11046
diff changeset
12 call assert_match('browse confirm w', execute(':menu File.Save'))
18860
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
13
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
14 let v:errmsg = ''
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
15 doautocmd LoadBufferMenu VimEnter
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
16 call assert_equal('', v:errmsg)
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
17
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
18 source $VIMRUNTIME/delmenu.vim
18860
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
19 call assert_equal('', v:errmsg)
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endfunc
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
21
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
22 func Test_buffer_menu_special_buffers()
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
23 " Load in runtime menus
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
24 try
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
25 source $VIMRUNTIME/menu.vim
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
26 catch
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
27 call assert_report('error while loading menus: ' . v:exception)
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
28 endtry
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
29
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
30 let v:errmsg = ''
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
31 doautocmd LoadBufferMenu VimEnter
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
32 call assert_equal('', v:errmsg)
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
33
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
34 let orig_buffer_menus = execute("nmenu Buffers")
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
35
19844
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
36 " Test that regular new buffer results in a new buffer menu item.
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
37 new
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
38 let new_buffer_menus = execute('nmenu Buffers')
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
39 call assert_equal(len(split(orig_buffer_menus, "\n")) + 2, len(split(new_buffer_menus, "\n")))
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
40 bwipe!
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
41 call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
42
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
43 " Make a new command-line window, test that it does not create a new buffer
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
44 " menu.
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
45 call feedkeys("q::let cmdline_buffer_menus=execute('nmenu Buffers')\<CR>:q\<CR>", 'ntx')
19844
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
46 call assert_equal(len(split(orig_buffer_menus, "\n")) + 2, len(split(cmdline_buffer_menus, "\n")))
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
47 call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
48
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
49 if has('terminal')
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
50 " Open a terminal window and test that it does not create a buffer menu
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
51 " item.
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
52 terminal
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
53 let term_buffer_menus = execute('nmenu Buffers')
19844
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
54 call assert_equal(len(split(orig_buffer_menus, "\n")) + 2, len(split(term_buffer_menus, "\n")))
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
55 bwipe!
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
56 call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
57 endif
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
58
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
59 " Remove menus to clean up
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
60 source $VIMRUNTIME/delmenu.vim
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
61 call assert_equal('', v:errmsg)
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
62 endfunc
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
63
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
64 func Test_translate_menu()
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
65 if !has('multi_lang')
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
66 return
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
67 endif
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
68 if !filereadable($VIMRUNTIME . '/lang/menu_de_de.latin1.vim')
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
69 throw 'Skipped: translated menu not found'
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
70 endif
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
71
11048
860d023f0fc8 patch 8.0.0413: menu test fails on MS-Windows using gvim
Christian Brabandt <cb@256bit.org>
parents: 11046
diff changeset
72 " First delete any English menus.
860d023f0fc8 patch 8.0.0413: menu test fails on MS-Windows using gvim
Christian Brabandt <cb@256bit.org>
parents: 11046
diff changeset
73 source $VIMRUNTIME/delmenu.vim
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
74 set langmenu=de_de
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
75 source $VIMRUNTIME/menu.vim
11046
d48f4eeb91ec patch 8.0.0412: menu test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11044
diff changeset
76 call assert_match('browse confirm w', execute(':menu Datei.Speichern'))
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
77
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
78 source $VIMRUNTIME/delmenu.vim
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
79 endfunc
14952
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
80
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
81 func Test_menu_commands()
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
82 nmenu 2 Test.FooBar :let g:did_menu = 'normal'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
83 vmenu 2 Test.FooBar :let g:did_menu = 'visual'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
84 smenu 2 Test.FooBar :let g:did_menu = 'select'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
85 omenu 2 Test.FooBar :let g:did_menu = 'op-pending'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
86 tlmenu 2 Test.FooBar :let g:did_menu = 'terminal'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
87 imenu 2 Test.FooBar :let g:did_menu = 'insert'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
88 cmenu 2 Test.FooBar :let g:did_menu = 'cmdline'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
89 emenu n Test.FooBar
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18860
diff changeset
90
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18860
diff changeset
91 call feedkeys(":menu Test.FooB\<C-A>\<C-B>\"\<CR>", 'tx')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18860
diff changeset
92 call assert_equal('"menu Test.FooBar', @:)
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18860
diff changeset
93
14952
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
94 call assert_equal('normal', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
95 emenu v Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
96 call assert_equal('visual', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
97 emenu s Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
98 call assert_equal('select', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
99 emenu o Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
100 call assert_equal('op-pending', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
101 emenu t Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
102 call assert_equal('terminal', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
103 emenu i Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
104 call assert_equal('insert', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
105 emenu c Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
106 call assert_equal('cmdline', g:did_menu)
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
107
16541
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
108 nunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
109 call assert_fails('emenu n Test.FooBar', 'E335: Menu not defined for Normal mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
110 vunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
111 call assert_fails('emenu v Test.FooBar', 'E335: Menu not defined for Visual mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
112 vmenu 2 Test.FooBar :let g:did_menu = 'visual'<CR>
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
113 sunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
114 call assert_fails('emenu s Test.FooBar', 'E335: Menu not defined for Select mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
115 ounmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
116 call assert_fails('emenu o Test.FooBar', 'E335: Menu not defined for Op-pending mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
117 iunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
118 call assert_fails('emenu i Test.FooBar', 'E335: Menu not defined for Insert mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
119 cunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
120 call assert_fails('emenu c Test.FooBar', 'E335: Menu not defined for Cmdline mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
121 tlunmenu Test.FooBar
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
122 call assert_fails('emenu t Test.FooBar', 'E335: Menu not defined for Terminal mode')
822d00007b34 patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Bram Moolenaar <Bram@vim.org>
parents: 14952
diff changeset
123
14952
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
124 aunmenu Test.FooBar
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
125 call assert_fails('emenu n Test.FooBar', 'E334:')
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
126
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
127 nmenu 2 Test.FooBar.Child :let g:did_menu = 'foobar'<CR>
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
128 call assert_fails('emenu n Test.FooBar', 'E333:')
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
129 nunmenu Test.FooBar.Child
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
130
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
131 unlet g:did_menu
405309f9dd13 patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents: 11183
diff changeset
132 endfun
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
133
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
134 " Test various menu related errors
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
135 func Test_menu_errors()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
136 menu Test.Foo :version<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
137
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
138 " Error cases
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
139 call assert_fails('menu .Test.Foo :ls<CR>', 'E475:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
140 call assert_fails('menu Test. :ls<CR>', 'E330:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
141 call assert_fails('menu Foo. :ls<CR>', 'E331:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
142 call assert_fails('unmenu Test.Foo abc', 'E488:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
143 call assert_fails('menu <Tab>:ls :ls<CR>', 'E792:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
144 call assert_fails('menu Test.<Tab>:ls :ls<CR>', 'E792:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
145 call assert_fails('menu Test.Foo.Bar :ls<CR>', 'E327:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
146 call assert_fails('menu Test.-Sep-.Baz :ls<CR>', 'E332:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
147 call assert_fails('menu Foo.Bar.--.Baz :ls<CR>', 'E332:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
148 call assert_fails('menu disable Test.Foo.Bar', 'E327:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
149 call assert_fails('menu disable T.Foo', 'E329:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
150 call assert_fails('unmenu Test.Foo.Bar', 'E327:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
151 call assert_fails('cunmenu Test.Foo', 'E328:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
152 call assert_fails('unmenu Test.Bar', 'E329:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
153 call assert_fails('menu Test.Foo.Bar', 'E327:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
154 call assert_fails('cmenu Test.Foo', 'E328:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
155 call assert_fails('emenu x Test.Foo', 'E475:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
156 call assert_fails('emenu Test.Foo.Bar', 'E334:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
157 call assert_fails('menutranslate Test', 'E474:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
158
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
159 silent! unmenu Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
160 unmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
161 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
162
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
163 " Test for menu item completion in command line
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
164 func Test_menu_expand()
19844
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
165 " Make sure we don't have stale menu items like Buffers menu.
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
166 source $VIMRUNTIME/delmenu.vim
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
167
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
168 " Create the menu itmes for test
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
169 menu Dummy.Nothing lll
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
170 for i in range(1, 4)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
171 let m = 'menu Xmenu.A' .. i .. '.A' .. i
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
172 for j in range(1, 4)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
173 exe m .. 'B' .. j .. ' :echo "A' .. i .. 'B' .. j .. '"' .. "<CR>"
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
174 endfor
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
175 endfor
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
176 set wildmenu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
177
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
178 " Test for <CR> selecting a submenu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
179 call feedkeys(":emenu Xmenu.A\<Tab>\<CR>\<Right>x\<BS>\<C-B>\"\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
180 call assert_equal('"emenu Xmenu.A1.A1B2', @:)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
181
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
182 " Test for <Down> selecting a submenu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
183 call feedkeys(":emenu Xmenu.A\<Tab>\<Right>\<Right>\<Down>" ..
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
184 \ "\<C-A>\<C-B>\"\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
185 call assert_equal('"emenu Xmenu.A3.A3B1 A3B2 A3B3 A3B4', @:)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
186
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
187 " Test for <Up> to go up a submenu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
188 call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Right>\<Right>" ..
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
189 \ "\<Left>\<Down>\<C-A>\<C-B>\"\<CR>", 'xt')
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
190 call assert_equal('"emenu Xmenu.A2.A2B1 A2B2 A2B3 A2B4', @:)
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
191
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
192 " Test for <Up> to go up a menu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
193 call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Up>\<Up>" ..
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
194 \ "\<C-A>\<C-B>\"\<CR>", 'xt')
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
195 call assert_equal('"emenu Dummy. Xmenu.', @:)
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
196
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
197 " Test for expanding only submenus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
198 call feedkeys(":popup Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
199 call assert_equal('"popup Xmenu.A1 A2 A3 A4', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
200
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
201 " Test for expanding menus after enable/disable
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
202 call feedkeys(":menu enable Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
203 call assert_equal('"menu enable Xmenu.A1. A2. A3. A4.', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
204 call feedkeys(":menu disable Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
205 call assert_equal('"menu disable Xmenu.A1. A2. A3. A4.', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
206
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
207 " Test for expanding non-existing menu path
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
208 call feedkeys(":menu xyz.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
209 call assert_equal('"menu xyz.', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
210 call feedkeys(":menu Xmenu.A1.A1B1.xyz.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
211 call assert_equal('"menu Xmenu.A1.A1B1.xyz.', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
212
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
213 set wildmenu&
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
214 unmenu Xmenu
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
215 unmenu Dummy
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
216
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
217 " Test for expanding popup menus with some hidden items
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
218 menu Xmenu.foo.A1 a1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
219 menu Xmenu.]bar bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
220 menu Xmenu.]baz.B1 b1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
221 menu Xmenu.-sep- :
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
222 call feedkeys(":popup Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
223 call assert_equal('"popup Xmenu.foo', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
224 unmenu Xmenu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
225 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
226
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
227 " Test for the menu_info() function
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
228 func Test_menu_info()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
229 " Define menus with various attributes
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
230 10nnoremenu 10.10 T&est.F&oo :echo 'foo'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
231 10nmenu <silent> 10.20 T&est.B&ar<Tab>:bar :echo 'bar'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
232 10nmenu <script> 10.30.5 T&est.Ba&z.Qu&x :echo 'qux'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
233
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
234 let d = #{name: "B&ar\t:bar", display: 'Bar', modes: 'n', shortcut: 'a',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
235 \ accel: ':bar', priority: 20, enabled: v:true, silent: v:true,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
236 \ noremenu: v:false, script: v:false, rhs: ":echo 'bar'<CR>"}
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
237 call assert_equal(d, menu_info('Test.Bar'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
238
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
239 let d = #{name: 'Ba&z', display: 'Baz', modes: 'n', shortcut: 'z',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
240 \ priority: 30, submenus: ['Qux']}
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
241 call assert_equal(d, menu_info('Test.Baz'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
242
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
243 let d = #{name: 'T&est', display: 'Test', modes: 'n', shortcut: 'e',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
244 \ priority: 10, submenus: ['Foo', 'Bar', 'Baz']}
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
245 call assert_equal(d, menu_info('Test'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
246 call assert_equal({}, menu_info('Test.Dummy'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
247 call assert_equal({}, menu_info('Dummy'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
248
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
249 nmenu disable Test.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
250 call assert_equal(v:false, menu_info('Test.Foo').enabled)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
251 nmenu enable Test.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
252 call assert_equal(v:true, menu_info('Test.Foo').enabled)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
253
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
254 call assert_equal(menu_info('Test.Foo'), menu_info('Test.Foo', ''))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
255 nmenu Test.abc <Nop>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
256 call assert_equal('<Nop>', menu_info('Test.abc').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
257 call assert_fails('call menu_info([])', 'E730:')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
258 nunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
259
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
260 " Test for defining menus in different modes
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
261 menu Test.menu :menu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
262 menu! Test.menu! :menu!<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
263 amenu Test.amenu :amenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
264 nmenu Test.nmenu :nmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
265 omenu Test.omenu :omenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
266 vmenu Test.vmenu :vmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
267 xmenu Test.xmenu :xmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
268 smenu Test.smenu :smenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
269 imenu <silent> <script> Test.imenu :imenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
270 cmenu Test.cmenu :cmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
271 tlmenu Test.tlmenu :tlmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
272 tmenu Test.nmenu Normal mode menu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
273 tmenu Test.omenu Op-pending mode menu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
274 noremenu Test.noremenu :noremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
275 noremenu! Test.noremenu! :noremenu!<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
276 anoremenu Test.anoremenu :anoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
277 nnoremenu Test.nnoremenu :nnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
278 onoremenu Test.onoremenu :onoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
279 vnoremenu Test.vnoremenu :vnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
280 xnoremenu Test.xnoremenu :xnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
281 snoremenu Test.snoremenu :snoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
282 inoremenu <silent> Test.inoremenu :inoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
283 cnoremenu Test.cnoremenu :cnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
284 tlnoremenu Test.tlnoremenu :tlnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
285 call assert_equal(#{name: 'menu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
286 \ display: 'menu', modes: ' ', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
287 \ rhs: ":menu<CR>", noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
288 \ menu_info('Test.menu'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
289 call assert_equal(#{name: 'menu!', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
290 \ display: 'menu!', modes: '!', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
291 \ rhs: ":menu!<CR>", noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
292 \ menu_info('Test.menu!', '!'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
293 call assert_equal(#{name: 'amenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
294 \ display: 'amenu', modes: 'a', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
295 \ rhs: ":amenu<CR>", noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
296 \ menu_info('Test.amenu', 'a'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
297 call assert_equal(#{name: 'nmenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
298 \ display: 'nmenu', modes: 'n', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
299 \ rhs: ':nmenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
300 \ menu_info('Test.nmenu', 'n'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
301 call assert_equal(#{name: 'omenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
302 \ display: 'omenu', modes: 'o', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
303 \ rhs: ':omenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
304 \ menu_info('Test.omenu', 'o'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
305 call assert_equal(#{name: 'vmenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
306 \ display: 'vmenu', modes: 'v', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
307 \ rhs: ':vmenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
308 \ menu_info('Test.vmenu', 'v'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
309 call assert_equal(#{name: 'xmenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
310 \ display: 'xmenu', modes: 'x', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
311 \ rhs: ':xmenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
312 \ menu_info('Test.xmenu', 'x'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
313 call assert_equal(#{name: 'smenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
314 \ display: 'smenu', modes: 's', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
315 \ rhs: ':smenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
316 \ menu_info('Test.smenu', 's'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
317 call assert_equal(#{name: 'imenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
318 \ display: 'imenu', modes: 'i', enabled: v:true, silent: v:true,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
319 \ rhs: ':imenu<CR>', noremenu: v:false, script: v:true},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
320 \ menu_info('Test.imenu', 'i'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
321 call assert_equal(#{ name: 'cmenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
322 \ display: 'cmenu', modes: 'c', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
323 \ rhs: ':cmenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
324 \ menu_info('Test.cmenu', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
325 call assert_equal(#{name: 'tlmenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
326 \ display: 'tlmenu', modes: 'tl', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
327 \ rhs: ':tlmenu<CR>', noremenu: v:false, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
328 \ menu_info('Test.tlmenu', 'tl'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
329 call assert_equal(#{name: 'noremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
330 \ display: 'noremenu', modes: ' ', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
331 \ rhs: ":noremenu<CR>", noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
332 \ menu_info('Test.noremenu'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
333 call assert_equal(#{name: 'noremenu!', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
334 \ display: 'noremenu!', modes: '!', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
335 \ rhs: ":noremenu!<CR>", noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
336 \ menu_info('Test.noremenu!', '!'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
337 call assert_equal(#{name: 'anoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
338 \ display: 'anoremenu', modes: 'a', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
339 \ rhs: ":anoremenu<CR>", noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
340 \ menu_info('Test.anoremenu', 'a'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
341 call assert_equal(#{name: 'nnoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
342 \ display: 'nnoremenu', modes: 'n', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
343 \ rhs: ':nnoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
344 \ menu_info('Test.nnoremenu', 'n'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
345 call assert_equal(#{name: 'onoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
346 \ display: 'onoremenu', modes: 'o', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
347 \ rhs: ':onoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
348 \ menu_info('Test.onoremenu', 'o'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
349 call assert_equal(#{name: 'vnoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
350 \ display: 'vnoremenu', modes: 'v', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
351 \ rhs: ':vnoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
352 \ menu_info('Test.vnoremenu', 'v'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
353 call assert_equal(#{name: 'xnoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
354 \ display: 'xnoremenu', modes: 'x', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
355 \ rhs: ':xnoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
356 \ menu_info('Test.xnoremenu', 'x'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
357 call assert_equal(#{name: 'snoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
358 \ display: 'snoremenu', modes: 's', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
359 \ rhs: ':snoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
360 \ menu_info('Test.snoremenu', 's'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
361 call assert_equal(#{name: 'inoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
362 \ display: 'inoremenu', modes: 'i', enabled: v:true, silent: v:true,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
363 \ rhs: ':inoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
364 \ menu_info('Test.inoremenu', 'i'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
365 call assert_equal(#{ name: 'cnoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
366 \ display: 'cnoremenu', modes: 'c', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
367 \ rhs: ':cnoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
368 \ menu_info('Test.cnoremenu', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
369 call assert_equal(#{name: 'tlnoremenu', priority: 500, shortcut: '',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
370 \ display: 'tlnoremenu', modes: 'tl', enabled: v:true, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
371 \ rhs: ':tlnoremenu<CR>', noremenu: v:true, script: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
372 \ menu_info('Test.tlnoremenu', 'tl'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
373 aunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
374 tlunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
375 call assert_equal({}, menu_info('Test'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
376 call assert_equal({}, menu_info('Test', '!'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
377 call assert_equal({}, menu_info('Test', 'a'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
378 call assert_equal({}, menu_info('Test', 'n'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
379 call assert_equal({}, menu_info('Test', 'o'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
380 call assert_equal({}, menu_info('Test', 'v'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
381 call assert_equal({}, menu_info('Test', 'x'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
382 call assert_equal({}, menu_info('Test', 's'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
383 call assert_equal({}, menu_info('Test', 'i'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
384 call assert_equal({}, menu_info('Test', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
385 call assert_equal({}, menu_info('Test', 't'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
386 call assert_equal({}, menu_info('Test', 'tl'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
387
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
388 amenu Test.amenu :amenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
389 call assert_equal(':amenu<CR>', menu_info('Test.amenu', '').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
390 call assert_equal('<C-\><C-O>:amenu<CR>', menu_info('Test.amenu', '!').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
391 call assert_equal(':amenu<CR>', menu_info('Test.amenu', 'n').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
392 call assert_equal('<C-C>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
393 \ menu_info('Test.amenu', 'o').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
394 call assert_equal('<C-C>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
395 \ menu_info('Test.amenu', 'v').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
396 call assert_equal('<C-C>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
397 \ menu_info('Test.amenu', 'x').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
398 call assert_equal('<C-C>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
399 \ menu_info('Test.amenu', 's').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
400 call assert_equal('<C-\><C-O>:amenu<CR>', menu_info('Test.amenu', 'i').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
401 call assert_equal('<C-C>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
402 \ menu_info('Test.amenu', 'c').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
403 aunmenu Test.amenu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
404
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
405 " Test for hidden menus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
406 menu ]Test.menu :menu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
407 call assert_equal(#{name: ']Test', display: ']Test', priority: 500,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
408 \ shortcut: '', modes: ' ', submenus: ['menu']},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
409 \ menu_info(']Test'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
410 unmenu ]Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
411 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
412
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
413 " Test for <special> keyword in a menu with 'cpo' containing '<'
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
414 func Test_menu_special()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
415 new
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
416 set cpo+=<
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
417 nmenu Test.Sign am<Tab>n<Esc>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
418 call feedkeys(":emenu n Test.Sign\<CR>", 'x')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
419 call assert_equal("m<Tab>n<Esc>", getline(1))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
420 nunmenu Test.Sign
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
421 nmenu <special> Test.Sign am<Tab>n<Esc>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
422 call setline(1, '')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
423 call feedkeys(":emenu n Test.Sign\<CR>", 'x')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
424 call assert_equal("m\tn", getline(1))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
425 set cpo-=<
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
426 close!
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
427 nunmenu Test.Sign
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
428 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
429
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
430 " Test for "icon=filname" in a toolbar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
431 func Test_menu_icon()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
432 CheckFeature toolbar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
433 nmenu icon=myicon.xpm Toolbar.Foo :echo "Foo"<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
434 call assert_equal('myicon.xpm', "Toolbar.Foo"->menu_info().icon)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
435 nunmenu Toolbar.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
436
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
437 " Test for using the builtin icon
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
438 amenu ToolBar.BuiltIn22 :echo "BuiltIn22"<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
439 call assert_equal(#{name: 'BuiltIn22', display: 'BuiltIn22',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
440 \ enabled: v:true, shortcut: '', modes: 'a', script: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
441 \ iconidx: 22, priority: 500, silent: v:false,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
442 \ rhs: ':echo "BuiltIn22"<CR>', noremenu: v:false},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
443 \ menu_info("ToolBar.BuiltIn22"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
444 aunmenu ToolBar.BuiltIn22
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
445 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
446
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
447 " Test for ":emenu" command in different modes
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
448 func Test_emenu_cmd()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
449 new
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
450 xmenu Test.foo rx
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
451 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
452 normal ggVj
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
453 %emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
454 call assert_equal(['xxxx', 'xxxx'], getline(1, 2))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
455 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
456 exe "normal ggVj\<Esc>"
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
457 %emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
458 call assert_equal(['xxxx', 'xxxx'], getline(1, 2))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
459 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
460 exe "normal ggV\<Esc>"
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
461 2emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
462 call assert_equal(['aaaa', 'xxxx'], getline(1, 2))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
463 xunmenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
464 close!
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
465 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
466
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
467 " Test for PopUp menus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
468 func Test_popup_menu()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
469 20menu PopUp.foo :echo 'foo'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
470 20menu PopUp.bar :echo 'bar'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
471 call assert_equal(#{name: 'PopUp', display: 'PopUp', priority: 20,
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
472 \ shortcut: '', modes: ' ', submenus: ['foo', 'bar']},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
473 \ menu_info('PopUp'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
474 menu disable PopUp.bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
475 call assert_equal(v:true, "PopUp.foo"->menu_info().enabled)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
476 call assert_equal(v:false, "PopUp.bar"->menu_info().enabled)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
477 menu enable PopUp.bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
478 call assert_equal(v:true, "PopUp.bar"->menu_info().enabled)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
479 unmenu PopUp
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
480 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
481
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
482 " Test for listing the menus using the :menu command
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
483 func Test_show_menus()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
484 " In the GUI, tear-off menu items are present in the output below
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
485 " So skip this test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
486 CheckNotGui
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
487 aunmenu *
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
488 call assert_equal(['--- Menus ---'], split(execute('menu'), "\n"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
489 nmenu <script> 200.10 Test.nmenu1 :nmenu1<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
490 nmenu 200.20 Test.nmenu2 :nmenu2<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
491 nnoremenu 200.30 Test.nmenu3 :nmenu3<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
492 nmenu 200.40 Test.nmenu4 :nmenu4<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
493 nmenu 200.50 disable Test.nmenu4
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
494 let exp =<< trim [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
495 --- Menus ---
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
496 200 Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
497 10 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
498 n& :nmenu1<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
499 20 nmenu2
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
500 n :nmenu2<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
501 30 nmenu3
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
502 n* :nmenu3<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
503 40 nmenu4
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
504 n - :nmenu4<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
505 [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
506 call assert_equal(exp, split(execute('nmenu'), "\n"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
507 nunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
508 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
509
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
510 " Test for menu tips
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
511 func Test_tmenu()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
512 tunmenu *
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
513 call assert_equal(['--- Menus ---'], split(execute('tmenu'), "\n"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
514 tmenu Test.nmenu1 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
515 tmenu Test.nmenu2.sub1 nmenu2.sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
516 let exp =<< trim [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
517 --- Menus ---
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
518 500 Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
519 500 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
520 t - nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
521 500 nmenu2
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
522 500 sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
523 t - nmenu2.sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
524 [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
525 call assert_equal(exp, split(execute('tmenu'), "\n"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
526 tunmenu Test
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
527 endfunc
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
528
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
529 " vim: shiftwidth=2 sts=2 expandtab