Merge PR #1328 'Migrate legacy tests'

This commit is contained in:
Thiago de Arruda
2014-11-04 12:59:09 -03:00
71 changed files with 986 additions and 578 deletions

View File

@@ -1,12 +0,0 @@
Test if fnameescape is correct for special chars like !
STARTTEST
:%d
:let fname = 'Xspa ce'
:try | exe "w! " . fnameescape(fname) | put='Space' | endtry
:let fname = 'Xemark!'
:try | exe "w! " . fnameescape(fname) | put='ExclamationMark' | endtry
:w! test.out
:qa!
ENDTEST

View File

@@ -1,3 +0,0 @@
Space
ExclamationMark

View File

@@ -1,16 +0,0 @@
Tests for errorformat. vim: set ft=vim ts=8 :
STARTTEST
:so small.vim
:if !has('quickfix') | e! test.ok | wq! test.out | endif
:set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#
:cgetexpr ['WWWW', 'EEEE', 'CCCC']
:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
:cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']
:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
:cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']
:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
:/^Results/,$wq! test.out
ENDTEST
Results of test106:

View File

@@ -1,4 +0,0 @@
Results of test106:
[['W', 1], ['E^@CCCC', 1]]
[['W', 1], ['E^@CCCC', 1]]
[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]

View File

@@ -1,16 +0,0 @@
Tests for not doing smart indenting when it isn't set.
STARTTEST
:so small.vim
:set nocin nosi ai
/some
2cc#test
:?start?,$w! test.out
:qa!
ENDTEST
start text
some test text
test text
test text
test text

View File

@@ -1,4 +0,0 @@
start text
#test
test text
test text

View File

@@ -1,28 +0,0 @@
Tests Blockwise Visual when there are TABs before the text.
First test for undo working properly when executing commands from a register.
Also test this in an empty buffer.
STARTTEST
:so tiny.vim
G0"ay$k@au
:new
@auY:quit!
GP
/start here$
"by$jjlld
/456$
jj"bP
:/56$/,$-1w! test.out
:qa!
ENDTEST
123456
234567
345678
test text test tex start here
some text
test text
test text
OxjAykdd

View File

@@ -1,10 +0,0 @@
123start here56
234start here67
345start here78
test text test tex rt here
somext
tesext
test text

View File

@@ -1,13 +0,0 @@
Tests for file with some lines ending in CTRL-M, some not
STARTTEST
:set ta tx
:e!
:$-3,$w! test.out
:qa!
ENDTEST
this lines ends in a
this one doesn't
this one does
and the last one doesn't

View File

@@ -1,4 +0,0 @@
this lines ends in a
this one doesn't
this one does
and the last one doesn't

View File

@@ -1,15 +0,0 @@
Tests for complicated + argument to :edit command
STARTTEST
:$-1w! Xfile1
:$w! Xfile2
:edit +1|s/|/PIPE/|w Xfile1| e Xfile2|1 | s/\//SLASH/|w
:w! test.out
:e Xfile1
:w >> test.out
:qa!
ENDTEST
The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar"
foo|bar
foo/bar

View File

@@ -1,2 +0,0 @@
fooSLASHbar
fooPIPEbar

View File

@@ -1,20 +0,0 @@
Test for expanding file names
STARTTEST
:!mkdir Xdir1
:!mkdir Xdir2
:!mkdir Xdir3
:cd Xdir3
:!mkdir Xdir4
:cd ..
:w Xdir1/file
:w Xdir3/Xdir4/file
:n Xdir?/*/file
Go%:.w! test.out
:n! Xdir?/*/nofile
Go%:.w >>test.out
:e! xx
:!rm -rf Xdir1 Xdir2 Xdir3
:qa!
ENDTEST

View File

@@ -1,2 +0,0 @@
Xdir3/Xdir4/file
Xdir?/*/nofile

Binary file not shown.

View File

@@ -1,2 +0,0 @@
sd
map __2 asdsecondsdsd0map __5 asd0fifth

View File

@@ -1,31 +0,0 @@
Test for autocommand that changes current buffer on BufEnter event.
Check if modelines are interpreted for the correct buffer.
STARTTEST
:so small.vim
:set nocompatible viminfo+=nviminfo
:au BufEnter Xxx brew
/start of
:.,/end of/w! Xxx " write test file Xxx
:set ai modeline modelines=3
:sp Xxx " split to Xxx, autocmd will do :brew
G?this is a
othis should be auto-indented
: " Append text with autoindent to this file
:au! BufEnter Xxx
:buf Xxx " go to Xxx, no autocmd anymore
G?this is a
othis should be in column 1:wq " append text without autoindent to Xxx
G:r Xxx " include Xxx in the current file
:?startstart?,$w! test.out
:qa!
ENDTEST
startstart
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
end of test file Xxx

View File

@@ -1,17 +0,0 @@
startstart
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
this should be auto-indented
end of test file Xxx
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
this should be in column 1
end of test file Xxx

View File

@@ -1,24 +0,0 @@
Test for writing and reading a file of over 100 Kbyte
1 line: "This is the start"
3001 lines: "This is the leader"
1 line: "This is the middle"
3001 lines: "This is the trailer"
1 line: "This is the end"
STARTTEST
:%d
aThis is the start
This is the leader
This is the middle
This is the trailer
This is the endkY3000p2GY3000p
:w! Xtest
:%d
:e! Xtest
:.w! test.out
3003G:.w >>test.out
6005G:.w >>test.out
:qa!
ENDTEST

View File

@@ -1,3 +0,0 @@
This is the start
This is the middle
This is the end

View File

@@ -1,27 +0,0 @@
Tests for multi-line regexps with ":s". vim: set ft=vim :
STARTTEST
:" test if replacing a line break works with a back reference
:/^1/,/^2/s/\n\(.\)/ \1/
:" test if inserting a line break works with a back reference
:/^3/,/^4/s/\(.\)$/\r\1/
:" test if replacing a line break with another line break works
:/^5/,/^6/s/\(\_d\{3}\)/x\1x/
:/^1/,$w! test.out
:qa!
ENDTEST
1 aa
bb
cc
2 dd
ee
3 ef
gh
4 ij
5 a8
8b c9
9d
6 e7
77f
xxxxx

View File

@@ -1,13 +0,0 @@
1 aa bb cc 2 dd ee
3 e
f
g
h
4 i
j
5 ax8
8xb cx9
9xd
6 ex7
7x7f
xxxxx

View File

@@ -1,22 +0,0 @@
Some tests for buffer-local autocommands
STARTTEST
:so small.vim
:e xx
:if has("vms")
: !del test.out.*
: au BufLeave <buffer> :!write sys$output "buffer-local autommand in %" > test.out
:else
: !rm -f test.out
: au BufLeave <buffer> :!echo buffer-local autommand in %>> test.out
:endif
:e somefile " here, autocommand for xx shall write test.out
: " but autocommand shall not apply to buffer named <buffer>
:bwipe xx " here, autocommand shall be auto-deleted
:e xx " nothing shall be written
:e somefile " nothing shall be written
:qa!
ENDTEST
start of test file xx
end of test file xx

View File

@@ -1 +0,0 @@
buffer-local autommand in xx

View File

@@ -1,21 +0,0 @@
Test for script-local function. vim: set ft=vim :
STARTTEST
:so small.vim
:"
:set nocp viminfo+=nviminfo
:/^start:/+1,/^end:/-1w! Xtest.vim
:source Xtest.vim
_x
:$-1,$wq! test.out
ENDTEST
start:
fun <SID>DoLast()
call append(line('$'), "last line")
endfun
fun s:DoNothing()
call append(line('$'), "nothing line")
endfun
nnoremap <buffer> _x :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr>
end:

View File

@@ -1,2 +0,0 @@
nothing line
last line

View File

@@ -1,24 +0,0 @@
Test for autocommand that redefines the argument list, when doing ":all".
STARTTEST
:so small.vim
:au BufReadPost Xxx2 next Xxx2 Xxx1
/^start of
A1:.,/end of/w! Xxx1 " write test file Xxx1
$r2:.,/end of/w! Xxx2 " write test file Xxx2
$r3:.,/end of/w! Xxx3 " write test file Xxx3
:next! Xxx1 Xxx2 Xxx3 " redefine arglist; go to Xxx1
:all " open window for all args
:w! test.out " Write contents of Xxx1
:w >>test.out " Append contents of last window (Xxx1)
:rew " should now be in Xxx2
:w >>test.out " Append contents of Xxx2
:qa!
ENDTEST
start of test file Xxx
this is a test
this is a test
this is a test
this is a test
end of test file Xxx

View File

@@ -1,18 +0,0 @@
start of test file Xxx1
this is a test
this is a test
this is a test
this is a test
end of test file Xxx
start of test file Xxx1
this is a test
this is a test
this is a test
this is a test
end of test file Xxx
start of test file Xxx2
this is a test
this is a test
this is a test
this is a test
end of test file Xxx

View File

@@ -1,26 +0,0 @@
Test for autocommand that changes the buffer list, when doing ":ball".
STARTTEST
:so small.vim
/^start of
A1:.,/end of/w! Xxx1 " write test file Xxx1
:sp Xxx1
:close
$r2:.,/end of/w! Xxx2 " write test file Xxx2
:sp Xxx2
:close
$r3:.,/end of/w! Xxx3 " write test file Xxx3
:sp Xxx3
:close
:au BufReadPost Xxx2 bwipe
$r4:ball " open window for all args, close Xxx2
:.,$w! test.out " Write contents of this file
:w >>test.out " Append contents of second window (Xxx1)
:/^start of/,$w >>test.out " Append contents of last window (this file)
:qa!
ENDTEST
start of test file Xxx
this is a test
this is a test
end of test file Xxx

View File

@@ -1,12 +0,0 @@
start of test file Xxx4
this is a test
this is a test
end of test file Xxx
start of test file Xxx1
this is a test
this is a test
end of test file Xxx
start of test file Xxx4
this is a test
this is a test
end of test file Xxx

View File

@@ -1,22 +0,0 @@
Test for t movement command and 'cpo-;' setting
STARTTEST
:set nocompatible viminfo+=nviminfo
:set cpo-=;
/firstline/
j0tt;D
0fz;D
$Fy;D
$Ty;D:set cpo+=;
j0tt;;D
$Ty;;D:?firstline?+1,$w! test.out
:qa!
ENDTEST
firstline
aaa two three four
zzz
yyy
bbb yee yoo four
ccc two three four
ddd yee yoo four

View File

@@ -1,6 +0,0 @@
aaa two
z
y
bbb y
ccc
ddd yee y

View File

@@ -1,12 +0,0 @@
Test for Bufleave autocommand that deletes the buffer we are about to edit.
STARTTEST
:so small.vim
:au BufLeave test9.in bwipe yy
:e yy
:/^start of/,$w! test.out " Write contents of this file
:qa!
ENDTEST
start of test file xx
end of test file xx

View File

@@ -1,2 +0,0 @@
start of test file xx
end of test file xx

View File

@@ -1,23 +0,0 @@
Test whether glob()/globpath() return correct results with certain escaped
characters.
STARTTEST
:so small.vim
:" make sure glob() doesn't use the shell
:set shell=doesnotexist
:" consistent sorting of file names
:set nofileignorecase
:e test.out
:$put =glob('Xxx\{')
:$put =glob('Xxx\$')
:w! Xxx{
:w! Xxx\$
:$put =glob('Xxx\{')
:$put =glob('Xxx\$')
:"
:$put =string(globpath('sautest/autoload', '*.vim'))
:$put =string(globpath('sautest/autoload', '*.vim', 0, 1))
:w
:qa!
ENDTEST

View File

@@ -1,8 +0,0 @@
Xxx{
Xxx$
'sautest/autoload/Test104.vim
sautest/autoload/footest.vim'
['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']

View File

@@ -1,23 +0,0 @@
Tests for setting the '[,'] marks when joining lines.
STARTTEST
:so small.vim
:/^\t\t/
0gqj
:let a=string(getpos("'[")).'/'.string(getpos("']"))
:/^This line/;'}-join
:let b=string(getpos("'[")).'/'.string(getpos("']"))
:$put ='First test: Start/End '.string(a)
:$put ='Second test: Start/End '.string(b)
:/^\t\t/,$wq! test.out
ENDTEST
O sodales, ludite, vos qui
attamen consulite per voster honur. Tua pulchra facies me fay planszer milies
This line.
Should be joined with the next line
and with this line
Results:

View File

@@ -1,8 +0,0 @@
O sodales, ludite, vos qui attamen consulite per voster honur.
Tua pulchra facies me fay planszer milies
This line. Should be joined with the next line and with this line
Results:
First test: Start/End '[0, 16, 1, 0]/[0, 17, 1, 0]'
Second test: Start/End '[0, 19, 11, 0]/[0, 19, 67, 0]'

View File

@@ -1,22 +0,0 @@
Test changelist position after splitting window
Set 'undolevels' to make changelist for sourced file
STARTTEST
:so small.vim
Gkylp:set ul=100
Gylp:set ul=100
gg
:vsplit
:try
: normal g;
: normal ggVGcpass
:catch
: normal ggVGcfail
:finally
: %w! test.out
:endtry
:qa!
ENDTEST
1
2

View File

@@ -1 +0,0 @@
pass

View File

@@ -1,14 +0,0 @@
Tests for repeating insert and replace.
STARTTEST
:so small.vim
:/Second
4gro
:/^First/,$wq! test.out
:" get here when failed and in Insert mode
:.wq! test.out
ENDTEST
First line
Second line
Last line

View File

@@ -1,3 +0,0 @@
First line
ooooecond line
Last line

View File

@@ -1,17 +0,0 @@
Test for ":options".
STARTTEST
:so small.vim
:let caught = 'ok'
:try
:options
:catch
:let caught = v:throwpoint . "\n" . v:exception
:endtry
:buf 1
:$put =caught
:/^result/,$w! test.out
:qa!
ENDTEST
result

View File

@@ -1,2 +0,0 @@
result
ok

View File

@@ -1,18 +0,0 @@
Tests for Unicode manipulations
STARTTEST
:so small.vim
:set encoding=utf-8
:" Visual block Insert adjusts for multi-byte char
:new
:call setline(1, ["aaa", "あああ", "bbb"])
:exe ":norm! gg0l\<C-V>jjIx\<Esc>"
:let r = getline(1, '$')
:
:bwipeout!
:$put=r
:call garbagecollect(1)
:/^start:/,$wq! test.out
ENDTEST
start:

View File

@@ -1,4 +0,0 @@
start:
axaa
xあああ
bxbb

View File

@@ -67,6 +67,25 @@ local function restart()
mapclear!
abclear
comclear
let regs = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"'
let i = 0
while i < strlen(regs)
call setreg(regs[i], '')
let i = i+1
endwhile
redir => funcs
silent! function
redir END
for fname in split(funcs, '\n')
let matches = matchlist(fname, '\v^function ([^()<>]+)')
if type([]) == type(matches) && matches[1] !~ 'BeforeEachTest'
exe 'silent! delfunc '.matches[1]
endif
endfor
let options = ['shell', 'fileignorecase']
for option in options
exe 'set '.option.'&'
endfor
endfunction
]])
end
@@ -83,6 +102,9 @@ local function request(method, ...)
error(rv[2])
end
end
-- Make sure this will only return after all buffered characters have been
-- processed
session:request('vim_eval', '1')
return rv
end
@@ -201,7 +223,6 @@ local function expect(contents, first, last, buffer_index)
return eq(dedent(contents), buffer_slice(first, last, buffer_index))
end
local function ok(expr)
assert.is_true(expr)
end
@@ -254,6 +275,7 @@ restart()
return {
clear = clear,
dedent = dedent,
restart = restart,
rawfeed = rawfeed,
insert = insert,

View File

@@ -0,0 +1,72 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test for autocommand that changes current buffer on BufEnter event.
-- Check if modelines are interpreted for the correct buffer.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('BufEnter with modelines', function()
setup(clear)
it('is working', function()
insert([[
startstart
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
end of test file Xxx]])
execute('au BufEnter Xxx brew')
-- Write test file Xxx
execute('/start of')
execute('.,/end of/w! Xxx')
execute('set ai modeline modelines=3')
-- Split to Xxx, autocmd will do :brew
execute('sp Xxx')
-- Append text with autoindent to this file
feed('G?this is a<Esc>')
feed('othis should be auto-indented<Esc>')
-- Go to Xxx, no autocmd anymore
execute('au! BufEnter Xxx')
execute('buf Xxx')
-- Append text without autoindent to Xxx
feed('G?this is a<Esc>')
feed('othis should be in column 1<Esc>')
execute('wq')
-- Include Xxx in the current file
feed('G:r Xxx<CR>')
expect([[
startstart
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
this should be auto-indented
end of test file Xxx
start of test file Xxx
vim: set noai :
this is a test
this is a test
this is a test
this is a test
this should be in column 1
end of test file Xxx]])
end)
teardown(function()
os.remove('Xxx')
end)
end)

View File

@@ -0,0 +1,81 @@
-- Test for autocommand that redefines the argument list, when doing ":all".
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, dedent, eq = helpers.execute, helpers.dedent, helpers.eq
local curbuf_contents = helpers.curbuf_contents
describe('argument list', function()
setup(clear)
it('is working', function()
insert([[
start of test file Xxx
this is a test
this is a test
this is a test
this is a test
end of test file Xxx]])
execute('au BufReadPost Xxx2 next Xxx2 Xxx1')
execute('/^start of')
-- Write test file Xxx1
feed('A1<Esc>:.,/end of/w! Xxx1<cr>')
-- Write test file Xxx2
feed('$r2:.,/end of/w! Xxx2<cr>')
-- Write test file Xxx3
feed('$r3:.,/end of/w! Xxx3<cr>')
-- Redefine arglist; go to Xxx1
execute('next! Xxx1 Xxx2 Xxx3')
-- Open window for all args
execute('all')
-- Write contents of Xxx1
execute('%yank A')
-- Append contents of last window (Xxx1)
feed('')
execute('%yank A')
-- should now be in Xxx2
execute('rew')
-- Append contents of Xxx2
execute('%yank A')
execute('%d')
execute('0put=@a')
execute('1d | $d')
eq(dedent([[
start of test file Xxx1
this is a test
this is a test
this is a test
this is a test
end of test file Xxx
start of test file Xxx1
this is a test
this is a test
this is a test
this is a test
end of test file Xxx
start of test file Xxx2
this is a test
this is a test
this is a test
this is a test
end of test file Xxx]]), curbuf_contents())
end)
teardown(function()
os.remove('Xxx1')
os.remove('Xxx2')
os.remove('Xxx3')
end)
end)

View File

@@ -0,0 +1,77 @@
-- Test for autocommand that changes the buffer list, when doing ":ball".
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe(':ball', function()
setup(clear)
it('is working', function()
insert([[
start of test file Xxx
this is a test
this is a test
end of test file Xxx]])
execute('w! Xxx0')
feed('gg')
-- Write test file Xxx1
feed('A1:.,/end of/w! Xxx1<cr>')
execute('sp Xxx1')
execute('close')
-- Write test file Xxx2
feed('$r2:.,/end of/w! Xxx2<cr>')
execute('sp Xxx2')
execute('close')
-- Write test file Xxx3
feed('$r3:.,/end of/w! Xxx3<cr>')
execute('sp Xxx3')
execute('close')
execute('au BufReadPost Xxx2 bwipe')
-- Open window for all args, close Xxx2
feed('$r4:ball<cr>')
-- Write contents of this file
execute('%yank A')
-- Append contents of second window (Xxx1)
feed('')
execute('%yank A')
-- Append contents of last window (this file)
feed('')
execute('%yank A')
execute('bf')
execute('%d')
execute('0put=@a')
execute('1d | $d')
expect([[
start of test file Xxx4
this is a test
this is a test
end of test file Xxx
start of test file Xxx1
this is a test
this is a test
end of test file Xxx
start of test file Xxx4
this is a test
this is a test
end of test file Xxx]])
end)
teardown(function()
os.remove('Xxx0')
os.remove('Xxx1')
os.remove('Xxx2')
os.remove('Xxx3')
end)
end)

View File

@@ -0,0 +1,22 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('BufLeave autocommand', function()
setup(clear)
it('is working', function()
insert([[
start of test file xx
end of test file xx]])
execute('au BufLeave * bwipe yy')
execute('e yy')
expect([[
start of test file xx
end of test file xx]])
end)
end)

View File

@@ -0,0 +1,28 @@
-- Tests for not doing smart indenting when it isn't set.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('unset smart indenting', function()
setup(clear)
it('is working', function()
insert([[
start text
some test text
test text
test text
test text]])
execute('set nocin nosi ai')
execute('/some')
feed('2cc#test<Esc>')
expect([[
start text
#test
test text
test text]])
end)
end)

View File

@@ -0,0 +1,49 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests Blockwise Visual when there are TABs before the text.
-- First test for undo working properly when executing commands from a register.
-- Also test this in an empty buffer.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('blockwise visual', function()
setup(clear)
it('is working', function()
insert([[
123456
234567
345678
test text test tex start here
some text
test text
test text
x jAy kdd
Ox jAy kdd]])
feed(":let @a = 'Ox<C-v><Esc>jAy<C-v><Esc>kdd'<cr>")
feed('G0k@au')
execute('new')
feed('@auY')
execute('quit')
feed('GP')
execute('/start here')
feed('"by$<C-v>jjlld')
execute('/456')
feed('<C-v>jj"bP')
execute('$-3,$d')
expect([[
123start here56
234start here67
345start here78
test text test tex rt here
somext
tesext
test text]])
end)
end)

View File

@@ -0,0 +1,41 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('CTRL-W CTRL-I', function()
setup(clear)
it('is working', function()
insert([[
#include test21.in
/* test text test tex start here
some text
test text
start OK if found this line
start found wrong line
test text]])
-- Search for the second occurence of start and append to register
execute('/start')
feed('2[<C-i>')
execute('yank A')
-- Same as above but using different keystrokes.
feed('?start<cr>')
feed('2<C-w><Tab>')
execute('yank A')
-- Clean buffer and put register
feed('ggdG"ap')
execute('1,2d')
-- The buffer should now contain:
expect([[
start OK if found this line
start OK if found this line]])
end)
end)

View File

@@ -0,0 +1,25 @@
-- Tests for file with some lines ending in CTRL-M, some not
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('line ending', function()
setup(clear)
it('is working', function()
feed('i', [[
this lines ends in a<C-V><C-M>
this one doesn't
this one does<C-V><C-M>
and the last one doesn't]], '<ESC>')
execute('set ta tx')
execute('e!')
expect("this lines ends in a\r\n"..
"this one doesn't\n"..
"this one does\r\n"..
"and the last one doesn't")
end)
end)

View File

@@ -0,0 +1,52 @@
-- Tests for complicated + argument to :edit command
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe(':edit', function()
setup(clear)
it('is working', function()
insert([[
The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar"
foo|bar
foo/bar]])
-- Prepare some test files
execute('$-1w! Xfile1')
execute('$w! Xfile2')
execute('w! Xfile0')
-- Open Xfile using '+' range
execute('edit +1 Xfile1')
execute('s/|/PIPE/')
execute('yank A')
execute('w! Xfile1')
-- Open Xfile2 using '|' range
execute('edit Xfile2|1')
execute("s/\\//SLASH/")
execute('yank A')
execute('w! Xfile2')
-- Clean first buffer and put @a
execute('bf')
execute('%d')
execute('0put a')
-- Remove empty lines
execute('1d | $d')
-- The buffer should now contain
expect([[
fooPIPEbar
fooSLASHbar]])
end)
teardown(function()
os.remove('Xfile0')
os.remove('Xfile1')
os.remove('Xfile2')
end)
end)

View File

@@ -0,0 +1,38 @@
-- Test for expanding file names
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
local curbuf_contents = helpers.curbuf_contents
local eq, eval = helpers.eq, helpers.eval
describe('expand file name', function()
setup(clear)
it('is working', function()
execute('set nocp')
execute('!mkdir Xdir1')
execute('!mkdir Xdir2')
execute('!mkdir Xdir3')
execute('cd Xdir3')
execute('!mkdir Xdir4')
execute('cd ..')
execute('w Xdir1/file')
execute('w Xdir3/Xdir4/file')
execute('n Xdir?/*/file')
-- Yank current file path to @a register
feed('i<C-R>%<Esc>V"ad')
-- Put @a and current file path in the current buffer
execute('n! Xdir?/*/nofile')
feed('V"ap')
feed('o<C-R>%<Esc>')
eq("Xdir3/Xdir4/file\nXdir?/*/nofile", curbuf_contents())
end)
teardown(function()
os.execute('rm -rf Xdir1 Xdir2 Xdir3')
end)
end)

View File

@@ -0,0 +1,40 @@
-- Test for sourcing a file with CTRL-V's at the end of the line
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('CTRL-V at the end of the line', function()
setup(clear)
it('is working', function()
insert([[
firstline
map __1 afirst
map __2 asecond
map __3 athird
map __4 afourth
map __5 afifth
map __1 asdX
map __2 asdXX
map __3 asdXX
map __4 asdXXX
map __5 asdXXX
lastline]])
feed(':%s/X/<C-v><C-v>/g<cr>')
feed(':/firstline/+1,/lastline/-1w! Xtestfile<cr>')
execute('so Xtestfile')
execute('%d')
feed('Gmm__1<Esc><Esc>__2<Esc>__3<Esc><Esc>__4<Esc>__5<Esc>')
feed(":'m,$s/<C-v><C-@>/0/g<cr>")
expect([[
sd
map __2 asdsecondsdsd0map __5 asd0fifth]])
end)
teardown(function()
os.remove('Xtestfile')
end)
end)

View File

@@ -0,0 +1,40 @@
-- Test for writing and reading a file of over 100 Kbyte
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('writing and reading a file of over 100 Kbyte', function()
setup(clear)
it('is working', function()
insert([[
This is the start
This is the leader
This is the middle
This is the trailer
This is the end]])
feed('kY3000p2GY3000p')
execute('w! test.out')
execute('%d')
execute('e! test.out')
execute('yank A')
execute('3003yank A')
execute('6005yank A')
execute('%d')
execute('0put a')
execute('1d | $d')
execute('w!')
expect([[
This is the start
This is the middle
This is the end]])
end)
teardown(function()
os.remove('test.out')
end)
end)

View File

@@ -0,0 +1,52 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for multi-line regexps with ":s"
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('multi-line regexp', function()
setup(clear)
it('is working', function()
insert([[
1 aa
bb
cc
2 dd
ee
3 ef
gh
4 ij
5 a8
8b c9
9d
6 e7
77f
xxxxx]])
-- Test if replacing a line break works with a back reference
feed([[:/^1/,/^2/s/\n\(.\)/ \1/<cr>]])
-- Test if inserting a line break works with a back reference
feed([[:/^3/,/^4/s/\(.\)$/\r\1/<cr>]])
-- Test if replacing a line break with another line break works
feed([[:/^5/,/^6/s/\(\_d\{3}\)/x\1x/<cr>]])
expect([[
1 aa bb cc 2 dd ee
3 e
f
g
h
4 i
j
5 ax8
8xb cx9
9xd
6 ex7
7x7f
xxxxx]])
end)
end)

View File

@@ -0,0 +1,33 @@
-- Some tests for buffer-local autocommands
local helpers = require('test.functional.helpers')
local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq
local curbuf_contents = helpers.curbuf_contents
describe('BufLeave <buffer>', function()
setup(clear)
it('is working', function()
execute('w! xx')
execute('au BufLeave <buffer> norm Ibuffer-local autocommand')
execute('au BufLeave <buffer> update')
-- Here, autocommand for xx shall append a line
-- But autocommand shall not apply to buffer named <buffer>
execute('e somefile')
-- Here, autocommand shall be auto-deleted
execute('bwipe xx')
-- Nothing shall be written
execute('e xx')
execute('e somefile')
execute('e xx')
eq('buffer-local autocommand', curbuf_contents())
end)
teardown(function()
os.remove('xx')
end)
end)

View File

@@ -0,0 +1,31 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test for script-local function.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('source function', function()
setup(clear)
it('is working', function()
insert([[
fun DoLast()
call append(line('$'), "last line")
endfun
fun DoNothing()
call append(line('$'), "nothing line")
endfun
nnoremap <buffer> _x :call DoNothing()<bar>call DoLast()<cr>]])
feed(':<C-R>=getline(1,3)<cr><cr>')
feed(':<C-R>=getline(4,6)<cr><cr>')
feed(':<C-R>=getline(7)<cr><cr>')
feed('ggdG')
feed('_xggdd')
expect([[
nothing line
last line]])
end)
end)

View File

@@ -0,0 +1,39 @@
-- Test for t movement command and 'cpo-;' setting
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('coptions', function()
setup(clear)
it('is working', function()
insert([[
aaa two three four
zzz
yyy
bbb yee yoo four
ccc two three four
ddd yee yoo four]])
execute('set cpo-=;')
feed('gg0tt;D')
feed('j0fz;D')
feed('j$Fy;D')
feed('j$Ty;D')
execute('set cpo+=;')
feed('j0tt;;D')
feed('j$Ty;;D')
expect([[
aaa two
z
y
bbb y
ccc
ddd yee y]])
end)
end)

View File

@@ -0,0 +1,50 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test whether glob()/globpath() return correct results with certain escaped
-- characters.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('glob() and globpath()', function()
setup(clear)
setup(function()
os.execute("mkdir -p sautest/autoload")
os.execute("touch sautest/autoload/Test104.vim")
os.execute("touch sautest/autoload/footest.vim")
end)
it('is working', function()
-- Make sure glob() doesn't use the shell
execute('set shell=doesnotexist')
-- Consistent sorting of file names
execute('set nofileignorecase')
execute([[$put =glob('Xxx\{')]])
execute([[$put =glob('Xxx\$')]])
execute('w! Xxx{')
execute([[w! Xxx\$]])
execute([[$put =glob('Xxx\{')]])
execute([[$put =glob('Xxx\$')]])
execute("$put =string(globpath('sautest/autoload', '*.vim'))")
execute("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))")
expect([=[
Xxx{
Xxx$
'sautest/autoload/Test104.vim
sautest/autoload/footest.vim'
['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=])
end)
teardown(function()
os.execute("rm -rf sautest Xxx{ Xxx$")
end)
end)

View File

@@ -0,0 +1,26 @@
-- Test if fnameescape is correct for special chars like!
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('fnameescape', function()
setup(clear)
it('is working', function()
execute('let fname = "Xspa ce"')
execute('try', 'exe "w! " . fnameescape(fname)', "put='Space'", 'endtry')
execute('let fname = "Xemark!"')
execute('try', 'exe "w! " . fnameescape(fname)', "put='ExclamationMark'", 'endtry')
expect([[
Space
ExclamationMark]])
end)
teardown(function()
os.remove("Xspa ce")
os.remove("Xemark!")
end)
end)

View File

@@ -0,0 +1,25 @@
-- Tests for errorformat.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('errorformat', function()
setup(clear)
it('is working', function()
execute("set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#")
execute("cgetexpr ['WWWW', 'EEEE', 'CCCC']")
execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))")
execute("cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']")
execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))")
execute("cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']")
execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))")
expect([=[
[['W', 1], ['E^@CCCC', 1]]
[['W', 1], ['E^@CCCC', 1]]
[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]]=])
end)
end)

View File

@@ -0,0 +1,41 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for setting the '[,'] marks when joining lines.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('autoformat join', function()
setup(clear)
it('is working', function()
insert([[
O sodales, ludite, vos qui
attamen consulite per voster honur. Tua pulchra facies me fay planszer milies
This line.
Should be joined with the next line
and with this line
Results:]])
feed('gg')
feed('0gqj<cr>')
execute([[let a=string(getpos("'[")).'/'.string(getpos("']"))]])
execute("g/^This line/;'}-join")
execute([[let b=string(getpos("'[")).'/'.string(getpos("']"))]])
execute("$put ='First test: Start/End '.string(a)")
execute("$put ='Second test: Start/End '.string(b)")
expect([[
O sodales, ludite, vos qui attamen consulite per voster honur.
Tua pulchra facies me fay planszer milies
This line. Should be joined with the next line and with this line
Results:
First test: Start/End '[0, 1, 1, 0]/[0, 2, 1, 0]'
Second test: Start/End '[0, 4, 11, 0]/[0, 4, 67, 0]']])
end)
end)

View File

@@ -0,0 +1,26 @@
-- Test changelist position after splitting window
-- Set 'undolevels' to make changelist for sourced file
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('changelist', function()
setup(clear)
it('is working', function()
insert("1\n2")
feed('Gkylp')
execute('set ul=100')
feed('Gylp')
execute('set ul=100')
feed('gg')
execute('vsplit')
execute('try', 'normal g;', 'normal ggVGcpass', 'catch', 'normal ggVGcfail', 'endtry')
expect('pass')
end)
end)

View File

@@ -0,0 +1,24 @@
-- Tests for repeating insert and replace.
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('insertcount', function()
setup(clear)
it('is working', function()
insert([[
First line
Second line
Last line]])
execute('/Second')
feed('4gro')
expect([[
First line
oooond line
Last line]])
end)
end)

View File

@@ -0,0 +1,20 @@
-- Test for ":options".
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('options', function()
setup(clear)
it('is working', function()
insert('result')
execute("let caught = 'ok'")
execute('try', 'options', 'catch', 'let caught = v:throwpoint . "\n" . v:exception', 'endtry')
execute('buf 1')
execute('$put =caught')
expect("result\nok")
end)
end)

View File

@@ -0,0 +1,31 @@
-- Tests for Unicode manipulations
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('utf8', function()
setup(clear)
it('is working', function()
insert('start:')
execute('set encoding=utf-8')
execute('new')
execute('call setline(1, ["aaa", "あああ", "bbb"])')
-- Visual block Insert adjusts for multi-byte char
feed('gg0l<C-V>jjIx<Esc>')
execute('let r = getline(1, "$")')
execute('bwipeout!')
execute('$put=r')
execute('call garbagecollect(1)')
expect([[
start:
axaa
xあああ
bxbb]])
end)
end)