Patch 8.2.0540
Problem:    Regexp and other code not tested.
Solution:   Add more tests. (Yegappan Lakshmanan, closes #5904)
Files:      src/testdir/test_backspace_opt.vim, src/testdir/test_expr.vim,
            src/testdir/test_increment.vim, src/testdir/test_normal.vim,
            src/testdir/test_options.vim, src/testdir/test_regexp_latin.vim,
            src/testdir/test_search.vim, src/testdir/test_substitute.vim,
            src/testdir/test_terminal.vim, src/testdir/test_virtualedit.vim


*** ../vim-8.2.0539/src/testdir/test_backspace_opt.vim  2019-05-14 
17:34:49.000000000 +0200
--- src/testdir/test_backspace_opt.vim  2020-04-11 17:06:15.112713749 +0200
***************
*** 1,6 ****
  " Tests for 'backspace' settings
  
! :func Exec(expr)
    let str=''
    try
      exec a:expr
--- 1,6 ----
  " Tests for 'backspace' settings
  
! func Exec(expr)
    let str=''
    try
      exec a:expr
***************
*** 8,14 ****
      let str=v:exception
    endtry
    return str
! :endfunc
  
  func Test_backspace_option()
    set backspace=
--- 8,14 ----
      let str=v:exception
    endtry
    return str
! endfunc
  
  func Test_backspace_option()
    set backspace=
*** ../vim-8.2.0539/src/testdir/test_expr.vim   2020-04-06 21:35:02.460237781 
+0200
--- src/testdir/test_expr.vim   2020-04-11 17:06:15.112713749 +0200
***************
*** 429,480 ****
    call 
assert_equal("1111111111111111111111111111111111111111111111111111111111111111",
 printf('%b', -1))
  endfunc
  
- func Test_substitute_expr()
-   let g:val = 'XXX'
-   call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', ''))
-   call assert_equal('XXX', substitute('yyy', 'y*', {-> g:val}, ''))
-   call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
-                          \ '\=nr2char("0x" . submatch(1))', 'g'))
-   call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
-                          \ {-> nr2char("0x" . submatch(1))}, 'g'))
- 
-   call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)',
-       \ {-> submatch(2) . submatch(3) . submatch(1)}, ''))
- 
-   func Recurse()
-     return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '')
-   endfunc
-   " recursive call works
-   call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() 
. '-' . submatch(1) . '-'}, ''))
- 
-   call assert_fails("let s=submatch([])", 'E745:')
-   call assert_fails("let s=submatch(2, [])", 'E745:')
- endfunc
- 
- func Test_invalid_submatch()
-   " This was causing invalid memory access in Vim-7.4.2232 and older
-   call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 
'E935:')
- endfunc
- 
- func Test_substitute_expr_arg()
-   call assert_equal('123456789-123456789=', substitute('123456789',
-       \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
-       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . 
m[8] . m[9] . '='}, ''))
- 
-   call assert_equal('123456-123456=789', substitute('123456789',
-       \ '\(.\)\(.\)\(.\)\(a*\)\(n*\)\(.\)\(.\)\(.\)\(x*\)',
-       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . 
m[8] . m[9] . '='}, ''))
- 
-   call assert_equal('123456789-123456789x=', substitute('123456789',
-       \ '\(.\)\(.\)\(.*\)',
-       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . 'x' . m[4] . m[5] . m[6] . 
m[7] . m[8] . m[9] . '='}, ''))
- 
-   call assert_fails("call substitute('xxx', '.', {m -> string(add(m, 'x'))}, 
'')", 'E742:')
-   call assert_fails("call substitute('xxx', '.', {m -> string(insert(m, 
'x'))}, '')", 'E742:')
-   call assert_fails("call substitute('xxx', '.', {m -> string(extend(m, 
['x']))}, '')", 'E742:')
-   call assert_fails("call substitute('xxx', '.', {m -> string(remove(m, 1))}, 
'')", 'E742:')
- endfunc
- 
  func Test_function_with_funcref()
    let s:f = function('type')
    let s:fref = function(s:f)
--- 429,434 ----
*** ../vim-8.2.0539/src/testdir/test_increment.vim      2020-03-10 
07:48:06.571619551 +0100
--- src/testdir/test_increment.vim      2020-04-11 17:06:15.116713744 +0200
***************
*** 475,480 ****
--- 475,484 ----
    exec "norm! \<C-A>"
    call assert_equal(["b"], getline(1, '$'))
    call assert_equal([0, 1, 1, 0], getpos('.'))
+   " decrement a and A and increment z and Z
+   call setline(1, ['a', 'A', 'z', 'Z'])
+   exe "normal 1G\<C-X>2G\<C-X>3G\<C-A>4G\<C-A>"
+   call assert_equal(['a', 'A', 'z', 'Z'], getline(1, '$'))
  endfunc
  
  " 21) block-wise increment on part of hexadecimal
***************
*** 565,576 ****
  "   1) <ctrl-a>
  " 0b11111111111111111111111111111111
  func Test_visual_increment_26()
!   set nrformats+=alpha
    call setline(1, ["0b11111111111111111111111111111110"])
    exec "norm! \<C-V>$\<C-A>"
    call assert_equal(["0b11111111111111111111111111111111"], getline(1, '$'))
    call assert_equal([0, 1, 1, 0], getpos('.'))
!   set nrformats-=alpha
  endfunc
  
  " 27) increment with 'rightreft', if supported
--- 569,582 ----
  "   1) <ctrl-a>
  " 0b11111111111111111111111111111111
  func Test_visual_increment_26()
!   set nrformats+=bin
    call setline(1, ["0b11111111111111111111111111111110"])
    exec "norm! \<C-V>$\<C-A>"
    call assert_equal(["0b11111111111111111111111111111111"], getline(1, '$'))
    call assert_equal([0, 1, 1, 0], getpos('.'))
!   exec "norm! \<C-V>$\<C-X>"
!   call assert_equal(["0b11111111111111111111111111111110"], getline(1, '$'))
!   set nrformats-=bin
  endfunc
  
  " 27) increment with 'rightreft', if supported
***************
*** 771,777 ****
  endfunc
  
  func Test_increment_empty_line()
-   new
    call setline(1, ['0', '0', '0', '0', '0', '0', ''])
    exe "normal Gvgg\<C-A>"
    call assert_equal(['1', '1', '1', '1', '1', '1', ''], getline(1, 7))
--- 777,782 ----
***************
*** 782,789 ****
    exe "normal! c\<C-A>l"
    exe "normal! c\<C-X>l"
    call assert_equal('one two', getline(1))
  
!   bwipe!
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
--- 787,799 ----
    exe "normal! c\<C-A>l"
    exe "normal! c\<C-X>l"
    call assert_equal('one two', getline(1))
+ endfunc
  
! " Try incrementing/decrementing a non-digit/alpha character
! func Test_increment_special_char()
!   call setline(1, '!')
!   call assert_beeps("normal \<C-A>")
!   call assert_beeps("normal \<C-X>")
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/testdir/test_normal.vim 2020-04-06 21:35:02.464237765 
+0200
--- src/testdir/test_normal.vim 2020-04-11 17:06:15.116713744 +0200
***************
*** 138,153 ****
    $
    :j 10
    call assert_equal('100', getline('.'))
    " clean up
    bw!
  endfunc
  
  func Test_normal04_filter()
-   " basic filter test
    " only test on non windows platform
!   if has('win32')
!     return
!   endif
    call Setup_NewWindow()
    1
    call feedkeys("!!sed -e 's/^/|    /'\n", 'tx')
--- 138,152 ----
    $
    :j 10
    call assert_equal('100', getline('.'))
+   call assert_beeps('normal GVJ')
    " clean up
    bw!
  endfunc
  
+ " basic filter test
  func Test_normal04_filter()
    " only test on non windows platform
!   CheckNotMSWindows
    call Setup_NewWindow()
    1
    call feedkeys("!!sed -e 's/^/|    /'\n", 'tx')
***************
*** 205,216 ****
    set formatexpr=
  endfunc
  
  func Test_normal06_formatprg()
-   " basic test for formatprg
    " only test on non windows platform
!   if has('win32')
!     return
!   endif
  
    " uses sed to number non-empty lines
    call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/    /', 
'}'''], 'Xsed_format.sh')
--- 204,213 ----
    set formatexpr=
  endfunc
  
+ " basic test for formatprg
  func Test_normal06_formatprg()
    " only test on non windows platform
!   CheckNotMSWindows
  
    " uses sed to number non-empty lines
    call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/    /', 
'}'''], 'Xsed_format.sh')
***************
*** 223,238 ****
    set formatprg=./Xsed_format.sh
    norm! gggqG
    call assert_equal(expected, getline(1, '$'))
!   bw!
  
-   10new
    call setline(1, text)
    set formatprg=donothing
    setlocal formatprg=./Xsed_format.sh
    norm! gggqG
    call assert_equal(expected, getline(1, '$'))
!   bw!
  
    " clean up
    set formatprg=
    setlocal formatprg=
--- 220,243 ----
    set formatprg=./Xsed_format.sh
    norm! gggqG
    call assert_equal(expected, getline(1, '$'))
!   %d
  
    call setline(1, text)
    set formatprg=donothing
    setlocal formatprg=./Xsed_format.sh
    norm! gggqG
    call assert_equal(expected, getline(1, '$'))
!   %d
  
+   " Check for the command-line ranges added to 'formatprg'
+   set formatprg=cat
+   call setline(1, ['one', 'two', 'three', 'four', 'five'])
+   call feedkeys('gggqG', 'xt')
+   call assert_equal('.,$!cat', @:)
+   call feedkeys('2Ggq2j', 'xt')
+   call assert_equal('.,.+2!cat', @:)
+ 
+   bw!
    " clean up
    set formatprg=
    setlocal formatprg=
***************
*** 246,263 ****
    10new
    call setline(1, list)
    set tw=12
!   norm! gggqG
    call assert_equal(['1    2    3', '4    5    6', '7    8    9', '10    11   
 '], getline(1, '$'))
    " clean up
    set tw=0
    bw!
  endfunc
  
  func Test_normal08_fold()
!   " basic tests for foldopen/folddelete
!   if !has("folding")
!     return
!   endif
    call Setup_NewWindow()
    50
    setl foldenable fdm=marker
--- 251,266 ----
    10new
    call setline(1, list)
    set tw=12
!   norm! ggVGgq
    call assert_equal(['1    2    3', '4    5    6', '7    8    9', '10    11   
 '], getline(1, '$'))
    " clean up
    set tw=0
    bw!
  endfunc
  
+ " basic tests for foldopen/folddelete
  func Test_normal08_fold()
!   CheckFeature folding
    call Setup_NewWindow()
    50
    setl foldenable fdm=marker
***************
*** 757,767 ****
    close!
  endfunc
  
  func Test_normal18_z_fold()
!   " basic tests for foldopen/folddelete
!   if !has("folding")
!     return
!   endif
    call Setup_NewWindow()
    50
    setl foldenable fdm=marker foldlevel=5
--- 760,768 ----
    close!
  endfunc
  
+ " basic tests for foldopen/folddelete
  func Test_normal18_z_fold()
!   CheckFeature folding
    call Setup_NewWindow()
    50
    setl foldenable fdm=marker foldlevel=5
***************
*** 1132,1141 ****
  endfunc
  
  func Test_normal20_exmode()
!   if !has("unix")
!     " Reading from redirected file doesn't work on MS-Windows
!     return
!   endif
    call writefile(['1a', 'foo', 'bar', '.', 'w! Xfile2', 'q!'], 'Xscript')
    call writefile(['1', '2'], 'Xfile')
    call system(GetVimCommand() .. ' -e -s < Xscript Xfile')
--- 1133,1140 ----
  endfunc
  
  func Test_normal20_exmode()
!   " Reading from redirected file doesn't work on MS-Windows
!   CheckNotMSWindows
    call writefile(['1a', 'foo', 'bar', '.', 'w! Xfile2', 'q!'], 'Xscript')
    call writefile(['1', '2'], 'Xfile')
    call system(GetVimCommand() .. ' -e -s < Xscript Xfile')
***************
*** 1762,1767 ****
--- 1761,1772 ----
    " r command should fail in operator pending mode
    call assert_beeps('normal! cr')
  
+   " replace a tab character in visual mode
+   %d
+   call setline(1, ["a\tb", "c\td", "e\tf"])
+   normal gglvjjrx
+   call assert_equal(['axx', 'xxx', 'xxf'], getline(1, '$'))
+ 
    " clean up
    set noautoindent
    bw!
***************
*** 1786,1794 ****
  " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G,
  " gi and gI commands
  func Test_normal33_g_cmd2()
!   if !has("jumplist")
!     return
!   endif
    call Setup_NewWindow()
    " Test for g`
    clearjumps
--- 1791,1797 ----
  " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G,
  " gi and gI commands
  func Test_normal33_g_cmd2()
!   CheckFeature jumplist
    call Setup_NewWindow()
    " Test for g`
    clearjumps
***************
*** 2503,2511 ****
  endfunc
  
  func Test_normal50_commandline()
!   if !has("timers") || !has("cmdline_hist")
!     return
!   endif
    func! DoTimerWork(id)
      call assert_equal('[Command Line]', bufname(''))
      " should fail, with E11, but does fail with E23?
--- 2506,2513 ----
  endfunc
  
  func Test_normal50_commandline()
!   CheckFeature timers
!   CheckFeature cmdline_hist
    func! DoTimerWork(id)
      call assert_equal('[Command Line]', bufname(''))
      " should fail, with E11, but does fail with E23?
***************
*** 2534,2542 ****
  endfunc
  
  func Test_normal51_FileChangedRO()
!   if !has("autocmd")
!     return
!   endif
    " Don't sleep after the warning message.
    call test_settime(1)
    call writefile(['foo'], 'Xreadonly.log')
--- 2536,2542 ----
  endfunc
  
  func Test_normal51_FileChangedRO()
!   CheckFeature autocmd
    " Don't sleep after the warning message.
    call test_settime(1)
    call writefile(['foo'], 'Xreadonly.log')
***************
*** 2554,2562 ****
  endfunc
  
  func Test_normal52_rl()
!   if !has("rightleft")
!     return
!   endif
    new
    call setline(1, 'abcde fghij klmnopq')
    norm! 1gg$
--- 2554,2560 ----
  endfunc
  
  func Test_normal52_rl()
!   CheckFeature rightleft
    new
    call setline(1, 'abcde fghij klmnopq')
    norm! 1gg$
***************
*** 2589,2597 ****
  endfunc
  
  func Test_normal53_digraph()
!   if !has('digraphs')
!     return
!   endif
    new
    call setline(1, 'abcdefgh|')
    exe "norm! 1gg0f\<c-k>!!"
--- 2587,2593 ----
  endfunc
  
  func Test_normal53_digraph()
!   CheckFeature digraphs
    new
    call setline(1, 'abcdefgh|')
    exe "norm! 1gg0f\<c-k>!!"
***************
*** 2819,2829 ****
    close!
  endfunc
  
  func Test_normal_gdollar_cmd()
!   if !has("jumplist")
!     return
!   endif
!   " Tests for g cmds
    call Setup_NewWindow()
    " Make long lines that will wrap
    %s/$/\=repeat(' foobar', 10)/
--- 2815,2823 ----
    close!
  endfunc
  
+ " Tests for g cmds
  func Test_normal_gdollar_cmd()
!   CheckFeature jumplist
    call Setup_NewWindow()
    " Make long lines that will wrap
    %s/$/\=repeat(' foobar', 10)/
***************
*** 3028,3031 ****
--- 3022,3068 ----
    close!
  endfunc
  
+ " Test for d and D commands
+ func Test_normal_delete_cmd()
+   new
+   " D in an empty line
+   call setline(1, '')
+   normal D
+   call assert_equal('', getline(1))
+   " D in an empty line in virtualedit mode
+   set virtualedit=all
+   normal D
+   call assert_equal('', getline(1))
+   set virtualedit&
+   " delete to a readonly register
+   call setline(1, ['abcd'])
+   call assert_beeps('normal ":d2l')
+   close!
+ endfunc
+ 
+ " Test for the 'E' flag in 'cpo' with yank, change, delete, etc. operators
+ func Test_empty_region_error()
+   new
+   call setline(1, '')
+   set cpo+=E
+   " yank an empty line
+   call assert_beeps('normal "ayl')
+   " change an empty line
+   call assert_beeps('normal lcTa')
+   " delete an empty line
+   call assert_beeps('normal D')
+   call assert_beeps('normal dl')
+   call assert_equal('', getline(1))
+   " change case of an empty line
+   call assert_beeps('normal gul')
+   call assert_beeps('normal gUl')
+   " replace a character
+   call assert_beeps('normal vrx')
+   " increment and decrement
+   call assert_beeps('exe "normal v\<C-A>"')
+   call assert_beeps('exe "normal v\<C-X>"')
+   set cpo-=E
+   close!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/testdir/test_options.vim        2020-04-09 
18:42:08.358066443 +0200
--- src/testdir/test_options.vim        2020-04-11 17:06:15.116713744 +0200
***************
*** 22,27 ****
--- 22,42 ----
    set whichwrap=h,h,h
    call assert_equal('h', &whichwrap)
  
+   " For compatibility with Vim 3.0 and before, number values are also
+   " supported for 'whichwrap'
+   set whichwrap=1
+   call assert_equal('b', &whichwrap)
+   set whichwrap=2
+   call assert_equal('s', &whichwrap)
+   set whichwrap=4
+   call assert_equal('h,l', &whichwrap)
+   set whichwrap=8
+   call assert_equal('<,>', &whichwrap)
+   set whichwrap=16
+   call assert_equal('[,]', &whichwrap)
+   set whichwrap=31
+   call assert_equal('b,s,h,l,<,>,[,]', &whichwrap)
+ 
    set whichwrap&
  endfunc
  
***************
*** 82,87 ****
--- 97,109 ----
  
    " close option-window
    close
+ 
+   " Open the options window browse
+   if has('browse')
+     browse set
+     call assert_equal('option-window', bufname(''))
+     close
+   endif
  endfunc
  
  func Test_path_keep_commas()
***************
*** 308,313 ****
--- 330,346 ----
    call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
    call assert_fails("set showbreak=\x01", 'E595:')
    call assert_fails('set t_foo=', 'E846:')
+   call assert_fails('set tabstop??', 'E488:')
+   call assert_fails('set wrapscan!!', 'E488:')
+   call assert_fails('set tabstop&&', 'E488:')
+   call assert_fails('set wrapscan<<', 'E488:')
+   call assert_fails('set wrapscan=1', 'E474:')
+   call assert_fails('set autoindent@', 'E488:')
+   call assert_fails('set wildchar=<abc>', 'E474:')
+   call assert_fails('set cmdheight=1a', 'E521:')
+   if has('python') && has('python3')
+     call assert_fails('set pyxversion=6', 'E474:')
+   endif
  endfunc
  
  func CheckWasSet(name)
***************
*** 730,733 ****
--- 763,834 ----
    set debug&
  endfunc
  
+ " Test for the default CDPATH option
+ func Test_opt_default_cdpath()
+   CheckFeature file_in_path
+   let after =<< trim [CODE]
+     call assert_equal(',/path/to/dir1,/path/to/dir2', &cdpath)
+     call writefile(v:errors, 'Xtestout')
+     qall
+   [CODE]
+   if has('unix')
+     let $CDPATH='/path/to/dir1:/path/to/dir2'
+   else
+     let $CDPATH='/path/to/dir1;/path/to/dir2'
+   endif
+   if RunVim([], after, '')
+     call assert_equal([], readfile('Xtestout'))
+     call delete('Xtestout')
+   endif
+ endfunc
+ 
+ " Test for setting keycodes using set
+ func Test_opt_set_keycode()
+   call assert_fails('set <t_k1=l', 'E474:')
+   call assert_fails('set <Home=l', 'E474:')
+   set <t_k9>=abcd
+   call assert_equal('abcd', &t_k9)
+   set <t_k9>&
+   set <F9>=xyz
+   call assert_equal('xyz', &t_k9)
+   set <t_k9>&
+ endfunc
+ 
+ " Test for changing options in a sandbox
+ func Test_opt_sandbox()
+   for opt in ['backupdir', 'cdpath', 'exrc']
+     call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
+   endfor
+ endfunc
+ 
+ " Test for setting an option with local value to global value
+ func Test_opt_local_to_global()
+   setglobal equalprg=gprg
+   setlocal equalprg=lprg
+   call assert_equal('gprg', &g:equalprg)
+   call assert_equal('lprg', &l:equalprg)
+   call assert_equal('lprg', &equalprg)
+   set equalprg<
+   call assert_equal('', &l:equalprg)
+   call assert_equal('gprg', &equalprg)
+   setglobal equalprg=gnewprg
+   setlocal equalprg=lnewprg
+   setlocal equalprg<
+   call assert_equal('gnewprg', &l:equalprg)
+   call assert_equal('gnewprg', &equalprg)
+   set equalprg&
+ endfunc
+ 
+ " Test for incrementing, decrementing and multiplying a number option value
+ func Test_opt_num_op()
+   set shiftwidth=4
+   set sw+=2
+   call assert_equal(6, &sw)
+   set sw-=2
+   call assert_equal(4, &sw)
+   set sw^=2
+   call assert_equal(8, &sw)
+   set shiftwidth&
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/testdir/test_regexp_latin.vim   2020-04-09 
18:42:08.358066443 +0200
--- src/testdir/test_regexp_latin.vim   2020-04-11 17:06:15.116713744 +0200
***************
*** 171,176 ****
--- 171,180 ----
    call add(tl, [2, 'c*', 'abdef', ''])
    call add(tl, [2, 'bc\+', 'abccccdef', 'bcccc'])
    call add(tl, [2, 'bc\+', 'abdef']) " no match
+   " match escape character in a string
+   call add(tl, [2, '.\e.', "one\<Esc>two", "e\<Esc>t"])
+   " match backspace character in a string
+   call add(tl, [2, '.\b.', "one\<C-H>two", "e\<C-H>t"])
    " match newline character in a string
    call add(tl, [2, 'o\nb', "foo\nbar", "o\nb"])
  
***************
*** 913,918 ****
--- 917,924 ----
    call assert_fails("call matchlist('x x', '\\%#=2 \\zs*')", 'E888:')
    call assert_fails("call matchlist('x x', '\\%#=2 \\ze*')", 'E888:')
    call assert_fails('exe "normal /\\%#=1\\%[x\\%[x]]\<CR>"', 'E369:')
+   call assert_fails("call matchstr('abcd', '\\%o841\\%o142')", 'E678:')
+   call assert_equal('', matchstr('abcd', '\%o181\%o142'))
  endfunc
  
  " Test for using the last substitute string pattern (~)
*** ../vim-8.2.0539/src/testdir/test_search.vim 2020-04-09 18:42:08.362066431 
+0200
--- src/testdir/test_search.vim 2020-04-11 17:06:15.116713744 +0200
***************
*** 1593,1596 ****
--- 1593,1615 ----
    call assert_fails("call search('\\%#=3ab')", 'E864:')
  endfunc
  
+ " Test for searching a very complex pattern in a string. Should switch the
+ " regexp engine from NFA to the old engine.
+ func Test_regexp_switch_engine()
+   let l = readfile('samples/re.freeze.txt')
+   let v = substitute(l[4], '..\@<!', '', '')
+   call assert_equal(l[4], v)
+ endfunc
+ 
+ " Test for the \%V atom to search within visually selected text
+ func Test_search_in_visual_area()
+   new
+   call setline(1, ['foo bar1', 'foo bar2', 'foo bar3', 'foo bar4'])
+   exe "normal 2GVjo/\\%Vbar\<CR>\<Esc>"
+   call assert_equal([2, 5], [line('.'), col('.')])
+   exe "normal 2GVj$?\\%Vbar\<CR>\<Esc>"
+   call assert_equal([3, 5], [line('.'), col('.')])
+   close!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/testdir/test_substitute.vim     2020-03-30 
19:38:17.935358947 +0200
--- src/testdir/test_substitute.vim     2020-04-11 17:06:15.116713744 +0200
***************
*** 282,287 ****
--- 282,290 ----
    call assert_equal("x\<C-M>x", substitute('xXx', 'X', "\r", ''))
    call assert_equal("YyyY", substitute('Y', 'Y', '\L\uyYy\l\EY', ''))
    call assert_equal("zZZz", substitute('Z', 'Z', '\U\lZzZ\u\Ez', ''))
+   " \v or \V after $
+   call assert_equal('abxx', substitute('abcd', 'xy$\v|cd$', 'xx', ''))
+   call assert_equal('abxx', substitute('abcd', 'xy$\V\|cd\$', 'xx', ''))
  endfunc
  
  func Test_sub_replace_2()
***************
*** 842,847 ****
--- 845,922 ----
  
  func Test_substitute()
    call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g'))
+   " Substitute with special keys
+   call assert_equal("a\<End>c", substitute('abc', "a.c", "a\<End>c", ''))
+ endfunc
+ 
+ func Test_substitute_expr()
+   let g:val = 'XXX'
+   call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', ''))
+   call assert_equal('XXX', substitute('yyy', 'y*', {-> g:val}, ''))
+   call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
+                          \ '\=nr2char("0x" . submatch(1))', 'g'))
+   call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
+                          \ {-> nr2char("0x" . submatch(1))}, 'g'))
+ 
+   call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)',
+       \ {-> submatch(2) . submatch(3) . submatch(1)}, ''))
+ 
+   func Recurse()
+     return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '')
+   endfunc
+   " recursive call works
+   call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() 
. '-' . submatch(1) . '-'}, ''))
+ 
+   call assert_fails("let s=submatch([])", 'E745:')
+   call assert_fails("let s=submatch(2, [])", 'E745:')
+ endfunc
+ 
+ func Test_invalid_submatch()
+   " This was causing invalid memory access in Vim-7.4.2232 and older
+   call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 
'E935:')
+   call assert_fails('eval submatch(-1)', 'E935:')
+   call assert_equal('', submatch(0))
+   call assert_equal('', submatch(1))
+   call assert_equal([], submatch(0, 1))
+   call assert_equal([], submatch(1, 1))
+ endfunc
+ 
+ func Test_substitute_expr_arg()
+   call assert_equal('123456789-123456789=', substitute('123456789',
+       \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
+       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . 
m[8] . m[9] . '='}, ''))
+ 
+   call assert_equal('123456-123456=789', substitute('123456789',
+       \ '\(.\)\(.\)\(.\)\(a*\)\(n*\)\(.\)\(.\)\(.\)\(x*\)',
+       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . 
m[8] . m[9] . '='}, ''))
+ 
+   call assert_equal('123456789-123456789x=', substitute('123456789',
+       \ '\(.\)\(.\)\(.*\)',
+       \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . 'x' . m[4] . m[5] . m[6] . 
m[7] . m[8] . m[9] . '='}, ''))
+ 
+   call assert_fails("call substitute('xxx', '.', {m -> string(add(m, 'x'))}, 
'')", 'E742:')
+   call assert_fails("call substitute('xxx', '.', {m -> string(insert(m, 
'x'))}, '')", 'E742:')
+   call assert_fails("call substitute('xxx', '.', {m -> string(extend(m, 
['x']))}, '')", 'E742:')
+   call assert_fails("call substitute('xxx', '.', {m -> string(remove(m, 1))}, 
'')", 'E742:')
+ endfunc
+ 
+ " Test for using a function to supply the substitute string
+ func Test_substitute_using_func()
+   func Xfunc()
+     return '1234'
+   endfunc
+   call assert_equal('a1234f', substitute('abcdef', 'b..e',
+         \ function("Xfunc"), ''))
+   delfunc Xfunc
+ endfunc
+ 
+ " Test for using submatch() with a multiline match
+ func Test_substitute_multiline_submatch()
+   new
+   call setline(1, ['line1', 'line2', 'line3', 'line4'])
+   %s/^line1\(\_.\+\)line4$/\=submatch(1)/
+   call assert_equal(['', 'line2', 'line3', ''], getline(1, '$'))
+   close!
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/testdir/test_terminal.vim       2020-04-08 
21:50:18.876619651 +0200
--- src/testdir/test_terminal.vim       2020-04-11 17:06:15.116713744 +0200
***************
*** 42,47 ****
--- 42,48 ----
    call assert_match('%aR[^\n]*running]', execute('ls R'))
    call assert_notmatch('%[^\n]*running]', execute('ls F'))
    call assert_notmatch('%[^\n]*running]', execute('ls ?'))
+   call assert_fails('set modifiable', 'E946:')
  
    call StopShellInTerminal(buf)
    call TermWait(buf)
*** ../vim-8.2.0539/src/testdir/test_virtualedit.vim    2020-03-08 
05:13:10.007536782 +0100
--- src/testdir/test_virtualedit.vim    2020-04-11 17:06:15.116713744 +0200
***************
*** 346,349 ****
--- 346,360 ----
    set virtualedit=
  endfunc
  
+ " Test for delete that breaks a tab into spaces
+ func Test_delete_break_tab()
+   new
+   call setline(1, "one\ttwo")
+   set virtualedit=all
+   normal v3ld
+   call assert_equal('    two', getline(1))
+   set virtualedit&
+   close!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0539/src/version.c       2020-04-09 21:33:19.166717351 +0200
--- src/version.c       2020-04-11 17:09:00.840469901 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     540,
  /**/

-- 
INSPECTOR END OF FILM: Move along.  There's nothing to see!  Keep moving!
   [Suddenly he notices the cameras.]
INSPECTOR END OF FILM: (to Camera) All right, put that away sonny.
   [He walks over to it and puts his hand over the lens.]
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004111509.03BF9vOb029522%40masaka.moolenaar.net.

Raspunde prin e-mail lui