annotate src/testdir/test_menu.vim @ 32697:e5cd5e8627da v9.0.1679

patch 9.0.1679: Cleanup Tests from leftover files Commit: https://github.com/vim/vim/commit/84bc00e9b52b1174888f2f696f8b628a83c49988 Author: Christian Brabandt <cb@256bit.org> Date: Thu Jul 13 11:45:54 2023 +0200 patch 9.0.1679: Cleanup Tests from leftover files Problem: Tests may leave leftover files around Solution: Clean up tests and remove files There were a few failures in 'linux (huge, gcc, testgui, true, true)' e.g. here: https://github.com/vim/vim/actions/runs/5497376153/jobs/10018060156 ,---- | Error detected while processing command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[585]..function RunTheTest[54]..Test_lvimgrep_crash[16]..TestTimeout[12]..VimLeavePre Autocommands for "*"..function EarlyExit[7]..FinishTesting: | line 70: | E445: Other window contains changes | E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txt | E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txt | E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txtmalloc(): unsorted double linked list corrupted `---- Which is puzzling, because the Xtest_stable_xxd file should have been long gone after test_crypt.vim is run (and definitely no longer be staying around in test_quickfix.vim). So try to clean up properly after a test script is run, just in case any X<file> is still around. During testing, a found a few leftover files, which I also fixed in the relevant test-file. Unfortunately, the test workflow 'linux (huge, gcc, testgui, true, true)' now seems to fail with 'E1230: Encryption: sodium_mlock()' in test_crypt.vim. Hopefully this is only temporary.
author Christian Brabandt <cb@256bit.org>
date Tue, 08 Aug 2023 20:45:05 +0200
parents 64e6e523d32d
children c9d6178da2e2
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
31079
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
6 source screendump.vim
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
7
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_load_menu()
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 try
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 source $VIMRUNTIME/menu.vim
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 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
12 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
13 endtry
11048
860d023f0fc8 patch 8.0.0413: menu test fails on MS-Windows using gvim
Christian Brabandt <cb@256bit.org>
parents: 11046
diff changeset
14 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
15
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
16 let v:errmsg = ''
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
17 doautocmd LoadBufferMenu VimEnter
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
18 call assert_equal('', v:errmsg)
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
19
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
20 source $VIMRUNTIME/delmenu.vim
18860
ec92ccff5c8b patch 8.1.2416: loading menus sets v:errmsg
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
21 call assert_equal('', v:errmsg)
7488
6f14d7da2d8a commit https://github.com/vim/vim/commit/2d6c8002729821acc54a4de41d5c5f3d50594973
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 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
23
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
24 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
25 " 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
26 try
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
27 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
28 catch
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
29 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
30 endtry
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
31
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
32 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
33 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
34 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
35
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
36 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
37
19844
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
38 " 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
39 new
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
40 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
41 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
42 bwipe!
d53e8428a79a patch 8.2.0478: new buffers are not added to the Buffers menu
Bram Moolenaar <Bram@vim.org>
parents: 19713
diff changeset
43 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
44
19713
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
45 " 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
46 " menu.
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
47 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
48 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
49 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
50
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
51 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
52 " 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
53 " item.
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
54 terminal
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
55 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
56 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
57 bwipe!
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
58 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
59 endif
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
60
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
61 " 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
62 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
63 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
64 endfunc
8514e8b7e661 patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents: 19657
diff changeset
65
11044
eb3a2ff3309a patch 8.0.0411: menu translations don't match when case is changed.
Christian Brabandt <cb@256bit.org>
parents: 7488
diff changeset
66 func Test_translate_menu()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
67 CheckFeature multi_lang
11044
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:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
156 call assert_fails('emenu Test.Foo.Bar', 'E327:')
19657
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()
32244
533e36e02a68 patch 9.0.1453: typos in source code and tests
Bram Moolenaar <Bram@vim.org>
parents: 31467
diff changeset
165 " Create the menu items 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
166 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
167 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
168 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
169 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
170 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
171 endfor
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
172 endfor
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
173 set wildmenu
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
174
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
175 " 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
176 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
177 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
178
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
179 " 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
180 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
181 \ "\<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
182 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
183
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
184 " 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
185 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
186 \ "\<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
187 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
188
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
189 " 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
190 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
191 \ "\<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
192 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
193
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
194 " Test for expanding only submenus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
195 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
196 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
197
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
198 " 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
199 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
200 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
201 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
202 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
203
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
204 " 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
205 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
206 call assert_equal('"menu xyz.', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
207 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
208 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
209
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
210 set wildmenu&
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
211 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
212 unmenu Dummy
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
213
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
214 " 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
215 menu Xmenu.foo.A1 a1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
216 menu Xmenu.]bar bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
217 menu Xmenu.]baz.B1 b1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
218 menu Xmenu.-sep- :
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
219 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
220 call assert_equal('"popup Xmenu.foo', @:)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
221 unmenu Xmenu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
222 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
223
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
224 " Test for the menu_info() function
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
225 func Test_menu_info()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
226 " Define menus with various attributes
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
227 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
228 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
229 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
230
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
231 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
232 \ 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
233 \ 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
234 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
235
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
236 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
237 \ priority: 30, submenus: ['Qux']}
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
238 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
239
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
240 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
241 \ priority: 10, submenus: ['Foo', 'Bar', 'Baz']}
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
242 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
243 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
244 call assert_equal({}, menu_info('Dummy'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
245
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
246 nmenu disable Test.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
247 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
248 nmenu enable Test.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
249 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
250
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
251 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
252 nmenu Test.abc <Nop>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
253 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
254 call assert_fails('call menu_info([])', 'E730:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19844
diff changeset
255 call assert_fails('call menu_info("", [])', 'E730:')
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
256 nunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
257
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
258 " 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
259 menu Test.menu :menu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
260 menu! Test.menu! :menu!<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
261 amenu Test.amenu :amenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
262 nmenu Test.nmenu :nmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
263 omenu Test.omenu :omenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
264 vmenu Test.vmenu :vmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
265 xmenu Test.xmenu :xmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
266 smenu Test.smenu :smenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
267 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
268 cmenu Test.cmenu :cmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
269 tlmenu Test.tlmenu :tlmenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
270 tmenu Test.nmenu Normal mode menu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
271 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
272 noremenu Test.noremenu :noremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
273 noremenu! Test.noremenu! :noremenu!<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
274 anoremenu Test.anoremenu :anoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
275 nnoremenu Test.nnoremenu :nnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
276 onoremenu Test.onoremenu :onoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
277 vnoremenu Test.vnoremenu :vnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
278 xnoremenu Test.xnoremenu :xnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
279 snoremenu Test.snoremenu :snoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
280 inoremenu <silent> Test.inoremenu :inoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
281 cnoremenu Test.cnoremenu :cnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
282 tlnoremenu Test.tlnoremenu :tlnoremenu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
283 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
284 \ 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
285 \ 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
286 \ menu_info('Test.menu'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
287 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
288 \ 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
289 \ 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
290 \ menu_info('Test.menu!', '!'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
291 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
292 \ 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
293 \ 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
294 \ menu_info('Test.amenu', 'a'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
295 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
296 \ 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
297 \ 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
298 \ menu_info('Test.nmenu', 'n'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
299 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
300 \ 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
301 \ 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
302 \ menu_info('Test.omenu', 'o'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
303 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
304 \ 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
305 \ 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
306 \ menu_info('Test.vmenu', 'v'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
307 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
308 \ 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
309 \ 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
310 \ menu_info('Test.xmenu', 'x'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
311 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
312 \ 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
313 \ 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
314 \ menu_info('Test.smenu', 's'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
315 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
316 \ 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
317 \ 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
318 \ menu_info('Test.imenu', 'i'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
319 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
320 \ 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
321 \ 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
322 \ menu_info('Test.cmenu', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
323 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
324 \ 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
325 \ 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
326 \ menu_info('Test.tlmenu', 'tl'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
327 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
328 \ 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
329 \ 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
330 \ menu_info('Test.noremenu'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
331 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
332 \ 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
333 \ 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
334 \ menu_info('Test.noremenu!', '!'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
335 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
336 \ 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
337 \ 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
338 \ menu_info('Test.anoremenu', 'a'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
339 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
340 \ 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
341 \ 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
342 \ menu_info('Test.nnoremenu', 'n'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
343 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
344 \ 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
345 \ 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
346 \ menu_info('Test.onoremenu', 'o'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
347 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
348 \ 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
349 \ 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
350 \ menu_info('Test.vnoremenu', 'v'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
351 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
352 \ 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
353 \ 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
354 \ menu_info('Test.xnoremenu', 'x'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
355 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
356 \ 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
357 \ 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
358 \ menu_info('Test.snoremenu', 's'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
359 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
360 \ 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
361 \ 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
362 \ menu_info('Test.inoremenu', 'i'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
363 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
364 \ 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
365 \ 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
366 \ menu_info('Test.cnoremenu', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
367 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
368 \ 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
369 \ 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
370 \ menu_info('Test.tlnoremenu', 'tl'))
29601
8f0ca93857a6 patch 9.0.0141: "delmenu" does not remove autocmmands
Bram Moolenaar <Bram@vim.org>
parents: 29332
diff changeset
371
8f0ca93857a6 patch 9.0.0141: "delmenu" does not remove autocmmands
Bram Moolenaar <Bram@vim.org>
parents: 29332
diff changeset
372 " Test for getting all the top-level menu names
8f0ca93857a6 patch 9.0.0141: "delmenu" does not remove autocmmands
Bram Moolenaar <Bram@vim.org>
parents: 29332
diff changeset
373 call assert_notequal(menu_info('').submenus, [])
8f0ca93857a6 patch 9.0.0141: "delmenu" does not remove autocmmands
Bram Moolenaar <Bram@vim.org>
parents: 29332
diff changeset
374
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
375 aunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
376 tlunmenu 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'))
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', '!'))
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', 'a'))
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', 'n'))
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', 'o'))
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', 'v'))
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', 'x'))
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', 's'))
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', 'i'))
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', 'c'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
387 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
388 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
389
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
390 amenu Test.amenu :amenu<CR>
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', '').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-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
393 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
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', 'o').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', 'v').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', 'x').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>:amenu<CR><C-\><C-G>',
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
401 \ menu_info('Test.amenu', 's').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
402 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
403 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
404 \ menu_info('Test.amenu', 'c').rhs)
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
405 aunmenu Test.amenu
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
406
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
407 " Test for hidden menus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
408 menu ]Test.menu :menu<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
409 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
410 \ shortcut: '', modes: ' ', submenus: ['menu']},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
411 \ menu_info(']Test'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
412 unmenu ]Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
413 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
414
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
415 " 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
416 func Test_menu_special()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
417 new
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
418 set cpo+=<
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
419 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
420 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
421 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
422 nunmenu Test.Sign
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
423 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
424 call setline(1, '')
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
425 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
426 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
427 set cpo-=<
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
428 close!
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
429 nunmenu Test.Sign
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
430 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
431
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
432 " Test for "icon=filename" in a toolbar
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
433 func Test_menu_icon()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
434 CheckFeature toolbar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
435 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
436 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
437 nunmenu Toolbar.Foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
438
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
439 " Test for using the builtin icon
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
440 amenu ToolBar.BuiltIn22 :echo "BuiltIn22"<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
441 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
442 \ 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
443 \ 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
444 \ 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
445 \ menu_info("ToolBar.BuiltIn22"))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
446 aunmenu ToolBar.BuiltIn22
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
447 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
448
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
449 " 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
450 func Test_emenu_cmd()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
451 new
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
452 xmenu Test.foo rx
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
453 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
454 normal ggVj
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
455 %emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
456 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
457 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
458 exe "normal ggVj\<Esc>"
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
459 %emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
460 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
461 call setline(1, ['aaaa', 'bbbb'])
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
462 exe "normal ggV\<Esc>"
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
463 2emenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
464 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
465 xunmenu Test.foo
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
466 close!
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
467 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
468
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
469 " Test for PopUp menus
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
470 func Test_popup_menu()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
471 20menu PopUp.foo :echo 'foo'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
472 20menu PopUp.bar :echo 'bar'<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
473 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
474 \ shortcut: '', modes: ' ', submenus: ['foo', 'bar']},
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
475 \ menu_info('PopUp'))
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
476 menu disable PopUp.bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
477 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
478 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
479 menu enable PopUp.bar
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
480 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
481 unmenu PopUp
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
482 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
483
30757
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
484 " Test for MenuPopup autocommand
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
485 func Test_autocmd_MenuPopup()
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
486 CheckNotGui
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
487
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
488 set mouse=a
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
489 set mousemodel=popup
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
490 aunmenu *
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
491 autocmd MenuPopup * exe printf(
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
492 \ 'anoremenu PopUp.Foo <Cmd>let g:res = ["%s", "%s"]<CR>',
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
493 \ expand('<afile>'), expand('<amatch>'))
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
494
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
495 call feedkeys("\<RightMouse>\<Down>\<CR>", 'tnix')
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
496 call assert_equal(['n', 'n'], g:res)
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
497
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
498 call feedkeys("v\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
499 call assert_equal(['v', 'v'], g:res)
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
500
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
501 call feedkeys("gh\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
502 call assert_equal(['s', 's'], g:res)
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
503
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
504 call feedkeys("i\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
505 call assert_equal(['i', 'i'], g:res)
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
506
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
507 autocmd! MenuPopup
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
508 aunmenu PopUp.Foo
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
509 unlet g:res
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
510 set mouse& mousemodel&
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
511 endfunc
74043ee52030 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name
Bram Moolenaar <Bram@vim.org>
parents: 29601
diff changeset
512
19657
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
513 " 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
514 func Test_show_menus()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
515 " 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
516 " So skip this test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
517 CheckNotGui
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
518 aunmenu *
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
519 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
520 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
521 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
522 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
523 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
524 nmenu 200.50 disable Test.nmenu4
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
525 let exp =<< trim [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
526 --- Menus ---
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
527 200 Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
528 10 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
529 n& :nmenu1<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
530 20 nmenu2
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
531 n :nmenu2<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
532 30 nmenu3
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
533 n* :nmenu3<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
534 40 nmenu4
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
535 n - :nmenu4<CR>
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
536 [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
537 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
538 nunmenu Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
539 endfunc
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
540
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
541 " Test for menu tips
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
542 func Test_tmenu()
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
543 tunmenu *
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
544 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
545 tmenu Test.nmenu1 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
546 tmenu Test.nmenu2.sub1 nmenu2.sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
547 let exp =<< trim [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
548 --- Menus ---
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
549 500 Test
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
550 500 nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
551 t - nmenu1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
552 500 nmenu2
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
553 500 sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
554 t - nmenu2.sub1
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
555 [TEXT]
da791e5c0139 patch 8.2.0385: menu functionality insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19517
diff changeset
556 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
557 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
558 endfunc
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
559
29332
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
560 func Test_only_modifier()
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
561 exe "tmenu a.b \x80\xfc0"
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
562 let exp =<< trim [TEXT]
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
563 --- Menus ---
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
564 500 a
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
565 500 b
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
566 t - <T-2-^@>
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
567 [TEXT]
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
568 call assert_equal(exp, split(execute('tmenu'), "\n"))
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
569
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
570 tunmenu a.b
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
571 endfunc
a538982f74ea patch 9.0.0009: going past the end of a menu item with only modifier
Bram Moolenaar <Bram@vim.org>
parents: 25850
diff changeset
572
31467
4abd8f9edf47 patch 9.0.1066: test function name is wrong
Bram Moolenaar <Bram@vim.org>
parents: 31079
diff changeset
573 func Test_unmenu_while_listing_menus()
31079
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
574 CheckRunVimInTerminal
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
575
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
576 let lines =<< trim END
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
577 set nocompatible
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
578 unmenu *
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
579 for i in range(1, 999)
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
580 exe 'menu ' .. 'foo.' .. i .. ' bar'
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
581 endfor
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
582 au CmdlineLeave : call timer_start(0, {-> execute('unmenu *')})
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
583 END
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
584 call writefile(lines, 'Xmenuclear', 'D')
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
585 let buf = RunVimInTerminal('-S Xmenuclear', {'rows': 10})
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
586
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
587 " this was using freed memory
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
588 call term_sendkeys(buf, ":menu\<CR>")
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
589 call TermWait(buf, 50)
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
590 call term_sendkeys(buf, "G")
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
591 call TermWait(buf, 50)
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
592 call term_sendkeys(buf, "\<CR>")
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
593
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
594 call StopVimInTerminal(buf)
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
595 endfunc
082f526cfb96 patch 9.0.0874: using freed memory when executing unmenu at more prompt
Bram Moolenaar <Bram@vim.org>
parents: 30757
diff changeset
596
32297
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
597 " Test for opening a menu drawn in the cmdline area
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
598 func Test_popupmenu_cmdline()
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
599 CheckRunVimInTerminal
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
600
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
601 let lines =<< trim END
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
602 set mousemodel=popup
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
603 menu PopUp.Test1 :<CR>
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
604 menu PopUp.Test2 :<CR>
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
605 menu PopUp.Test3 :<CR>
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
606 call setline(1, repeat(['abcde'], 5))
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
607 END
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
608 call writefile(lines, 'Xpopupcmdline', 'D')
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
609 let buf = RunVimInTerminal('-S Xpopupcmdline', {'rows': 4})
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
610
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
611 " cmdline area should be cleared when popupmenu that covered it is closed
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
612 call term_sendkeys(buf, "\<RightMouse>\<RightRelease>\<Esc>")
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
613 call VerifyScreenDump(buf, 'Test_popupmenu_cmdline_1', {})
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
614
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
615 call StopVimInTerminal(buf)
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
616 endfunc
64e6e523d32d patch 9.0.1480: using popup menu may leave text in the command line
Bram Moolenaar <Bram@vim.org>
parents: 32244
diff changeset
617
19517
738a4fe2c8c5 patch 8.2.0316: ex_getln.c code has insufficient test coverage
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
618 " vim: shiftwidth=2 sts=2 expandtab