xref: /vim-8.2.3635/src/testdir/test_options.vim (revision d1caa941)
1" Test for options
2
3source check.vim
4source view_util.vim
5
6func Test_whichwrap()
7  set whichwrap=b,s
8  call assert_equal('b,s', &whichwrap)
9
10  set whichwrap+=h,l
11  call assert_equal('b,s,h,l', &whichwrap)
12
13  set whichwrap+=h,l
14  call assert_equal('b,s,h,l', &whichwrap)
15
16  set whichwrap+=h,l
17  call assert_equal('b,s,h,l', &whichwrap)
18
19  set whichwrap=h,h
20  call assert_equal('h', &whichwrap)
21
22  set whichwrap=h,h,h
23  call assert_equal('h', &whichwrap)
24
25  set whichwrap&
26endfunc
27
28func Test_isfname()
29  " This used to cause Vim to access uninitialized memory.
30  set isfname=
31  call assert_equal("~X", expand("~X"))
32  set isfname&
33endfunc
34
35func Test_wildchar()
36  " Empty 'wildchar' used to access invalid memory.
37  call assert_fails('set wildchar=', 'E521:')
38  call assert_fails('set wildchar=abc', 'E521:')
39  set wildchar=<Esc>
40  let a=execute('set wildchar?')
41  call assert_equal("\n  wildchar=<Esc>", a)
42  set wildchar=27
43  let a=execute('set wildchar?')
44  call assert_equal("\n  wildchar=<Esc>", a)
45  set wildchar&
46endfunc
47
48func Test_options_command()
49  let caught = 'ok'
50  try
51    options
52  catch
53    let caught = v:throwpoint . "\n" . v:exception
54  endtry
55  call assert_equal('ok', caught)
56
57  " Check if the option-window is opened horizontally.
58  wincmd j
59  call assert_notequal('option-window', bufname(''))
60  wincmd k
61  call assert_equal('option-window', bufname(''))
62  " close option-window
63  close
64
65  " Open the option-window vertically.
66  vert options
67  " Check if the option-window is opened vertically.
68  wincmd l
69  call assert_notequal('option-window', bufname(''))
70  wincmd h
71  call assert_equal('option-window', bufname(''))
72  " close option-window
73  close
74
75  " Open the option-window in a new tab.
76  tab options
77  " Check if the option-window is opened in a tab.
78  normal gT
79  call assert_notequal('option-window', bufname(''))
80  normal gt
81  call assert_equal('option-window', bufname(''))
82
83  " close option-window
84  close
85endfunc
86
87func Test_path_keep_commas()
88  " Test that changing 'path' keeps two commas.
89  set path=foo,,bar
90  set path-=bar
91  set path+=bar
92  call assert_equal('foo,,bar', &path)
93
94  set path&
95endfunc
96
97func Test_signcolumn()
98  if has('signs')
99    call assert_equal("auto", &signcolumn)
100    set signcolumn=yes
101    set signcolumn=no
102    call assert_fails('set signcolumn=nope')
103  endif
104endfunc
105
106func Test_filetype_valid()
107  set ft=valid_name
108  call assert_equal("valid_name", &filetype)
109  set ft=valid-name
110  call assert_equal("valid-name", &filetype)
111
112  call assert_fails(":set ft=wrong;name", "E474:")
113  call assert_fails(":set ft=wrong\\\\name", "E474:")
114  call assert_fails(":set ft=wrong\\|name", "E474:")
115  call assert_fails(":set ft=wrong/name", "E474:")
116  call assert_fails(":set ft=wrong\\\nname", "E474:")
117  call assert_equal("valid-name", &filetype)
118
119  exe "set ft=trunc\x00name"
120  call assert_equal("trunc", &filetype)
121endfunc
122
123func Test_syntax_valid()
124  if !has('syntax')
125    return
126  endif
127  set syn=valid_name
128  call assert_equal("valid_name", &syntax)
129  set syn=valid-name
130  call assert_equal("valid-name", &syntax)
131
132  call assert_fails(":set syn=wrong;name", "E474:")
133  call assert_fails(":set syn=wrong\\\\name", "E474:")
134  call assert_fails(":set syn=wrong\\|name", "E474:")
135  call assert_fails(":set syn=wrong/name", "E474:")
136  call assert_fails(":set syn=wrong\\\nname", "E474:")
137  call assert_equal("valid-name", &syntax)
138
139  exe "set syn=trunc\x00name"
140  call assert_equal("trunc", &syntax)
141endfunc
142
143func Test_keymap_valid()
144  if !has('keymap')
145    return
146  endif
147  call assert_fails(":set kmp=valid_name", "E544:")
148  call assert_fails(":set kmp=valid_name", "valid_name")
149  call assert_fails(":set kmp=valid-name", "E544:")
150  call assert_fails(":set kmp=valid-name", "valid-name")
151
152  call assert_fails(":set kmp=wrong;name", "E474:")
153  call assert_fails(":set kmp=wrong\\\\name", "E474:")
154  call assert_fails(":set kmp=wrong\\|name", "E474:")
155  call assert_fails(":set kmp=wrong/name", "E474:")
156  call assert_fails(":set kmp=wrong\\\nname", "E474:")
157
158  call assert_fails(":set kmp=trunc\x00name", "E544:")
159  call assert_fails(":set kmp=trunc\x00name", "trunc")
160endfunc
161
162func Check_dir_option(name)
163  " Check that it's possible to set the option.
164  exe 'set ' . a:name . '=/usr/share/dict/words'
165  call assert_equal('/usr/share/dict/words', eval('&' . a:name))
166  exe 'set ' . a:name . '=/usr/share/dict/words,/and/there'
167  call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name))
168  exe 'set ' . a:name . '=/usr/share/dict\ words'
169  call assert_equal('/usr/share/dict words', eval('&' . a:name))
170
171  " Check rejecting weird characters.
172  call assert_fails("set " . a:name . "=/not&there", "E474:")
173  call assert_fails("set " . a:name . "=/not>there", "E474:")
174  call assert_fails("set " . a:name . "=/not.*there", "E474:")
175endfunc
176
177func Test_cinkeys()
178  " This used to cause invalid memory access
179  set cindent cinkeys=0
180  norm a
181  set cindent& cinkeys&
182endfunc
183
184func Test_dictionary()
185  call Check_dir_option('dictionary')
186endfunc
187
188func Test_thesaurus()
189  call Check_dir_option('thesaurus')
190endfun
191
192func Test_complete()
193  " Trailing single backslash used to cause invalid memory access.
194  set complete=s\
195  new
196  call feedkeys("i\<C-N>\<Esc>", 'xt')
197  bwipe!
198  call assert_fails('set complete=ix', 'E535:')
199  set complete&
200endfun
201
202func Test_set_completion()
203  call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
204  call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
205
206  call feedkeys(":setlocal di\<C-A>\<C-B>\"\<CR>", 'tx')
207  call assert_equal('"setlocal dictionary diff diffexpr diffopt digraph directory display', @:)
208
209  call feedkeys(":setglobal di\<C-A>\<C-B>\"\<CR>", 'tx')
210  call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:)
211
212  " Expand boolan options. When doing :set no<Tab>
213  " vim displays the options names without "no" but completion uses "no...".
214  call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
215  call assert_equal('"set nodiff digraph', @:)
216
217  call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
218  call assert_equal('"set invdiff digraph', @:)
219
220  " Expand abbreviation of options.
221  call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
222  call assert_equal('"set tabstop thesaurus ttyscroll', @:)
223
224  " Expand current value
225  call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
226  call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
227
228  call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
229  call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
230
231  " Expand key codes.
232  call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
233  call assert_equal('"set <Help> <Home>', @:)
234
235  " Expand terminal options.
236  call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
237  call assert_equal('"set t_AB t_AF t_AL', @:)
238
239  " Expand directories.
240  call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
241  call assert_match(' ./samples/ ', @:)
242  call assert_notmatch(' ./small.vim ', @:)
243
244  " Expand files and directories.
245  call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
246  call assert_match(' ./samples/.* ./small.vim', @:)
247
248  call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
249  call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
250
251  set tags&
252endfunc
253
254func Test_set_errors()
255  call assert_fails('set scroll=-1', 'E49:')
256  call assert_fails('set backupcopy=', 'E474:')
257  call assert_fails('set regexpengine=3', 'E474:')
258  call assert_fails('set history=10001', 'E474:')
259  call assert_fails('set numberwidth=21', 'E474:')
260  call assert_fails('set colorcolumn=-a', 'E474:')
261  call assert_fails('set colorcolumn=a', 'E474:')
262  call assert_fails('set colorcolumn=1,', 'E474:')
263  call assert_fails('set colorcolumn=1;', 'E474:')
264  call assert_fails('set cmdheight=-1', 'E487:')
265  call assert_fails('set cmdwinheight=-1', 'E487:')
266  if has('conceal')
267    call assert_fails('set conceallevel=-1', 'E487:')
268    call assert_fails('set conceallevel=4', 'E474:')
269  endif
270  call assert_fails('set helpheight=-1', 'E487:')
271  call assert_fails('set history=-1', 'E487:')
272  call assert_fails('set report=-1', 'E487:')
273  call assert_fails('set shiftwidth=-1', 'E487:')
274  call assert_fails('set sidescroll=-1', 'E487:')
275  call assert_fails('set tabstop=-1', 'E487:')
276  call assert_fails('set textwidth=-1', 'E487:')
277  call assert_fails('set timeoutlen=-1', 'E487:')
278  call assert_fails('set updatecount=-1', 'E487:')
279  call assert_fails('set updatetime=-1', 'E487:')
280  call assert_fails('set winheight=-1', 'E487:')
281  call assert_fails('set tabstop!', 'E488:')
282  call assert_fails('set xxx', 'E518:')
283  call assert_fails('set beautify?', 'E519:')
284  call assert_fails('set undolevels=x', 'E521:')
285  call assert_fails('set tabstop=', 'E521:')
286  call assert_fails('set comments=-', 'E524:')
287  call assert_fails('set comments=a', 'E525:')
288  call assert_fails('set foldmarker=x', 'E536:')
289  call assert_fails('set commentstring=x', 'E537:')
290  call assert_fails('set complete=x', 'E539:')
291  call assert_fails('set statusline=%{', 'E540:')
292  call assert_fails('set statusline=' . repeat("%p", 81), 'E541:')
293  call assert_fails('set statusline=%(', 'E542:')
294  if has('cursorshape')
295    " This invalid value for 'guicursor' used to cause Vim to crash.
296    call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
297    call assert_fails('set guicursor=i-ci', 'E545:')
298    call assert_fails('set guicursor=x', 'E545:')
299    call assert_fails('set guicursor=x:', 'E546:')
300    call assert_fails('set guicursor=r-cr:horx', 'E548:')
301    call assert_fails('set guicursor=r-cr:hor0', 'E549:')
302  endif
303  if has('mouseshape')
304    call assert_fails('se mouseshape=i-r:x', 'E547:')
305  endif
306  call assert_fails('set backupext=~ patchmode=~', 'E589:')
307  call assert_fails('set winminheight=10 winheight=9', 'E591:')
308  call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
309  call assert_fails("set showbreak=\x01", 'E595:')
310  call assert_fails('set t_foo=', 'E846:')
311endfunc
312
313func CheckWasSet(name)
314  let verb_cm = execute('verbose set ' .. a:name .. '?')
315  call assert_match('Last set from.*test_options.vim', verb_cm)
316endfunc
317func CheckWasNotSet(name)
318  let verb_cm = execute('verbose set ' .. a:name .. '?')
319  call assert_notmatch('Last set from', verb_cm)
320endfunc
321
322" Must be executed before other tests that set 'term'.
323func Test_000_term_option_verbose()
324  CheckNotGui
325
326  call CheckWasNotSet('t_cm')
327
328  let term_save = &term
329  set term=ansi
330  call CheckWasSet('t_cm')
331  let &term = term_save
332endfunc
333
334func Test_copy_context()
335  setlocal list
336  call CheckWasSet('list')
337  split
338  call CheckWasSet('list')
339  quit
340  setlocal nolist
341
342  set ai
343  call CheckWasSet('ai')
344  set filetype=perl
345  call CheckWasSet('filetype')
346  set fo=tcroq
347  call CheckWasSet('fo')
348
349  split Xsomebuf
350  call CheckWasSet('ai')
351  call CheckWasNotSet('filetype')
352  call CheckWasSet('fo')
353endfunc
354
355func Test_set_ttytype()
356  CheckUnix
357  CheckNotGui
358
359  " Setting 'ttytype' used to cause a double-free when exiting vim and
360  " when vim is compiled with -DEXITFREE.
361  set ttytype=ansi
362  call assert_equal('ansi', &ttytype)
363  call assert_equal(&ttytype, &term)
364  set ttytype=xterm
365  call assert_equal('xterm', &ttytype)
366  call assert_equal(&ttytype, &term)
367  " "set ttytype=" gives E522 instead of E529
368  " in travis on some builds. Why?  Catch both for now
369  try
370    set ttytype=
371    call assert_report('set ttytype= did not fail')
372  catch /E529\|E522/
373  endtry
374
375  " Some systems accept any terminal name and return dumb settings,
376  " check for failure of finding the entry and for missing 'cm' entry.
377  try
378    set ttytype=xxx
379    call assert_report('set ttytype=xxx did not fail')
380  catch /E522\|E437/
381  endtry
382
383  set ttytype&
384  call assert_equal(&ttytype, &term)
385
386  if has('gui') && !has('gui_running')
387    call assert_fails('set term=gui', 'E531:')
388  endif
389endfunc
390
391func Test_set_all()
392  set tw=75
393  set iskeyword=a-z,A-Z
394  set nosplitbelow
395  let out = execute('set all')
396  call assert_match('textwidth=75', out)
397  call assert_match('iskeyword=a-z,A-Z', out)
398  call assert_match('nosplitbelow', out)
399  set tw& iskeyword& splitbelow&
400endfunc
401
402func Test_set_one_column()
403  let out_mult = execute('set all')->split("\n")
404  let out_one = execute('set! all')->split("\n")
405  call assert_true(len(out_mult) < len(out_one))
406endfunc
407
408func Test_set_values()
409  if filereadable('opt_test.vim')
410    source opt_test.vim
411  else
412    throw 'Skipped: opt_test.vim does not exist'
413  endif
414endfunc
415
416func Test_renderoptions()
417  " Only do this for Windows Vista and later, fails on Windows XP and earlier.
418  " Doesn't hurt to do this on a non-Windows system.
419  if windowsversion() !~ '^[345]\.'
420    set renderoptions=type:directx
421    set rop=type:directx
422  endif
423endfunc
424
425func ResetIndentexpr()
426  set indentexpr=
427endfunc
428
429func Test_set_indentexpr()
430  " this was causing usage of freed memory
431  set indentexpr=ResetIndentexpr()
432  new
433  call feedkeys("i\<c-f>", 'x')
434  call assert_equal('', &indentexpr)
435  bwipe!
436endfunc
437
438func Test_backupskip()
439  " Option 'backupskip' may contain several comma-separated path
440  " specifications if one or more of the environment variables TMPDIR, TMP,
441  " or TEMP is defined.  To simplify testing, convert the string value into a
442  " list.
443  let bsklist = split(&bsk, ',')
444
445  if has("mac")
446    let found = (index(bsklist, '/private/tmp/*') >= 0)
447    call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
448  elseif has("unix")
449    let found = (index(bsklist, '/tmp/*') >= 0)
450    call assert_true(found, '/tmp not in option bsk: ' . &bsk)
451  endif
452
453  " If our test platform is Windows, the path(s) in option bsk will use
454  " backslash for the path separator and the components could be in short
455  " (8.3) format.  As such, we need to replace the backslashes with forward
456  " slashes and convert the path components to long format.  The expand()
457  " function will do this but it cannot handle comma-separated paths.  This is
458  " why bsk was converted from a string into a list of strings above.
459  "
460  " One final complication is that the wildcard "/*" is at the end of each
461  " path and so expand() might return a list of matching files.  To prevent
462  " this, we need to remove the wildcard before calling expand() and then
463  " append it afterwards.
464  if has('win32')
465    let item_nbr = 0
466    while item_nbr < len(bsklist)
467      let path_spec = bsklist[item_nbr]
468      let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
469      let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
470      let bsklist[item_nbr] = path_spec . '/*'
471      let item_nbr += 1
472    endwhile
473  endif
474
475  " Option bsk will also include these environment variables if defined.
476  " If they're defined, verify they appear in the option value.
477  for var in  ['$TMPDIR', '$TMP', '$TEMP']
478    if exists(var)
479      let varvalue = substitute(expand(var), '\\', '/', 'g')
480      let varvalue = substitute(varvalue, '/$', '', '')
481      let varvalue .= '/*'
482      let found = (index(bsklist, varvalue) >= 0)
483      call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk)
484    endif
485  endfor
486
487  " Duplicates should be filtered out (option has P_NODUP)
488  let backupskip = &backupskip
489  set backupskip=
490  set backupskip+=/test/dir
491  set backupskip+=/other/dir
492  set backupskip+=/test/dir
493  call assert_equal('/test/dir,/other/dir', &backupskip)
494  let &backupskip = backupskip
495endfunc
496
497func Test_copy_winopt()
498  set hidden
499
500  " Test copy option from current buffer in window
501  split
502  enew
503  setlocal numberwidth=5
504  wincmd w
505  call assert_equal(4,&numberwidth)
506  bnext
507  call assert_equal(5,&numberwidth)
508  bw!
509  call assert_equal(4,&numberwidth)
510
511  " Test copy value from window that used to be display the buffer
512  split
513  enew
514  setlocal numberwidth=6
515  bnext
516  wincmd w
517  call assert_equal(4,&numberwidth)
518  bnext
519  call assert_equal(6,&numberwidth)
520  bw!
521
522  " Test that if buffer is current, don't use the stale cached value
523  " from the last time the buffer was displayed.
524  split
525  enew
526  setlocal numberwidth=7
527  bnext
528  bnext
529  setlocal numberwidth=8
530  wincmd w
531  call assert_equal(4,&numberwidth)
532  bnext
533  call assert_equal(8,&numberwidth)
534  bw!
535
536  " Test value is not copied if window already has seen the buffer
537  enew
538  split
539  setlocal numberwidth=9
540  bnext
541  setlocal numberwidth=10
542  wincmd w
543  call assert_equal(4,&numberwidth)
544  bnext
545  call assert_equal(4,&numberwidth)
546  bw!
547
548  set hidden&
549endfunc
550
551func Test_shortmess_F()
552  new
553  call assert_match('\[No Name\]', execute('file'))
554  set shortmess+=F
555  call assert_match('\[No Name\]', execute('file'))
556  call assert_match('^\s*$', execute('file foo'))
557  call assert_match('foo', execute('file'))
558  set shortmess-=F
559  call assert_match('bar', execute('file bar'))
560  call assert_match('bar', execute('file'))
561  set shortmess&
562  bwipe
563endfunc
564
565func Test_shortmess_F2()
566  e file1
567  e file2
568  call assert_match('file1', execute('bn', ''))
569  call assert_match('file2', execute('bn', ''))
570  set shortmess+=F
571  call assert_true(empty(execute('bn', '')))
572  call assert_false(test_getvalue('need_fileinfo'))
573  call assert_true(empty(execute('bn', '')))
574  call assert_false('need_fileinfo'->test_getvalue())
575  set hidden
576  call assert_true(empty(execute('bn', '')))
577  call assert_false(test_getvalue('need_fileinfo'))
578  call assert_true(empty(execute('bn', '')))
579  call assert_false(test_getvalue('need_fileinfo'))
580  set nohidden
581  call assert_true(empty(execute('bn', '')))
582  call assert_false(test_getvalue('need_fileinfo'))
583  call assert_true(empty(execute('bn', '')))
584  call assert_false(test_getvalue('need_fileinfo'))
585  set shortmess&
586  call assert_match('file1', execute('bn', ''))
587  call assert_match('file2', execute('bn', ''))
588  bwipe
589  bwipe
590endfunc
591
592func Test_local_scrolloff()
593  set so=5
594  set siso=7
595  split
596  call assert_equal(5, &so)
597  setlocal so=3
598  call assert_equal(3, &so)
599  wincmd w
600  call assert_equal(5, &so)
601  wincmd w
602  setlocal so<
603  call assert_equal(5, &so)
604  setlocal so=0
605  call assert_equal(0, &so)
606  setlocal so=-1
607  call assert_equal(5, &so)
608
609  call assert_equal(7, &siso)
610  setlocal siso=3
611  call assert_equal(3, &siso)
612  wincmd w
613  call assert_equal(7, &siso)
614  wincmd w
615  setlocal siso<
616  call assert_equal(7, &siso)
617  setlocal siso=0
618  call assert_equal(0, &siso)
619  setlocal siso=-1
620  call assert_equal(7, &siso)
621
622  close
623  set so&
624  set siso&
625endfunc
626
627func Test_writedelay()
628  CheckFunction reltimefloat
629
630  new
631  call setline(1, 'empty')
632  redraw
633  set writedelay=10
634  let start = reltime()
635  call setline(1, repeat('x', 70))
636  redraw
637  let elapsed = reltimefloat(reltime(start))
638  set writedelay=0
639  " With 'writedelay' set should take at least 30 * 10 msec
640  call assert_inrange(30 * 0.01, 999.0, elapsed)
641
642  bwipe!
643endfunc
644
645func Test_visualbell()
646  set belloff=
647  set visualbell
648  call assert_beeps('normal 0h')
649  set novisualbell
650  set belloff=all
651endfunc
652
653" Test for the 'write' option
654func Test_write()
655  new
656  call setline(1, ['L1'])
657  set nowrite
658  call assert_fails('write Xfile', 'E142:')
659  set write
660  close!
661endfunc
662
663" Test for 'buftype' option
664func Test_buftype()
665  new
666  call setline(1, ['L1'])
667  set buftype=nowrite
668  call assert_fails('write', 'E382:')
669
670  for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
671    exe 'set buftype=' .. val
672    call writefile(['something'], 'XBuftype')
673    call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
674  endfor
675
676  call delete('XBuftype')
677  bwipe!
678endfunc
679
680" Test for the 'shell' option
681func Test_shell()
682  CheckUnix
683  let save_shell = &shell
684  set shell=
685  call assert_fails('shell', 'E91:')
686  let &shell = save_shell
687endfunc
688
689" Test for the 'shellquote' option
690func Test_shellquote()
691  CheckUnix
692  set shellquote=#
693  set verbose=20
694  redir => v
695  silent! !echo Hello
696  redir END
697  set verbose&
698  set shellquote&
699  call assert_match(': "#echo Hello#"', v)
700endfunc
701
702" Test for the 'rightleftcmd' option
703func Test_rightleftcmd()
704  CheckFeature rightleft
705  set rightleft
706  set rightleftcmd
707
708  let g:l = []
709  func AddPos()
710    call add(g:l, screencol())
711    return ''
712  endfunc
713  cmap <expr> <F2> AddPos()
714
715  call feedkeys("/\<F2>abc\<Left>\<F2>\<Right>\<Right>\<F2>" ..
716        \ "\<Left>\<F2>\<Esc>", 'xt')
717  call assert_equal([&co - 1, &co - 4, &co - 2, &co - 3], g:l)
718
719  cunmap <F2>
720  unlet g:l
721  set rightleftcmd&
722  set rightleft&
723endfunc
724
725" Test for the "debug" option
726func Test_debug_option()
727  set debug=beep
728  exe "normal \<C-c>"
729  call assert_equal('Beep!', Screenline(&lines))
730  set debug&
731endfunc
732
733" vim: shiftwidth=2 sts=2 expandtab
734