mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1221: still too many old style tests
Problem: Still too many old style tests.
Solution: Convert a few more tests to new style. (Yegappan Lakshmanan,
closes vim/vim#2256)
15993ce921
This commit is contained in:
parent
0a531ddf87
commit
2de447b60c
@ -24,12 +24,10 @@ SCRIPTS_DEFAULT = \
|
|||||||
test52.out \
|
test52.out \
|
||||||
test64.out \
|
test64.out \
|
||||||
test73.out \
|
test73.out \
|
||||||
test79.out \
|
|
||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \
|
SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \
|
||||||
test17.out \
|
test17.out \
|
||||||
test32.out \
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -69,6 +67,7 @@ NEW_TESTS ?= \
|
|||||||
test_hlsearch.res \
|
test_hlsearch.res \
|
||||||
test_increment.res \
|
test_increment.res \
|
||||||
test_increment_dbcs.res \
|
test_increment_dbcs.res \
|
||||||
|
test_ins_complete.res \
|
||||||
test_lambda.res \
|
test_lambda.res \
|
||||||
test_langmap.res \
|
test_langmap.res \
|
||||||
test_let.res \
|
test_let.res \
|
||||||
@ -99,6 +98,7 @@ NEW_TESTS ?= \
|
|||||||
test_substitute.res \
|
test_substitute.res \
|
||||||
test_syntax.res \
|
test_syntax.res \
|
||||||
test_system.res \
|
test_system.res \
|
||||||
|
test_tab.res \
|
||||||
test_tabpage.res \
|
test_tabpage.res \
|
||||||
test_textobjects.res \
|
test_textobjects.res \
|
||||||
test_timers.res \
|
test_timers.res \
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
Test for insert expansion
|
|
||||||
|
|
||||||
:se cpt=.,w
|
|
||||||
* add-expands (word from next line) from other window
|
|
||||||
* add-expands (current buffer first)
|
|
||||||
* Local expansion, ends in an empty line (unless it becomes a global expansion)
|
|
||||||
* starts Local and switches to global add-expansion
|
|
||||||
:se cpt=.,w,i
|
|
||||||
* i-add-expands and switches to local
|
|
||||||
* add-expands lines (it would end in an empty line if it didn't ignored it self)
|
|
||||||
:se cpt=kXtestfile
|
|
||||||
* checks k-expansion, and file expansion (use Xtest11 instead of test11,
|
|
||||||
* because TEST11.OUT may match first on DOS)
|
|
||||||
:se cpt=w
|
|
||||||
* checks make_cyclic in other window
|
|
||||||
:se cpt=u nohid
|
|
||||||
* checks unloaded buffer expansion
|
|
||||||
* checks adding mode abortion
|
|
||||||
:se cpt=t,d
|
|
||||||
* tag expansion, define add-expansion interrupted
|
|
||||||
* t-expansion
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:se backspace=""
|
|
||||||
:se cpt=.,w ff=unix | $-2,$w!Xtestfile | set ff&
|
|
||||||
:se cot=
|
|
||||||
nO#include "Xtestfile"
|
|
||||||
ru
|
|
||||||
O
|
|
||||||
|
|
||||||
|
|
||||||
:se cpt=.,w,i
|
|
||||||
kOM
|
|
||||||
|
|
||||||
:se cpt=kXtestfile
|
|
||||||
:w Xtest11.one
|
|
||||||
:w Xtest11.two
|
|
||||||
OIXA
|
|
||||||
:" use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use
|
|
||||||
:" CTRL-X CTRL-F again to verify this doesn't cause trouble.
|
|
||||||
OXddk
|
|
||||||
:se cpt=w
|
|
||||||
OST
|
|
||||||
:se cpt=u nohid
|
|
||||||
oOEN
|
|
||||||
unl
|
|
||||||
:se cpt=t,d def=^\\k* tags=Xtestfile notagbsearch
|
|
||||||
O
|
|
||||||
a
|
|
||||||
:wq! test.out
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
start of testfile
|
|
||||||
run1
|
|
||||||
run2
|
|
||||||
end of testfile
|
|
||||||
|
|
||||||
test11 36Gepeto /Tag/
|
|
||||||
asd test11file 36G
|
|
||||||
Makefile to run
|
|
@ -1,15 +0,0 @@
|
|||||||
#include "Xtestfile"
|
|
||||||
run1 run3
|
|
||||||
run3 run3
|
|
||||||
|
|
||||||
Makefile to run3
|
|
||||||
Makefile to run3
|
|
||||||
Makefile to run3
|
|
||||||
Xtest11.two
|
|
||||||
STARTTEST
|
|
||||||
ENDTEST
|
|
||||||
unless
|
|
||||||
test11file 36Gepeto /Tag/ asd
|
|
||||||
asd
|
|
||||||
run1 run2
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
91
src/nvim/testdir/test_ins_complete.vim
Normal file
91
src/nvim/testdir/test_ins_complete.vim
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
" Test for insert expansion
|
||||||
|
func Test_ins_complete()
|
||||||
|
set ff=unix
|
||||||
|
call writefile(["test11\t36Gepeto\t/Tag/",
|
||||||
|
\ "asd\ttest11file\t36G",
|
||||||
|
\ "Makefile\tto\trun"], 'Xtestfile')
|
||||||
|
call writefile(['', 'start of testfile',
|
||||||
|
\ 'ru',
|
||||||
|
\ 'run1',
|
||||||
|
\ 'run2',
|
||||||
|
\ 'STARTTEST',
|
||||||
|
\ 'ENDTEST',
|
||||||
|
\ 'end of testfile'], 'Xtestdata')
|
||||||
|
set ff&
|
||||||
|
|
||||||
|
enew!
|
||||||
|
edit Xtestdata
|
||||||
|
new
|
||||||
|
call append(0, ['#include "Xtestfile"', ''])
|
||||||
|
call cursor(2, 1)
|
||||||
|
|
||||||
|
set cot=
|
||||||
|
set cpt=.,w
|
||||||
|
" add-expands (word from next line) from other window
|
||||||
|
exe "normal iru\<C-N>\<C-N>\<C-X>\<C-N>\<Esc>\<C-A>"
|
||||||
|
call assert_equal('run1 run3', getline('.'))
|
||||||
|
" add-expands (current buffer first)
|
||||||
|
exe "normal o\<C-P>\<C-X>\<C-N>"
|
||||||
|
call assert_equal('run3 run3', getline('.'))
|
||||||
|
" Local expansion, ends in an empty line (unless it becomes a global
|
||||||
|
" expansion)
|
||||||
|
exe "normal o\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>"
|
||||||
|
call assert_equal('', getline('.'))
|
||||||
|
" starts Local and switches to global add-expansion
|
||||||
|
exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>"
|
||||||
|
call assert_equal('run1 run2', getline('.'))
|
||||||
|
|
||||||
|
set cpt=.,w,i
|
||||||
|
" i-add-expands and switches to local
|
||||||
|
exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>"
|
||||||
|
call assert_equal("Makefile\tto\trun3", getline('.'))
|
||||||
|
" add-expands lines (it would end in an empty line if it didn't ignored
|
||||||
|
" itself)
|
||||||
|
exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>"
|
||||||
|
call assert_equal("Makefile\tto\trun3", getline('.'))
|
||||||
|
call assert_equal("Makefile\tto\trun3", getline(line('.') - 1))
|
||||||
|
|
||||||
|
set cpt=kXtestfile
|
||||||
|
" checks k-expansion, and file expansion (use Xtest11 instead of test11,
|
||||||
|
" because TEST11.OUT may match first on DOS)
|
||||||
|
write Xtest11.one
|
||||||
|
write Xtest11.two
|
||||||
|
exe "normal o\<C-N>\<Esc>IX\<Esc>A\<C-X>\<C-F>\<C-N>"
|
||||||
|
call assert_equal('Xtest11.two', getline('.'))
|
||||||
|
|
||||||
|
" use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X
|
||||||
|
" CTRL-F again to verify this doesn't cause trouble.
|
||||||
|
exe "normal oXt\<C-X>\<C-F>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<C-X>\<C-F>"
|
||||||
|
call assert_equal('Xtest11.one', getline('.'))
|
||||||
|
normal ddk
|
||||||
|
|
||||||
|
set cpt=w
|
||||||
|
" checks make_cyclic in other window
|
||||||
|
exe "normal oST\<C-N>\<C-P>\<C-P>\<C-P>\<C-P>"
|
||||||
|
call assert_equal('STARTTEST', getline('.'))
|
||||||
|
|
||||||
|
set cpt=u nohid
|
||||||
|
" checks unloaded buffer expansion
|
||||||
|
only
|
||||||
|
exe "normal oEN\<C-N>"
|
||||||
|
call assert_equal('ENDTEST', getline('.'))
|
||||||
|
" checks adding mode abortion
|
||||||
|
exe "normal ounl\<C-N>\<C-X>\<C-X>\<C-P>"
|
||||||
|
call assert_equal('unless', getline('.'))
|
||||||
|
|
||||||
|
set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch
|
||||||
|
" tag expansion, define add-expansion interrupted
|
||||||
|
exe "normal o\<C-X>\<C-]>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>"
|
||||||
|
call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.'))
|
||||||
|
" t-expansion
|
||||||
|
exe "normal oa\<C-N>\<Esc>"
|
||||||
|
call assert_equal('asd', getline('.'))
|
||||||
|
|
||||||
|
%bw!
|
||||||
|
call delete('Xtestfile')
|
||||||
|
call delete('Xtest11.one')
|
||||||
|
call delete('Xtest11.two')
|
||||||
|
call delete('Xtestdata')
|
||||||
|
set cpt& cot& def& tags& tagbsearch& hidden&
|
||||||
|
endfunc
|
@ -31,3 +31,33 @@ func Test_source_latin()
|
|||||||
bwipe!
|
bwipe!
|
||||||
call delete('Xscript')
|
call delete('Xscript')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for sourcing a file with CTRL-V's at the end of the line
|
||||||
|
func Test_source_ctrl_v()
|
||||||
|
call writefile(['map __1 afirst',
|
||||||
|
\ 'map __2 asecond',
|
||||||
|
\ 'map __3 athird',
|
||||||
|
\ 'map __4 afourth',
|
||||||
|
\ 'map __5 afifth',
|
||||||
|
\ "map __1 asd\<C-V>",
|
||||||
|
\ "map __2 asd\<C-V>\<C-V>",
|
||||||
|
\ "map __3 asd\<C-V>\<C-V>",
|
||||||
|
\ "map __4 asd\<C-V>\<C-V>\<C-V>",
|
||||||
|
\ "map __5 asd\<C-V>\<C-V>\<C-V>",
|
||||||
|
\ ], 'Xtestfile')
|
||||||
|
source Xtestfile
|
||||||
|
enew!
|
||||||
|
exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>"
|
||||||
|
exe "%s/\<C-J>/0/g"
|
||||||
|
call assert_equal(['sd',
|
||||||
|
\ "map __2 asd\<Esc>secondsd\<Esc>sd0map __5 asd0fifth"],
|
||||||
|
\ getline(1, 2))
|
||||||
|
|
||||||
|
enew!
|
||||||
|
call delete('Xtestfile')
|
||||||
|
unmap __1
|
||||||
|
unmap __2
|
||||||
|
unmap __3
|
||||||
|
unmap __4
|
||||||
|
unmap __5
|
||||||
|
endfunc
|
||||||
|
@ -114,3 +114,209 @@ func Test_substitute_repeat()
|
|||||||
call feedkeys("Qsc\<CR>y", 'tx')
|
call feedkeys("Qsc\<CR>y", 'tx')
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for *sub-replace-special* and *sub-replace-expression* on :substitute.
|
||||||
|
|
||||||
|
" Execute a list of :substitute command tests
|
||||||
|
func Run_SubCmd_Tests(tests)
|
||||||
|
enew!
|
||||||
|
for t in a:tests
|
||||||
|
let start = line('.') + 1
|
||||||
|
let end = start + len(t[2]) - 1
|
||||||
|
exe "normal o" . t[0]
|
||||||
|
call cursor(start, 1)
|
||||||
|
exe t[1]
|
||||||
|
call assert_equal(t[2], getline(start, end), t[1])
|
||||||
|
endfor
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_1()
|
||||||
|
set magic
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [['A', 's/A/&&/', ['AA']],
|
||||||
|
\ ['B', 's/B/\&/', ['&']],
|
||||||
|
\ ['C123456789', 's/C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']],
|
||||||
|
\ ['D', 's/D/d/', ['d']],
|
||||||
|
\ ['E', 's/E/~/', ['d']],
|
||||||
|
\ ['F', 's/F/\~/', ['~']],
|
||||||
|
\ ['G', 's/G/\ugg/', ['Gg']],
|
||||||
|
\ ['H', 's/H/\Uh\Eh/', ['Hh']],
|
||||||
|
\ ['I', 's/I/\lII/', ['iI']],
|
||||||
|
\ ['J', 's/J/\LJ\EJ/', ['jJ']],
|
||||||
|
\ ['K', 's/K/\Uk\ek/', ['Kk']],
|
||||||
|
\ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']],
|
||||||
|
\ ['mMm', 's/M/\r/', ['m', 'm']],
|
||||||
|
\ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']],
|
||||||
|
\ ['oOo', 's/O/\n/', ["o\no"]],
|
||||||
|
\ ['pPp', 's/P/\b/', ["p\<C-H>p"]],
|
||||||
|
\ ['qQq', 's/Q/\t/', ["q\tq"]],
|
||||||
|
\ ['rRr', 's/R/\\/', ['r\r']],
|
||||||
|
\ ['sSs', 's/S/\c/', ['scs']],
|
||||||
|
\ ['tTt', "s/T/\<C-V>\<C-J>/", ["t\<C-V>\<C-J>t"]],
|
||||||
|
\ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']],
|
||||||
|
\ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']]
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_2()
|
||||||
|
set nomagic
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [['A', 's/A/&&/', ['&&']],
|
||||||
|
\ ['B', 's/B/\&/', ['B']],
|
||||||
|
\ ['C123456789', 's/\mC\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']],
|
||||||
|
\ ['D', 's/D/d/', ['d']],
|
||||||
|
\ ['E', 's/E/~/', ['~']],
|
||||||
|
\ ['F', 's/F/\~/', ['~']],
|
||||||
|
\ ['G', 's/G/\ugg/', ['Gg']],
|
||||||
|
\ ['H', 's/H/\Uh\Eh/', ['Hh']],
|
||||||
|
\ ['I', 's/I/\lII/', ['iI']],
|
||||||
|
\ ['J', 's/J/\LJ\EJ/', ['jJ']],
|
||||||
|
\ ['K', 's/K/\Uk\ek/', ['Kk']],
|
||||||
|
\ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']],
|
||||||
|
\ ['mMm', 's/M/\r/', ['m', 'm']],
|
||||||
|
\ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']],
|
||||||
|
\ ['oOo', 's/O/\n/', ["o\no"]],
|
||||||
|
\ ['pPp', 's/P/\b/', ["p\<C-H>p"]],
|
||||||
|
\ ['qQq', 's/Q/\t/', ["q\tq"]],
|
||||||
|
\ ['rRr', 's/R/\\/', ['r\r']],
|
||||||
|
\ ['sSs', 's/S/\c/', ['scs']],
|
||||||
|
\ ['tTt', "s/T/\<C-V>\<C-J>/", ["t\<C-V>\<C-J>t"]],
|
||||||
|
\ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']],
|
||||||
|
\ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']]
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_3()
|
||||||
|
set nomagic
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [['aAa', "s/A/\\='\\'/", ['a\a']],
|
||||||
|
\ ['bBb', "s/B/\\='\\\\'/", ['b\\b']],
|
||||||
|
\ ['cCc', "s/C/\\='\<C-V>\<C-M>'/", ["c\<C-V>", 'c']],
|
||||||
|
\ ['dDd', "s/D/\\='\\\<C-V>\<C-M>'/", ["d\\\<C-V>", 'd']],
|
||||||
|
\ ['eEe', "s/E/\\='\\\\\<C-V>\<C-M>'/", ["e\\\\\<C-V>", 'e']],
|
||||||
|
\ ['fFf', "s/F/\\='\r'/", ['f', 'f']],
|
||||||
|
\ ['gGg', "s/G/\\='\<C-V>\<C-J>'/", ["g\<C-V>", 'g']],
|
||||||
|
\ ['hHh', "s/H/\\='\\\<C-V>\<C-J>'/", ["h\\\<C-V>", 'h']],
|
||||||
|
\ ['iIi', "s/I/\\='\\\\\<C-V>\<C-J>'/", ["i\\\\\<C-V>", 'i']],
|
||||||
|
\ ['jJj', "s/J/\\='\n'/", ['j', 'j']],
|
||||||
|
\ ['kKk', 's/K/\="\r"/', ['k', 'k']],
|
||||||
|
\ ['lLl', 's/L/\="\n"/', ['l', 'l']]
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for submatch() on :substitue.
|
||||||
|
func Test_sub_cmd_4()
|
||||||
|
set magic&
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [ ['aAa', "s/A/\\=substitute(submatch(0), '.', '\\', '')/",
|
||||||
|
\ ['a\a']],
|
||||||
|
\ ['bBb', "s/B/\\=substitute(submatch(0), '.', '\\', '')/",
|
||||||
|
\ ['b\b']],
|
||||||
|
\ ['cCc', "s/C/\\=substitute(submatch(0), '.', '\<C-V>\<C-M>', '')/",
|
||||||
|
\ ["c\<C-V>", 'c']],
|
||||||
|
\ ['dDd', "s/D/\\=substitute(submatch(0), '.', '\\\<C-V>\<C-M>', '')/",
|
||||||
|
\ ["d\<C-V>", 'd']],
|
||||||
|
\ ['eEe', "s/E/\\=substitute(submatch(0), '.', '\\\\\<C-V>\<C-M>', '')/",
|
||||||
|
\ ["e\\\<C-V>", 'e']],
|
||||||
|
\ ['fFf', "s/F/\\=substitute(submatch(0), '.', '\\r', '')/",
|
||||||
|
\ ['f', 'f']],
|
||||||
|
\ ['gGg', 's/G/\=substitute(submatch(0), ".", "\<C-V>\<C-J>", "")/',
|
||||||
|
\ ["g\<C-V>", 'g']],
|
||||||
|
\ ['hHh', 's/H/\=substitute(submatch(0), ".", "\\\<C-V>\<C-J>", "")/',
|
||||||
|
\ ["h\<C-V>", 'h']],
|
||||||
|
\ ['iIi', 's/I/\=substitute(submatch(0), ".", "\\\\\<C-V>\<C-J>", "")/',
|
||||||
|
\ ["i\\\<C-V>", 'i']],
|
||||||
|
\ ['jJj', "s/J/\\=substitute(submatch(0), '.', '\\n', '')/",
|
||||||
|
\ ['j', 'j']],
|
||||||
|
\ ['kKk', "s/K/\\=substitute(submatch(0), '.', '\\r', '')/",
|
||||||
|
\ ['k', 'k']],
|
||||||
|
\ ['lLl', "s/L/\\=substitute(submatch(0), '.', '\\n', '')/",
|
||||||
|
\ ['l', 'l']],
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_5()
|
||||||
|
set magic&
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [ ['A123456789', 's/A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)/', ['A123456789987654321']],
|
||||||
|
\ ['B123456789', 's/B\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=string([submatch(0, 1), submatch(9, 1), submatch(8, 1), submatch(7, 1), submatch(6, 1), submatch(5, 1), submatch(4, 1), submatch(3, 1), submatch(2, 1), submatch(1, 1)])/', ["[['B123456789'], ['9'], ['8'], ['7'], ['6'], ['5'], ['4'], ['3'], ['2'], ['1']]"]],
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for *:s%* on :substitute.
|
||||||
|
func Test_sub_cmd_6()
|
||||||
|
set magic&
|
||||||
|
set cpo+=/
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [ ['A', 's/A/a/', ['a']],
|
||||||
|
\ ['B', 's/B/%/', ['a']],
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
|
||||||
|
set cpo-=/
|
||||||
|
let tests = [ ['C', 's/C/c/', ['c']],
|
||||||
|
\ ['D', 's/D/%/', ['%']],
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
|
||||||
|
set cpo&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for :s replacing \n with line break.
|
||||||
|
func Test_sub_cmd_7()
|
||||||
|
set magic&
|
||||||
|
set cpo&
|
||||||
|
|
||||||
|
" List entry format: [input, cmd, output]
|
||||||
|
let tests = [ ["A\<C-V>\<C-M>A", 's/A./\=submatch(0)/', ['A', 'A']],
|
||||||
|
\ ["B\<C-V>\<C-J>B", 's/B./\=submatch(0)/', ['B', 'B']],
|
||||||
|
\ ["C\<C-V>\<C-J>C", 's/C./\=strtrans(string(submatch(0, 1)))/', [strtrans("['C\<C-J>']C")]],
|
||||||
|
\ ["D\<C-V>\<C-J>\nD", 's/D.\nD/\=strtrans(string(submatch(0, 1)))/', [strtrans("['D\<C-J>', 'D']")]],
|
||||||
|
\ ["E\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>E", 's/E\_.\{-}E/\=strtrans(string(submatch(0, 1)))/', [strtrans("['E\<C-J>', '\<C-J>', '\<C-J>', '\<C-J>', '\<C-J>E']")]],
|
||||||
|
\ ]
|
||||||
|
call Run_SubCmd_Tests(tests)
|
||||||
|
|
||||||
|
exe "normal oQ\nQ\<Esc>k"
|
||||||
|
call assert_fails('s/Q[^\n]Q/\=submatch(0)."foobar"/', 'E486')
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func TitleString()
|
||||||
|
let check = 'foo' =~ 'bar'
|
||||||
|
return ""
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_8()
|
||||||
|
set titlestring=%{TitleString()}
|
||||||
|
|
||||||
|
enew!
|
||||||
|
call append(0, ['', 'test_one', 'test_two'])
|
||||||
|
call cursor(1,1)
|
||||||
|
/^test_one/s/.*/\="foo\nbar"/
|
||||||
|
call assert_equal('foo', getline(2))
|
||||||
|
call assert_equal('bar', getline(3))
|
||||||
|
call feedkeys(':/^test_two/s/.*/\="foo\nbar"/c', "t")
|
||||||
|
call feedkeys("\<CR>y", "xt")
|
||||||
|
call assert_equal('foo', getline(4))
|
||||||
|
call assert_equal('bar', getline(5))
|
||||||
|
|
||||||
|
enew!
|
||||||
|
set titlestring&
|
||||||
|
endfunc
|
||||||
|
45
src/nvim/testdir/test_tab.vim
Normal file
45
src/nvim/testdir/test_tab.vim
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
" Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
|
||||||
|
" Also test that dv_ works correctly
|
||||||
|
func Test_smarttab()
|
||||||
|
enew!
|
||||||
|
set smarttab expandtab ts=8 sw=4
|
||||||
|
" make sure that backspace works, no matter what termcap is used
|
||||||
|
exe "set t_kD=\<C-V>x7f t_kb=\<C-V>x08"
|
||||||
|
call append(0, ['start text',
|
||||||
|
\ "\t\tsome test text",
|
||||||
|
\ 'test text',
|
||||||
|
\ "\t\tother test text",
|
||||||
|
\ ' a cde',
|
||||||
|
\ ' f ghi',
|
||||||
|
\ 'test text',
|
||||||
|
\ ' Second line beginning with whitespace'
|
||||||
|
\ ])
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal /some\<CR>"
|
||||||
|
exe "normal r\t"
|
||||||
|
call assert_equal("\t\t ome test text", getline('.'))
|
||||||
|
set noexpandtab
|
||||||
|
exe "normal /other\<CR>"
|
||||||
|
exe "normal r\t"
|
||||||
|
call assert_equal("\t\t ther test text", getline('.'))
|
||||||
|
|
||||||
|
" Test replacing with Tabs and then backspacing to undo it
|
||||||
|
exe "normal j0wR\t\t\t\<BS>\<BS>\<BS>"
|
||||||
|
call assert_equal(" a cde", getline('.'))
|
||||||
|
" Test replacing with Tabs
|
||||||
|
exe "normal j0wR\t\t\t"
|
||||||
|
call assert_equal(" \t\thi", getline('.'))
|
||||||
|
|
||||||
|
" Test that copyindent works with expandtab set
|
||||||
|
set expandtab smartindent copyindent ts=8 sw=8 sts=8
|
||||||
|
exe "normal jo{\<CR>x"
|
||||||
|
call assert_equal('{', getline(line('.') - 1))
|
||||||
|
call assert_equal(' x', getline('.'))
|
||||||
|
set nosol
|
||||||
|
exe "normal /Second line/\<CR>"
|
||||||
|
exe "normal fwdv_"
|
||||||
|
call assert_equal(' with whitespace', getline('.'))
|
||||||
|
enew!
|
||||||
|
set expandtab& smartindent& copyindent& ts& sw& sts&
|
||||||
|
endfunc
|
@ -95,4 +95,41 @@ function Test_keyword_jump()
|
|||||||
call delete('Xinclude')
|
call delete('Xinclude')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Test for jumping to a tag with 'hidden' set, with symbolic link in path of
|
||||||
|
" tag. This only works for Unix, because of the symbolic link.
|
||||||
|
func Test_tag_symbolic()
|
||||||
|
if !has('unix')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
set hidden
|
||||||
|
call delete("Xtest.dir", "rf")
|
||||||
|
call system("ln -s . Xtest.dir")
|
||||||
|
" Create a tags file with the current directory name inserted.
|
||||||
|
call writefile([
|
||||||
|
\ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/",
|
||||||
|
\ '',
|
||||||
|
\ ], 'Xtags')
|
||||||
|
call writefile(['#define SECTION_OFF 3',
|
||||||
|
\ '#define NUM_SECTIONS 3'], 'Xtest.c')
|
||||||
|
|
||||||
|
" Try jumping to a tag, but with a path that contains a symbolic link. When
|
||||||
|
" wrong, this will give the ATTENTION message. The next space will then be
|
||||||
|
" eaten by hit-return, instead of moving the cursor to 'd'.
|
||||||
|
set tags=Xtags
|
||||||
|
enew!
|
||||||
|
call append(0, 'SECTION_OFF')
|
||||||
|
call cursor(1,1)
|
||||||
|
exe "normal \<C-]> "
|
||||||
|
call assert_equal('Xtest.c', expand('%:t'))
|
||||||
|
call assert_equal(2, col('.'))
|
||||||
|
|
||||||
|
set hidden&
|
||||||
|
set tags&
|
||||||
|
enew!
|
||||||
|
call delete('Xtags')
|
||||||
|
call delete('Xtest.c')
|
||||||
|
call delete("Xtest.dir", "rf")
|
||||||
|
%bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -266,3 +266,19 @@ func Test_undofile_earlier()
|
|||||||
call delete('Xfile')
|
call delete('Xfile')
|
||||||
call delete('Xundofile')
|
call delete('Xundofile')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for undo working properly when executing commands from a register.
|
||||||
|
" Also test this in an empty buffer.
|
||||||
|
func Test_cmd_in_reg_undo()
|
||||||
|
enew!
|
||||||
|
let @a="Ox\<Esc>jAy\<Esc>kdd"
|
||||||
|
edit +/^$ test_undo.vim
|
||||||
|
normal @au
|
||||||
|
call assert_equal(0, &modified)
|
||||||
|
return
|
||||||
|
new
|
||||||
|
normal @au
|
||||||
|
call assert_equal(0, &modified)
|
||||||
|
only!
|
||||||
|
let @a=''
|
||||||
|
endfunc
|
||||||
|
@ -52,3 +52,102 @@ func Test_Visual_inner_quote()
|
|||||||
normal vki'
|
normal vki'
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for visual block shift and tab characters.
|
||||||
|
func Test_block_shift_tab()
|
||||||
|
enew!
|
||||||
|
call append(0, repeat(['one two three'], 5))
|
||||||
|
call cursor(1,1)
|
||||||
|
exe "normal i\<C-G>u"
|
||||||
|
exe "normal fe\<C-V>4jR\<Esc>ugvr1"
|
||||||
|
call assert_equal('on1 two three', getline(1))
|
||||||
|
call assert_equal('on1 two three', getline(2))
|
||||||
|
call assert_equal('on1 two three', getline(5))
|
||||||
|
|
||||||
|
enew!
|
||||||
|
call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5))
|
||||||
|
call cursor(1,1)
|
||||||
|
exe "normal \<C-V>4jI \<Esc>j<<11|D"
|
||||||
|
exe "normal j7|a\<Tab>\<Tab>"
|
||||||
|
exe "normal j7|a\<Tab>\<Tab> "
|
||||||
|
exe "normal j7|a\<Tab> \<Tab>\<Esc>4k13|\<C-V>4j<"
|
||||||
|
call assert_equal(' abcdefghijklmnopqrstuvwxyz', getline(1))
|
||||||
|
call assert_equal('abcdefghij', getline(2))
|
||||||
|
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(3))
|
||||||
|
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(4))
|
||||||
|
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(5))
|
||||||
|
|
||||||
|
%s/\s\+//g
|
||||||
|
call cursor(1,1)
|
||||||
|
exe "normal \<C-V>4jI \<Esc>j<<"
|
||||||
|
exe "normal j7|a\<Tab>\<Tab>"
|
||||||
|
exe "normal j7|a\<Tab>\<Tab>\<Tab>\<Tab>\<Tab>"
|
||||||
|
exe "normal j7|a\<Tab> \<Tab>\<Tab>\<Esc>4k13|\<C-V>4j3<"
|
||||||
|
call assert_equal(' abcdefghijklmnopqrstuvwxyz', getline(1))
|
||||||
|
call assert_equal('abcdefghij', getline(2))
|
||||||
|
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(3))
|
||||||
|
call assert_equal(" abc\<Tab>\<Tab>defghijklmnopqrstuvwxyz", getline(4))
|
||||||
|
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(5))
|
||||||
|
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Tests Blockwise Visual when there are TABs before the text.
|
||||||
|
func Test_blockwise_visual()
|
||||||
|
enew!
|
||||||
|
call append(0, ['123456',
|
||||||
|
\ '234567',
|
||||||
|
\ '345678',
|
||||||
|
\ '',
|
||||||
|
\ 'test text test tex start here',
|
||||||
|
\ "\t\tsome text",
|
||||||
|
\ "\t\ttest text",
|
||||||
|
\ 'test text'])
|
||||||
|
call cursor(1,1)
|
||||||
|
exe "normal /start here$\<CR>"
|
||||||
|
exe 'normal "by$' . "\<C-V>jjlld"
|
||||||
|
exe "normal /456$\<CR>"
|
||||||
|
exe "normal \<C-V>jj" . '"bP'
|
||||||
|
call assert_equal(['123start here56',
|
||||||
|
\ '234start here67',
|
||||||
|
\ '345start here78',
|
||||||
|
\ '',
|
||||||
|
\ 'test text test tex rt here',
|
||||||
|
\ "\t\tsomext",
|
||||||
|
\ "\t\ttesext"], getline(1, 7))
|
||||||
|
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test Virtual replace mode.
|
||||||
|
func Test_virtual_replace()
|
||||||
|
exe "set t_kD=\<C-V>x7f t_kb=\<C-V>x08"
|
||||||
|
enew!
|
||||||
|
exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\<C-D>uvwxyz"
|
||||||
|
call cursor(1,1)
|
||||||
|
set ai bs=2
|
||||||
|
exe "normal gR0\<C-D> 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR"
|
||||||
|
call assert_equal([' 1',
|
||||||
|
\ ' A',
|
||||||
|
\ ' BCDEFGHIJ',
|
||||||
|
\ ' KL',
|
||||||
|
\ ' MNO',
|
||||||
|
\ ' PQR',
|
||||||
|
\ ], getline(1, 6))
|
||||||
|
normal G
|
||||||
|
mark a
|
||||||
|
exe "normal o0\<C-D>\nabcdefghi\njk\tlmn\n opq\trst\n\<C-D>uvwxyz\n"
|
||||||
|
exe "normal 'ajgR0\<C-D> 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR" . repeat("\<BS>", 29)
|
||||||
|
call assert_equal([' 1',
|
||||||
|
\ 'abcdefghi',
|
||||||
|
\ 'jk lmn',
|
||||||
|
\ ' opq rst',
|
||||||
|
\ 'uvwxyz'], getline(7, 11))
|
||||||
|
normal G
|
||||||
|
exe "normal iab\tcdefghi\tjkl"
|
||||||
|
exe "normal 0gRAB......CDEFGHI.J\<Esc>o"
|
||||||
|
exe "normal iabcdefghijklmnopqrst\<Esc>0gRAB\tIJKLMNO\tQR"
|
||||||
|
call assert_equal(['AB......CDEFGHI.Jkl',
|
||||||
|
\ 'AB IJKLMNO QRst'], getline(12, 13))
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user