test: update tests to work with 'hidden'

This commit is contained in:
Gregory Anders
2021-08-17 21:30:58 -06:00
parent d417e67e59
commit d8ab8cccd0
25 changed files with 48 additions and 32 deletions

Binary file not shown.

View File

@@ -998,6 +998,7 @@ func Test_bufunload_all()
endfunc
au BufUnload * call UnloadAllBufs()
au VimLeave * call writefile(['Test Finished'], 'Xout')
set nohidden
edit Xxx1
split Xxx2
q

View File

@@ -33,7 +33,7 @@ func Test_command_count_0()
delcommand RangeBuffers
delcommand RangeBuffersAll
set hidden&
set nohidden
set swapfile&
endfunc

View File

@@ -540,7 +540,7 @@ func Test_diffopt_hiddenoff()
bwipe!
bwipe!
set hidden& diffopt&
set nohidden diffopt&
endfunc
func Test_diffoff_hidden()
@@ -577,7 +577,7 @@ func Test_diffoff_hidden()
bwipe!
bwipe!
set hidden& diffopt&
set nohidden diffopt&
endfunc
func Test_setting_cursor()

View File

@@ -145,7 +145,7 @@ func Test_gf_visual()
bwipe!
call delete('Xtest_gf_visual')
set hidden&
set nohidden
endfunc
func Test_gf_error()

View File

@@ -95,7 +95,7 @@ func Test_ins_complete()
call delete('Xtest11.one')
call delete('Xtest11.two')
call delete('Xtestdata')
set cpt& cot& def& tags& tagbsearch& hidden&
set cpt& cot& def& tags& tagbsearch& nohidden
cd ..
call delete('Xdir', 'rf')
endfunc

View File

@@ -35,7 +35,6 @@ endfunc
" Tests for setting the '[,'] marks when joining lines.
func Test_join_marks()
set joinspaces
enew
call append(0, [
\ "\t\tO sodales, ludite, vos qui",
@@ -52,9 +51,8 @@ func Test_join_marks()
/^This line/;'}-join
call assert_equal([0, 4, 11, 0], getpos("'["))
call assert_equal([0, 4, 67, 0], getpos("']"))
call assert_equal([0, 4, 66, 0], getpos("']"))
enew!
set nojoinspaces
endfunc
" Test for joining lines and marks in them

View File

@@ -307,7 +307,7 @@ func Test_mksession_buffer_count()
call delete('Xbaz')
call delete('Xtest_mks.out')
%bwipe!
set hidden&
set nohidden
endfunc
if has('extra_search')

View File

@@ -539,7 +539,7 @@ func Test_copy_winopt()
call assert_equal(4,&numberwidth)
bw!
set hidden&
set nohidden
endfunc
func Test_shortmess_F()

View File

@@ -170,7 +170,7 @@ func Test_tag_symbolic()
call assert_equal('Xtest.c', expand('%:t'))
call assert_equal(2, col('.'))
set hidden&
set nohidden
set tags&
enew!
call delete('Xtags')

View File

@@ -608,7 +608,7 @@ func Test_window_prevwin()
" reset
q
call delete('tmp.txt')
set hidden&vim autoread&vim
set nohidden autoread&vim
delfunc Fun_RenewFile
endfunc

View File

@@ -159,9 +159,8 @@ describe('API: buffer events:', function()
tick = tick + 1
expectn('nvim_buf_lines_event', {b, tick, 29, 29, firstfour, false})
-- create a new empty buffer and wipe out the old one ... this will
-- turn off buffer events
command('enew!')
-- delete the current buffer to turn off buffer events
command('bdelete!')
expectn('nvim_buf_detach_event', {b})
-- add a line at the start of an empty file
@@ -269,7 +268,7 @@ describe('API: buffer events:', function()
'original foo'}, false})
-- type text into the first line of a blank file, one character at a time
command('enew!')
command('bdelete!')
tick = 2
expectn('nvim_buf_detach_event', {b})
local bnew = nvim('get_current_buf')
@@ -666,7 +665,8 @@ describe('API: buffer events:', function()
tick = tick + 1
expectn('nvim_buf_changedtick_event', {b, tick})
-- close our buffer by creating a new one
-- close our buffer and create a new one
command('bdelete')
command('enew')
expectn('nvim_buf_detach_event', {b})

View File

@@ -311,7 +311,8 @@ describe('API/win', function()
eq({newwin}, meths.list_wins())
end)
it('handles changed buffer', function()
it("handles changed buffer when 'hidden' is unset", function()
command('set nohidden')
local oldwin = meths.get_current_win()
insert('text')
command('new')

View File

@@ -221,9 +221,9 @@ describe('getbufvar() function', function()
eq(0, funcs.getbufvar(1, '&l:autoindent'))
eq(0, funcs.getbufvar(1, '&g:autoindent'))
-- Also works with global-only options
eq(0, funcs.getbufvar(1, '&hidden'))
eq(0, funcs.getbufvar(1, '&l:hidden'))
eq(0, funcs.getbufvar(1, '&g:hidden'))
eq(1, funcs.getbufvar(1, '&hidden'))
eq(1, funcs.getbufvar(1, '&l:hidden'))
eq(1, funcs.getbufvar(1, '&g:hidden'))
-- Also works with window-local options
eq(0, funcs.getbufvar(1, '&number'))
eq(0, funcs.getbufvar(1, '&l:number'))
@@ -279,9 +279,9 @@ describe('setbufvar() function', function()
eq(false, winmeths.get_option(windows[3], 'number'))
eq(false, winmeths.get_option(meths.get_current_win(), 'number'))
eq(false, meths.get_option('hidden'))
funcs.setbufvar(1, '&hidden', true)
eq(true, meths.get_option('hidden'))
funcs.setbufvar(1, '&hidden', 0)
eq(false, meths.get_option('hidden'))
eq(false, bufmeths.get_option(buf1, 'autoindent'))
funcs.setbufvar(1, '&autoindent', true)

View File

@@ -47,6 +47,7 @@ for _, c in ipairs({'l', 'c'}) do
eq(('%s-2.res'):format(file), funcs.bufname(list[2].bufnr))
-- Run cfile/lfile from a modified buffer
command('set nohidden')
command('enew!')
curbufmeths.set_lines(1, 1, true, {'Quickfix'})
eq(('Vim(%s):E37: No write since last change (add ! to override)'):format(

View File

@@ -8,6 +8,9 @@ describe(':ball', function()
setup(clear)
it('is working', function()
-- Must disable 'hidden' so that the BufReadPost autocmd is triggered
-- when Xxx2 is reloaded
feed_command('set nohidden')
insert([[
start of test file Xxx
this is a test
@@ -18,7 +21,7 @@ describe(':ball', function()
feed('gg')
-- Write test file Xxx1
feed('A1:.,/end of/w! Xxx1<cr>')
feed('A1<esc>:.,/end of/w! Xxx1<cr>')
feed_command('sp Xxx1')
feed_command('close')

View File

@@ -71,6 +71,9 @@ describe('autocommands that delete and unload buffers:', function()
au BufUnload * call CloseAll()
au VimLeave * call WriteToOut()
]])
-- Must disable 'hidden' so that the BufUnload autocmd is triggered between
-- each :edit
command('set nohidden')
command('silent! edit Xxx2')
command('silent! edit Xxx1')
command('silent! edit Makefile') -- an existing file

View File

@@ -129,13 +129,11 @@ describe('file reading, writing and bufnew and filter autocommands', function()
-- Will load Xtest.c.
feed_command('e! foo.c')
feed_command("au FileAppendPre *.out '[,']s/new/NEW/")
feed_command('au FileAppendPost *.out !cat Xtest.c >>test.out')
feed_command('au FileAppendPost *.out !cat Xtest.c >test.out')
-- Append it to the output file.
feed_command('w>>test.out')
-- Discard all prompts and messages.
feed('<C-L>')
-- Expect the decompressed file in the buffer.
feed_command('e test.out')
expect([[
/*

View File

@@ -80,6 +80,7 @@ describe("'directory' option", function()
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
meths.set_option('directory', 'Xtest.je')
command('bdelete')
command('edit Xtest2/Xtest3')
eq(true, curbufmeths.get_option('swapfile'))
poke_eventloop()

View File

@@ -156,10 +156,12 @@ describe('argument list commands', function()
eq({'a', 'b', 'a', 'c'}, eval('argv()'))
command('0argedit x')
eq({'x', 'a', 'b', 'a', 'c'}, eval('argv()'))
command('set nohidden')
command('enew! | set modified')
assert_fails('argedit y', 'E37:')
command('argedit! y')
eq({'x', 'y', 'y', 'a', 'b', 'a', 'c'}, eval('argv()'))
command('set hidden')
command('%argd')
command('argedit a b')
eq({'a', 'b'}, eval('argv()'))

View File

@@ -91,7 +91,8 @@ describe('cdo', function()
exe "silent! 4,5" . XdoCmd
call assert_equal([], l)
" Run commands from an unsaved buffer
" Run commands from an unsaved buffer when 'hidden' is unset
set nohidden
let v:errmsg=''
let l = []
enew
@@ -108,6 +109,7 @@ describe('cdo', function()
if subst_count != 1 || getline('.') != 'xLine1'
call add(v:errors, 'Abort command on error test failed')
endif
set hidden
let l = []
exe "2,2" . Xdo . "! call add(l, GetRuler())"

View File

@@ -23,8 +23,6 @@ describe('fixeol', function()
it('is working', function()
-- First write two test files with and without trailing EOL.
-- Use Unix fileformat for consistency.
feed_command('set ff=unix')
feed_command('enew!')
feed('awith eol<esc>:w! XXEol<cr>')
feed_command('enew!')
@@ -40,7 +38,7 @@ describe('fixeol', function()
feed_command('e! XXNoEol')
feed('ostays without<esc>:set nofixeol<cr>')
feed_command('w! XXTestNoEol')
feed_command('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
feed_command('bwipe! XXEol XXNoEol XXTestEol XXTestNoEol')
feed_command('set fixeol')
-- Append "END" to each file so that we can see what the last written char was.

View File

@@ -2161,6 +2161,12 @@ describe('plugin/shada.vim', function()
reset()
wshada('\004\000\009\147\000\196\002ab\196\001a')
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
-- Need to set nohidden so that the buffer containing 'fname' is not unloaded
-- after loading 'fname_tmp', otherwise the '++opt not supported' test below
-- won't work since the BufReadCmd autocmd won't be triggered.
nvim_command('set nohidden')
nvim_command('edit ' .. fname)
eq({
'History entry with timestamp ' .. epoch .. ':',

View File

@@ -74,7 +74,8 @@ describe('float window', function()
funcs.win_execute(win, 'bwipe!')
end)
it('win_execute() call commands that not allowed' , function()
it("win_execute() call commands that are not allowed when 'hidden' is not set" , function()
command('set nohidden')
local buf = meths.create_buf(false, false)
meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})

View File

@@ -69,6 +69,7 @@ describe('ui/ext_tabline', function()
command("bnext")
local expected_buffers = {
{buffer = { id = 1 }, name = '[No Name]'},
{buffer = { id = 2 }, name = 'another-buffer'},
}
screen:expect{grid=[[