diff options
Diffstat (limited to 'test/functional/legacy')
| -rw-r--r-- | test/functional/legacy/autochdir_spec.lua | 94 | ||||
| -rw-r--r-- | test/functional/legacy/delete_spec.lua | 43 | ||||
| -rw-r--r-- | test/functional/legacy/file_perm_spec.lua | 43 | ||||
| -rw-r--r-- | test/functional/legacy/searchpos_spec.lua | 35 | ||||
| -rw-r--r-- | test/functional/legacy/set_spec.lua | 30 |
5 files changed, 76 insertions, 169 deletions
diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua index 37a94476a0..13cb6cd287 100644 --- a/test/functional/legacy/autochdir_spec.lua +++ b/test/functional/legacy/autochdir_spec.lua @@ -1,8 +1,12 @@ local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches -local eval, command, call = helpers.eval, helpers.command, helpers.call -local exec_capture = helpers.exec_capture +local eval, command, call, meths = helpers.eval, helpers.command, helpers.call, helpers.meths +local source, exec_capture = helpers.source, helpers.exec_capture + +local function expected_empty() + eq({}, meths.get_vvar('errors')) +end describe('autochdir behavior', function() local dir = 'Xtest_functional_legacy_autochdir' @@ -10,19 +14,66 @@ describe('autochdir behavior', function() before_each(function() lfs.mkdir(dir) clear() + command('set shellslash') end) after_each(function() helpers.rmdir(dir) end) - -- Tests vim/vim/777 without test_autochdir(). + -- Tests vim/vim#777 without test_autochdir(). it('sets filename', function() command('set acd') command('new') command('w '..dir..'/Xtest') eq('Xtest', eval("expand('%')")) - eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]])) + eq(dir, eval([[substitute(getcwd(), '.*/\(\k*\)', '\1', '')]])) + end) + + it(':file in win_execute() does not cause wrong directory', function() + command('cd '..dir) + source([[ + func Test_set_filename_other_window() + let cwd = getcwd() + call mkdir('Xa') + call mkdir('Xb') + call mkdir('Xc') + try + args Xa/aaa.txt Xb/bbb.txt + set acd + let winid = win_getid() + snext + call assert_equal('Xb', substitute(getcwd(), '.*/\([^/]*\)$', '\1', '')) + call win_execute(winid, 'file ' .. cwd .. '/Xc/ccc.txt') + call assert_equal('Xb', substitute(getcwd(), '.*/\([^/]*\)$', '\1', '')) + finally + set noacd + call chdir(cwd) + call delete('Xa', 'rf') + call delete('Xb', 'rf') + call delete('Xc', 'rf') + bwipe! aaa.txt + bwipe! bbb.txt + bwipe! ccc.txt + endtry + endfunc + ]]) + call('Test_set_filename_other_window') + expected_empty() + end) + + it('win_execute() does not change directory', function() + local subdir = 'Xfile' + command('cd '..dir) + command('set acd') + call('mkdir', subdir) + local winid = eval('win_getid()') + command('new '..subdir..'/file') + matches(dir..'/'..subdir..'$', eval('getcwd()')) + command('cd ..') + matches(dir..'$', eval('getcwd()')) + call('win_execute', winid, 'echo') + matches(dir..'$', eval('getcwd()')) end) it(':verbose pwd shows whether autochdir is used', function() @@ -30,29 +81,36 @@ describe('autochdir behavior', function() command('cd '..dir) local cwd = eval('getcwd()') command('edit global.txt') - matches('%[global%].*'..dir, exec_capture('verbose pwd')) + matches('%[global%].*'..dir..'$', exec_capture('verbose pwd')) call('mkdir', subdir) command('split '..subdir..'/local.txt') command('lcd '..subdir) - matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd')) - command('set autochdir') + matches('%[window%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd')) + command('set acd') command('wincmd w') - matches('%[autochdir%].*'..dir, exec_capture('verbose pwd')) - command('lcd '..cwd) - matches('%[window%].*'..dir, exec_capture('verbose pwd')) + matches('%[autochdir%].*'..dir..'$', exec_capture('verbose pwd')) command('tcd '..cwd) - matches('%[tabpage%].*'..dir, exec_capture('verbose pwd')) + matches('%[tabpage%].*'..dir..'$', exec_capture('verbose pwd')) command('cd '..cwd) - matches('%[global%].*'..dir, exec_capture('verbose pwd')) + matches('%[global%].*'..dir..'$', exec_capture('verbose pwd')) + command('lcd '..cwd) + matches('%[window%].*'..dir..'$', exec_capture('verbose pwd')) command('edit') - matches('%[autochdir%].*'..dir, exec_capture('verbose pwd')) + matches('%[autochdir%].*'..dir..'$', exec_capture('verbose pwd')) + command('enew') command('wincmd w') - matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd')) - command('set noautochdir') - matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd')) + matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd')) command('wincmd w') - matches('%[global%].*'..dir, exec_capture('verbose pwd')) + matches('%[window%].*'..dir..'$', exec_capture('verbose pwd')) + command('wincmd w') + matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd')) + command('set noacd') + matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd')) + command('wincmd w') + matches('%[window%].*'..dir..'$', exec_capture('verbose pwd')) + command('cd '..cwd) + matches('%[global%].*'..dir..'$', exec_capture('verbose pwd')) command('wincmd w') - matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd')) + matches('%[window%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd')) end) end) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index 141d9583e6..623b6b14a5 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -1,7 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source local eq, eval, command = helpers.eq, helpers.eval, helpers.command -local exc_exec = helpers.exc_exec describe('Test for delete()', function() before_each(clear) @@ -9,42 +8,6 @@ describe('Test for delete()', function() os.remove('Xfile') end) - it('file delete', function() - command('split Xfile') - command("call setline(1, ['a', 'b'])") - command('wq') - eq(eval("['a', 'b']"), eval("readfile('Xfile')")) - eq(0, eval("delete('Xfile')")) - eq(-1, eval("delete('Xfile')")) - end) - - it('directory delete', function() - command("call mkdir('Xdir1')") - eq(1, eval("isdirectory('Xdir1')")) - eq(0, eval("delete('Xdir1', 'd')")) - eq(0, eval("isdirectory('Xdir1')")) - eq(-1, eval("delete('Xdir1', 'd')")) - end) - it('recursive delete', function() - command("call mkdir('Xdir1')") - command("call mkdir('Xdir1/subdir')") - command("call mkdir('Xdir1/empty')") - command('split Xdir1/Xfile') - command("call setline(1, ['a', 'b'])") - command('w') - command('w Xdir1/subdir/Xfile') - command('close') - - eq(1, eval("isdirectory('Xdir1')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')")) - eq(1, eval("isdirectory('Xdir1/subdir')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')")) - eq(1, eval("'Xdir1/empty'->isdirectory()")) - eq(0, eval("delete('Xdir1', 'rf')")) - eq(0, eval("isdirectory('Xdir1')")) - eq(-1, eval("delete('Xdir1', 'd')")) - end) - it('symlink delete', function() source([[ split Xfile @@ -115,10 +78,4 @@ describe('Test for delete()', function() eq(0, eval("delete('Xdir4/Xfile')")) eq(0, eval("delete('Xdir4', 'd')")) end) - - it('gives correct emsgs', function() - eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')")) - eq('Vim(call):E15: Invalid expression: 0', - exc_exec("call delete('foo', 0)")) - end) end) diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua deleted file mode 100644 index ccdbfe0534..0000000000 --- a/test/functional/legacy/file_perm_spec.lua +++ /dev/null @@ -1,43 +0,0 @@ --- Test getting and setting file permissions. -require('os') - -local helpers = require('test.functional.helpers')(after_each) -local clear, call, eq = helpers.clear, helpers.call, helpers.eq -local neq, exc_exec, eval = helpers.neq, helpers.exc_exec, helpers.eval - -describe('Test getting and setting file permissions', function() - local tempfile = helpers.tmpname() - - before_each(function() - os.remove(tempfile) - clear() - end) - - it('file permissions', function() - -- eval() is used to test VimL method syntax for setfperm() and getfperm() - eq('', call('getfperm', tempfile)) - eq(0, eval("'" .. tempfile .. "'->setfperm('r--------')")) - - call('writefile', {'one'}, tempfile) - eq(9, eval("len('" .. tempfile .. "'->getfperm())")) - - eq(1, call('setfperm', tempfile, 'rwx------')) - if helpers.is_os('win') then - eq('rw-rw-rw-', call('getfperm', tempfile)) - else - eq('rwx------', call('getfperm', tempfile)) - end - - eq(1, call('setfperm', tempfile, 'r--r--r--')) - eq('r--r--r--', call('getfperm', tempfile)) - - local err = exc_exec(('call setfperm("%s", "---")'):format(tempfile)) - neq(err:find('E475:'), nil) - - eq(1, call('setfperm', tempfile, 'rwx------')) - end) - - after_each(function() - os.remove(tempfile) - end) -end) diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua deleted file mode 100644 index fc18341c38..0000000000 --- a/test/functional/legacy/searchpos_spec.lua +++ /dev/null @@ -1,35 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local call = helpers.call -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval -local insert = helpers.insert - -describe('searchpos', function() - before_each(clear) - - it('is working', function() - insert([[ - 1a3 - 123xyz]]) - - call('cursor', 1, 1) - eq({1, 1, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) - call('cursor', 1, 2) - eq({2, 1, 1}, eval([['\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW')]])) - - command('set cpo-=c') - call('cursor', 1, 2) - eq({1, 2, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) - call('cursor', 1, 3) - eq({1, 3, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) - - -- Now with \zs, first match is in column 0, "a" is matched. - call('cursor', 1, 3) - eq({2, 4, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')]])) - -- With z flag start at cursor column, don't see the "a". - call('cursor', 1, 3) - eq({2, 4, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')]])) - end) -end) diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua deleted file mode 100644 index deb268b1e8..0000000000 --- a/test/functional/legacy/set_spec.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Tests for :set - -local helpers = require('test.functional.helpers')(after_each) -local clear, command, eval, eq = - helpers.clear, helpers.command, helpers.eval, helpers.eq - -describe(':set', function() - before_each(clear) - - it('handles backslash properly', function() - command('set iskeyword=a,b,c') - command('set iskeyword+=d') - eq('a,b,c,d', eval('&iskeyword')) - - command([[set iskeyword+=\\,e]]) - eq([[a,b,c,d,\,e]], eval('&iskeyword')) - - command('set iskeyword-=e') - eq([[a,b,c,d,\]], eval('&iskeyword')) - - command([[set iskeyword-=\]]) - eq('a,b,c,d', eval('&iskeyword')) - end) - - it('recognizes a trailing comma with +=', function() - command('set wildignore=*.png,') - command('set wildignore+=*.jpg') - eq('*.png,*.jpg', eval('&wildignore')) - end) -end) |