mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #18267 from zeertzjq/test-eq-arg-order
test: correct order of arguments to eq() and neq()
This commit is contained in:
@@ -727,7 +727,7 @@ describe('autocmd api', function()
|
|||||||
set_ft("txt")
|
set_ft("txt")
|
||||||
set_ft("python")
|
set_ft("python")
|
||||||
|
|
||||||
eq(get_executed_count(), 2)
|
eq(2, get_executed_count())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works getting called multiple times', function()
|
it('works getting called multiple times', function()
|
||||||
@@ -736,7 +736,7 @@ describe('autocmd api', function()
|
|||||||
set_ft()
|
set_ft()
|
||||||
set_ft()
|
set_ft()
|
||||||
|
|
||||||
eq(get_executed_count(), 3)
|
eq(3, get_executed_count())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles ++once', function()
|
it('handles ++once', function()
|
||||||
@@ -746,7 +746,7 @@ describe('autocmd api', function()
|
|||||||
set_ft('txt')
|
set_ft('txt')
|
||||||
set_ft('help')
|
set_ft('help')
|
||||||
|
|
||||||
eq(get_executed_count(), 1)
|
eq(1, get_executed_count())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('errors on unexpected keys', function()
|
it('errors on unexpected keys', function()
|
||||||
@@ -874,7 +874,7 @@ describe('autocmd api', function()
|
|||||||
set_ft("txt")
|
set_ft("txt")
|
||||||
set_ft("python")
|
set_ft("python")
|
||||||
|
|
||||||
eq(get_executed_count(), 1)
|
eq(1, get_executed_count())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('autocmds can be registered multiple times.', function()
|
it('autocmds can be registered multiple times.', function()
|
||||||
@@ -888,7 +888,7 @@ describe('autocmd api', function()
|
|||||||
set_ft("txt")
|
set_ft("txt")
|
||||||
set_ft("python")
|
set_ft("python")
|
||||||
|
|
||||||
eq(get_executed_count(), 3 * 2)
|
eq(3 * 2, get_executed_count())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can be deleted', function()
|
it('can be deleted', function()
|
||||||
|
@@ -63,9 +63,9 @@ describe('API', function()
|
|||||||
local pid = funcs.getpid()
|
local pid = funcs.getpid()
|
||||||
local pinfo = request('nvim_get_proc', pid)
|
local pinfo = request('nvim_get_proc', pid)
|
||||||
eq((iswin() and 'nvim.exe' or 'nvim'), pinfo.name)
|
eq((iswin() and 'nvim.exe' or 'nvim'), pinfo.name)
|
||||||
eq(pinfo.pid, pid)
|
eq(pid, pinfo.pid)
|
||||||
eq(type(pinfo.ppid), 'number')
|
eq('number', type(pinfo.ppid))
|
||||||
neq(pinfo.ppid, pid)
|
neq(pid, pinfo.ppid)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('validates input', function()
|
it('validates input', function()
|
||||||
|
@@ -122,9 +122,9 @@ describe('API', function()
|
|||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
nvim('exec', 'function Foo()\ncall setline(1,["xxx"])\nendfunction', false)
|
nvim('exec', 'function Foo()\ncall setline(1,["xxx"])\nendfunction', false)
|
||||||
eq(nvim('get_current_line'), '')
|
eq('', nvim('get_current_line'))
|
||||||
nvim('exec', 'call Foo()', false)
|
nvim('exec', 'call Foo()', false)
|
||||||
eq(nvim('get_current_line'), 'xxx')
|
eq('xxx', nvim('get_current_line'))
|
||||||
|
|
||||||
-- Autocmds
|
-- Autocmds
|
||||||
nvim('exec','autocmd BufAdd * :let x1 = "Hello"', false)
|
nvim('exec','autocmd BufAdd * :let x1 = "Hello"', false)
|
||||||
@@ -1841,10 +1841,10 @@ describe('API', function()
|
|||||||
-- spin the loop a bit
|
-- spin the loop a bit
|
||||||
helpers.run(nil, nil, on_setup)
|
helpers.run(nil, nil, on_setup)
|
||||||
|
|
||||||
eq(nvim('get_var', 'x1'), '…')
|
eq('…', nvim('get_var', 'x1'))
|
||||||
-- Because of the double escaping this is neq
|
-- Because of the double escaping this is neq
|
||||||
neq(nvim('get_var', 'x2'), '…')
|
neq('…', nvim('get_var', 'x2'))
|
||||||
eq(nvim('get_var', 'x3'), '…')
|
eq('…', nvim('get_var', 'x3'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ describe("'langmap'", function()
|
|||||||
command('nmapclear')
|
command('nmapclear')
|
||||||
end)
|
end)
|
||||||
it("'langnoremap' is by default ON", function()
|
it("'langnoremap' is by default ON", function()
|
||||||
eq(eval('&langnoremap'), 1)
|
eq(1, eval('&langnoremap'))
|
||||||
end)
|
end)
|
||||||
it("Results of maps are not converted when 'langnoremap' ON.",
|
it("Results of maps are not converted when 'langnoremap' ON.",
|
||||||
function()
|
function()
|
||||||
@@ -71,19 +71,19 @@ describe("'langmap'", function()
|
|||||||
feed('<C-w>s')
|
feed('<C-w>s')
|
||||||
local origwin = curwin()
|
local origwin = curwin()
|
||||||
feed('<C-w>i')
|
feed('<C-w>i')
|
||||||
neq(curwin(), origwin)
|
neq(origwin, curwin())
|
||||||
-- Works when setting a mark
|
-- Works when setting a mark
|
||||||
feed('yy3p3gg0mwgg0mi')
|
feed('yy3p3gg0mwgg0mi')
|
||||||
eq(call('getpos', "'i"), {0, 3, 1, 0})
|
eq({0, 3, 1, 0}, call('getpos', "'i"))
|
||||||
eq(call('getpos', "'w"), {0, 1, 1, 0})
|
eq({0, 1, 1, 0}, call('getpos', "'w"))
|
||||||
feed('3dd')
|
feed('3dd')
|
||||||
-- Works when moving to a mark
|
-- Works when moving to a mark
|
||||||
feed("'i")
|
feed("'i")
|
||||||
eq(call('getpos', '.'), {0, 1, 1, 0})
|
eq({0, 1, 1, 0}, call('getpos', '.'))
|
||||||
-- Works when selecting a register
|
-- Works when selecting a register
|
||||||
feed('qillqqwhhq')
|
feed('qillqqwhhq')
|
||||||
eq(eval('@i'), 'hh')
|
eq('hh', eval('@i'))
|
||||||
eq(eval('@w'), 'll')
|
eq('ll', eval('@w'))
|
||||||
feed('a<C-r>i<esc>')
|
feed('a<C-r>i<esc>')
|
||||||
expect('illii www')
|
expect('illii www')
|
||||||
feed('"ip')
|
feed('"ip')
|
||||||
@@ -107,7 +107,7 @@ describe("'langmap'", function()
|
|||||||
expect('wwi www')
|
expect('wwi www')
|
||||||
feed('u@a')
|
feed('u@a')
|
||||||
expect('wwi www')
|
expect('wwi www')
|
||||||
eq(eval('@a'), ':s/i/w/gc\ryyn')
|
eq(':s/i/w/gc\ryyn', eval('@a'))
|
||||||
end)
|
end)
|
||||||
it('insert-mode CTRL-G', function()
|
it('insert-mode CTRL-G', function()
|
||||||
command('set langmap=jk,kj')
|
command('set langmap=jk,kj')
|
||||||
@@ -127,7 +127,7 @@ describe("'langmap'", function()
|
|||||||
helhellolo
|
helhellolo
|
||||||
helxlo
|
helxlo
|
||||||
hello]])
|
hello]])
|
||||||
eq(eval('@a'), 'gg3|ahellojx')
|
eq('gg3|ahellojx', eval('@a'))
|
||||||
end)
|
end)
|
||||||
it('command-line CTRL-\\', function()
|
it('command-line CTRL-\\', function()
|
||||||
command('set langmap=en,ne')
|
command('set langmap=en,ne')
|
||||||
@@ -145,8 +145,8 @@ describe("'langmap'", function()
|
|||||||
set langmap=ij,ji
|
set langmap=ij,ji
|
||||||
]])
|
]])
|
||||||
feed(':let <C-R>i=1<CR>')
|
feed(':let <C-R>i=1<CR>')
|
||||||
eq(eval('i_value'), 1)
|
eq(1, eval('i_value'))
|
||||||
eq(eval('j_value'), 0)
|
eq(0, eval('j_value'))
|
||||||
end)
|
end)
|
||||||
-- it('-- More -- prompt', function()
|
-- it('-- More -- prompt', function()
|
||||||
-- -- The 'b' 'j' 'd' 'f' commands at the -- More -- prompt
|
-- -- The 'b' 'j' 'd' 'f' commands at the -- More -- prompt
|
||||||
@@ -186,17 +186,17 @@ describe("'langmap'", function()
|
|||||||
nnoremap x :call Map()<CR>
|
nnoremap x :call Map()<CR>
|
||||||
]])
|
]])
|
||||||
feed('x1<CR>')
|
feed('x1<CR>')
|
||||||
eq(eval('gotten_one'), 1)
|
eq(1, eval('gotten_one'))
|
||||||
command('let g:gotten_one = 0')
|
command('let g:gotten_one = 0')
|
||||||
feed_command('call Map()')
|
feed_command('call Map()')
|
||||||
feed('1<CR>')
|
feed('1<CR>')
|
||||||
eq(eval('gotten_one'), 1)
|
eq(1, eval('gotten_one'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
it('conversions are not applied during setreg()',
|
it('conversions are not applied during setreg()',
|
||||||
function()
|
function()
|
||||||
call('setreg', 'i', 'ww')
|
call('setreg', 'i', 'ww')
|
||||||
eq(eval('@i'), 'ww')
|
eq('ww', eval('@i'))
|
||||||
end)
|
end)
|
||||||
it('conversions not applied in insert mode', function()
|
it('conversions not applied in insert mode', function()
|
||||||
feed('aiiiwww')
|
feed('aiiiwww')
|
||||||
|
@@ -17,20 +17,20 @@ describe('macros', function()
|
|||||||
it('can be recorded and replayed', function()
|
it('can be recorded and replayed', function()
|
||||||
feed('qiahello<esc>q')
|
feed('qiahello<esc>q')
|
||||||
expect('hello')
|
expect('hello')
|
||||||
eq(eval('@i'), 'ahello')
|
eq('ahello', eval('@i'))
|
||||||
feed('@i')
|
feed('@i')
|
||||||
expect('hellohello')
|
expect('hellohello')
|
||||||
eq(eval('@i'), 'ahello')
|
eq('ahello', eval('@i'))
|
||||||
end)
|
end)
|
||||||
it('applies maps', function()
|
it('applies maps', function()
|
||||||
command('imap x l')
|
command('imap x l')
|
||||||
command('nmap l a')
|
command('nmap l a')
|
||||||
feed('qilxxx<esc>q')
|
feed('qilxxx<esc>q')
|
||||||
expect('lll')
|
expect('lll')
|
||||||
eq(eval('@i'), 'lxxx')
|
eq('lxxx', eval('@i'))
|
||||||
feed('@i')
|
feed('@i')
|
||||||
expect('llllll')
|
expect('llllll')
|
||||||
eq(eval('@i'), 'lxxx')
|
eq('lxxx', eval('@i'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can be replayed with Q', function()
|
it('can be replayed with Q', function()
|
||||||
|
@@ -17,7 +17,7 @@ describe('argument list commands', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function assert_fails(cmd, err)
|
local function assert_fails(cmd, err)
|
||||||
neq(exc_exec(cmd):find(err), nil)
|
neq(nil, exc_exec(cmd):find(err))
|
||||||
end
|
end
|
||||||
|
|
||||||
it('test that argidx() works', function()
|
it('test that argidx() works', function()
|
||||||
|
@@ -52,6 +52,6 @@ describe('sort', function()
|
|||||||
eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval([[sort([3.3, 1, "2", "A", "a", "AA"], '')]]))
|
eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval([[sort([3.3, 1, "2", "A", "a", "AA"], '')]]))
|
||||||
eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 0)'))
|
eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 0)'))
|
||||||
eq({'2', 'A', 'a', 'AA', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 1)'))
|
eq({'2', 'A', 'a', 'AA', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 1)'))
|
||||||
neq(exc_exec('call sort([3.3, 1, "2"], 3)'):find('E474:'), nil)
|
neq(nil, exc_exec('call sort([3.3, 1, "2"], 3)'):find('E474:'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -50,44 +50,44 @@ describe('wordcount', function()
|
|||||||
]=])
|
]=])
|
||||||
|
|
||||||
-- Test 1: empty window
|
-- Test 1: empty window
|
||||||
eq(eval('DoRecordWin()'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[[''], {'chars': 0, 'cursor_chars': 0, 'words': 0, 'cursor_words': 0, 'bytes': 0, 'cursor_bytes': 0}]
|
[[''], {'chars': 0, 'cursor_chars': 0, 'words': 0, 'cursor_words': 0, 'bytes': 0, 'cursor_bytes': 0}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin()')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 2: some words, cursor at start
|
-- Test 2: some words, cursor at start
|
||||||
command([[call PutInWindow('one two three')]])
|
command([[call PutInWindow('one two three')]])
|
||||||
eq(eval('DoRecordWin([1, 1, 0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}]
|
[['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([1, 1, 0])')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 3: some words, cursor at end
|
-- Test 3: some words, cursor at end
|
||||||
command([[call PutInWindow('one two three')]])
|
command([[call PutInWindow('one two three')]])
|
||||||
eq(eval('DoRecordWin([2, 99, 0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}]
|
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([2, 99, 0])')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 4: some words, cursor at end, ve=all
|
-- Test 4: some words, cursor at end, ve=all
|
||||||
command('set ve=all')
|
command('set ve=all')
|
||||||
command([[call PutInWindow('one two three')]])
|
command([[call PutInWindow('one two three')]])
|
||||||
eq(eval('DoRecordWin([2,99,0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}]
|
[['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([2,99,0])')
|
||||||
)
|
)
|
||||||
command('set ve=')
|
command('set ve=')
|
||||||
|
|
||||||
-- Test 5: several lines with words
|
-- Test 5: several lines with words
|
||||||
command([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=])
|
command([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=])
|
||||||
eq(eval('DoRecordWin([4,99,0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}]
|
[['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([4,99,0])')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 6: one line with BOM set
|
-- Test 6: one line with BOM set
|
||||||
@@ -95,10 +95,10 @@ describe('wordcount', function()
|
|||||||
command('wincmd k')
|
command('wincmd k')
|
||||||
command('set bomb')
|
command('set bomb')
|
||||||
command('wincmd j')
|
command('wincmd j')
|
||||||
eq(eval('DoRecordWin([2,99,0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}]
|
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([2,99,0])')
|
||||||
)
|
)
|
||||||
command('wincmd k')
|
command('wincmd k')
|
||||||
command('set nobomb')
|
command('set nobomb')
|
||||||
@@ -106,18 +106,18 @@ describe('wordcount', function()
|
|||||||
|
|
||||||
-- Test 7: one line with multibyte words
|
-- Test 7: one line with multibyte words
|
||||||
command([=[call PutInWindow(['Äne M¤ne Müh'])]=])
|
command([=[call PutInWindow(['Äne M¤ne Müh'])]=])
|
||||||
eq(eval('DoRecordWin([2,99,0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}]
|
[['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([2,99,0])')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 8: several lines with multibyte words
|
-- Test 8: several lines with multibyte words
|
||||||
command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
|
command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
|
||||||
eq(eval('DoRecordWin([3,99,0])'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}]
|
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('DoRecordWin([3,99,0])')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 9: visual mode, complete buffer
|
-- Test 9: visual mode, complete buffer
|
||||||
@@ -131,10 +131,10 @@ describe('wordcount', function()
|
|||||||
command('set stl= ls=1')
|
command('set stl= ls=1')
|
||||||
command('let log=DoRecordWin([3,99,0])')
|
command('let log=DoRecordWin([3,99,0])')
|
||||||
command('let log[1]=g:visual_stat')
|
command('let log[1]=g:visual_stat')
|
||||||
eq(eval('log'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}]
|
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('log')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 10: visual mode (empty)
|
-- Test 10: visual mode (empty)
|
||||||
@@ -148,10 +148,10 @@ describe('wordcount', function()
|
|||||||
command('set stl= ls=1')
|
command('set stl= ls=1')
|
||||||
command('let log=DoRecordWin([3,99,0])')
|
command('let log=DoRecordWin([3,99,0])')
|
||||||
command('let log[1]=g:visual_stat')
|
command('let log[1]=g:visual_stat')
|
||||||
eq(eval('log'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}]
|
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('log')
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 11: visual mode, single line
|
-- Test 11: visual mode, single line
|
||||||
@@ -165,10 +165,10 @@ describe('wordcount', function()
|
|||||||
command('set stl= ls=1')
|
command('set stl= ls=1')
|
||||||
command('let log=DoRecordWin([3,99,0])')
|
command('let log=DoRecordWin([3,99,0])')
|
||||||
command('let log[1]=g:visual_stat')
|
command('let log[1]=g:visual_stat')
|
||||||
eq(eval('log'),
|
eq(eval([=[
|
||||||
eval([=[
|
|
||||||
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}]
|
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}]
|
||||||
]=])
|
]=]),
|
||||||
|
eval('log')
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -645,17 +645,17 @@ describe('lua stdlib', function()
|
|||||||
return vim.tbl_islist(c) and count == 0
|
return vim.tbl_islist(c) and count == 0
|
||||||
]]))
|
]]))
|
||||||
|
|
||||||
eq(exec_lua([[
|
eq({a = {b = 1}}, exec_lua([[
|
||||||
local a = { a = { b = 1 } }
|
local a = { a = { b = 1 } }
|
||||||
local b = { a = {} }
|
local b = { a = {} }
|
||||||
return vim.tbl_deep_extend("force", a, b)
|
return vim.tbl_deep_extend("force", a, b)
|
||||||
]]), {a = {b = 1}})
|
]]))
|
||||||
|
|
||||||
eq(exec_lua([[
|
eq({a = {b = 1}}, exec_lua([[
|
||||||
local a = { a = 123 }
|
local a = { a = 123 }
|
||||||
local b = { a = { b = 1} }
|
local b = { a = { b = 1} }
|
||||||
return vim.tbl_deep_extend("force", a, b)
|
return vim.tbl_deep_extend("force", a, b)
|
||||||
]]), {a = {b = 1}})
|
]]))
|
||||||
|
|
||||||
ok(exec_lua([[
|
ok(exec_lua([[
|
||||||
local a = { a = {[2] = 3} }
|
local a = { a = {[2] = 3} }
|
||||||
@@ -664,11 +664,11 @@ describe('lua stdlib', function()
|
|||||||
return vim.deep_equal(c, {a = {[3] = 3}})
|
return vim.deep_equal(c, {a = {[3] = 3}})
|
||||||
]]))
|
]]))
|
||||||
|
|
||||||
eq(exec_lua([[
|
eq({a = 123}, exec_lua([[
|
||||||
local a = { a = { b = 1} }
|
local a = { a = { b = 1} }
|
||||||
local b = { a = 123 }
|
local b = { a = 123 }
|
||||||
return vim.tbl_deep_extend("force", a, b)
|
return vim.tbl_deep_extend("force", a, b)
|
||||||
]]), {a = 123 })
|
]]))
|
||||||
|
|
||||||
matches('invalid "behavior": nil',
|
matches('invalid "behavior": nil',
|
||||||
pcall_err(exec_lua, [[
|
pcall_err(exec_lua, [[
|
||||||
|
@@ -120,9 +120,9 @@ describe("'keymap' / :lmap", function()
|
|||||||
it("Can be toggled with <C-^> in insert mode", function()
|
it("Can be toggled with <C-^> in insert mode", function()
|
||||||
feed('i<C-^>l<C-^>l<esc>')
|
feed('i<C-^>l<C-^>l<esc>')
|
||||||
expect('lalllaaa')
|
expect('lalllaaa')
|
||||||
eq(eval('&iminsert'), 1)
|
eq(1, eval('&iminsert'))
|
||||||
feed('i<C-^><esc>')
|
feed('i<C-^><esc>')
|
||||||
eq(eval('&iminsert'), 0)
|
eq(0, eval('&iminsert'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
describe("'imsearch' option", function()
|
describe("'imsearch' option", function()
|
||||||
@@ -136,36 +136,36 @@ describe("'keymap' / :lmap", function()
|
|||||||
expect('aaa')
|
expect('aaa')
|
||||||
end)
|
end)
|
||||||
it("Can be toggled with C-^", function()
|
it("Can be toggled with C-^", function()
|
||||||
eq(eval('&imsearch'), 1)
|
eq(1, eval('&imsearch'))
|
||||||
feed('/<C-^>lll<cr>3x')
|
feed('/<C-^>lll<cr>3x')
|
||||||
expect('aaa')
|
expect('aaa')
|
||||||
eq(eval('&imsearch'), 0)
|
eq(0, eval('&imsearch'))
|
||||||
feed('u0/<C-^>lll<cr>3x')
|
feed('u0/<C-^>lll<cr>3x')
|
||||||
expect('lll')
|
expect('lll')
|
||||||
eq(eval('&imsearch'), 1)
|
eq(1, eval('&imsearch'))
|
||||||
end)
|
end)
|
||||||
it("can follow 'iminsert'", function()
|
it("can follow 'iminsert'", function()
|
||||||
command('set imsearch=-1')
|
command('set imsearch=-1')
|
||||||
feed('/lll<cr>3x')
|
feed('/lll<cr>3x')
|
||||||
expect('lll')
|
expect('lll')
|
||||||
eq(eval('&imsearch'), -1)
|
eq(-1, eval('&imsearch'))
|
||||||
eq(eval('&iminsert'), 1)
|
eq(1, eval('&iminsert'))
|
||||||
feed('u/<C-^>lll<cr>3x')
|
feed('u/<C-^>lll<cr>3x')
|
||||||
expect('aaa')
|
expect('aaa')
|
||||||
eq(eval('&imsearch'), -1)
|
eq(-1, eval('&imsearch'))
|
||||||
eq(eval('&iminsert'), 0)
|
eq(0, eval('&iminsert'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
it(":lmap not applied to macros", function()
|
it(":lmap not applied to macros", function()
|
||||||
command("call setreg('a', 'il')")
|
command("call setreg('a', 'il')")
|
||||||
feed('@a')
|
feed('@a')
|
||||||
expect('llllaaa')
|
expect('llllaaa')
|
||||||
eq(call('getreg', 'a'), 'il')
|
eq('il', call('getreg', 'a'))
|
||||||
end)
|
end)
|
||||||
it(":lmap applied to macro recording", function()
|
it(":lmap applied to macro recording", function()
|
||||||
feed('qail<esc>q@a')
|
feed('qail<esc>q@a')
|
||||||
expect('aalllaaa')
|
expect('aalllaaa')
|
||||||
eq(call('getreg', 'a'), 'ia')
|
eq('ia', call('getreg', 'a'))
|
||||||
end)
|
end)
|
||||||
it(":lmap not applied to mappings", function()
|
it(":lmap not applied to mappings", function()
|
||||||
command('imap t l')
|
command('imap t l')
|
||||||
|
@@ -85,8 +85,8 @@ describe('float window', function()
|
|||||||
local buf = meths.create_buf(false, false)
|
local buf = meths.create_buf(false, false)
|
||||||
meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
|
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})
|
local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})
|
||||||
eq(pcall_err(funcs.win_execute, win, 'close'), 'Vim(close):E37: No write since last change (add ! to override)')
|
eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(funcs.win_execute, win, 'close'))
|
||||||
eq(pcall_err(funcs.win_execute, win, 'bdelete'), 'Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)')
|
eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(funcs.win_execute, win, 'bdelete'))
|
||||||
funcs.win_execute(win, 'bwipe!')
|
funcs.win_execute(win, 'bwipe!')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ describe('float window', function()
|
|||||||
return vim.api.nvim_open_win(bufnr, false, opts)
|
return vim.api.nvim_open_win(bufnr, false, opts)
|
||||||
]])
|
]])
|
||||||
command('windo echo')
|
command('windo echo')
|
||||||
neq(eval('win_getid()'), winid)
|
neq(winid, eval('win_getid()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is active after windo when focusable', function()
|
it('is active after windo when focusable', function()
|
||||||
@@ -384,7 +384,7 @@ describe('float window', function()
|
|||||||
return vim.api.nvim_open_win(bufnr, false, opts)
|
return vim.api.nvim_open_win(bufnr, false, opts)
|
||||||
]])
|
]])
|
||||||
command('windo echo')
|
command('windo echo')
|
||||||
eq(eval('win_getid()'), winid)
|
eq(winid, eval('win_getid()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports windo with focusable and non-focusable floats', function()
|
it('supports windo with focusable and non-focusable floats', function()
|
||||||
|
@@ -12,7 +12,7 @@ describe('reltimestr(), reltimefloat()', function()
|
|||||||
local later = reltime()
|
local later = reltime()
|
||||||
local elapsed = reltime(now)
|
local elapsed = reltime(now)
|
||||||
|
|
||||||
neq(reltimestr(elapsed), '0.0')
|
neq('0.0', reltimestr(elapsed))
|
||||||
ok(reltimefloat(elapsed) > 0.0)
|
ok(reltimefloat(elapsed) > 0.0)
|
||||||
-- original vim test for < 0.1, but easily fails on travis
|
-- original vim test for < 0.1, but easily fails on travis
|
||||||
ok(nil ~= string.match(reltimestr(elapsed), "0%."))
|
ok(nil ~= string.match(reltimestr(elapsed), "0%."))
|
||||||
@@ -26,7 +26,7 @@ describe('reltimestr(), reltimefloat()', function()
|
|||||||
eq(0.0, reltimefloat(same))
|
eq(0.0, reltimefloat(same))
|
||||||
|
|
||||||
local differs = reltime(now, later)
|
local differs = reltime(now, later)
|
||||||
neq(reltimestr(differs), '0.0')
|
neq('0.0', reltimestr(differs))
|
||||||
ok(reltimefloat(differs) > 0.0)
|
ok(reltimefloat(differs) > 0.0)
|
||||||
-- original vim test for < 0.1, but easily fails on travis
|
-- original vim test for < 0.1, but easily fails on travis
|
||||||
ok(nil ~= string.match(reltimestr(differs), "0%."))
|
ok(nil ~= string.match(reltimestr(differs), "0%."))
|
||||||
|
@@ -24,41 +24,41 @@ describe('setpos() function', function()
|
|||||||
end)
|
end)
|
||||||
it('can set the current cursor position', function()
|
it('can set the current cursor position', function()
|
||||||
setpos(".", {0, 2, 1, 0})
|
setpos(".", {0, 2, 1, 0})
|
||||||
eq(getpos("."), {0, 2, 1, 0})
|
eq({0, 2, 1, 0}, getpos("."))
|
||||||
setpos(".", {2, 1, 1, 0})
|
setpos(".", {2, 1, 1, 0})
|
||||||
eq(getpos("."), {0, 1, 1, 0})
|
eq({0, 1, 1, 0}, getpos("."))
|
||||||
local ret = exc_exec('call setpos(".", [1, 1, 1, 0])')
|
local ret = exc_exec('call setpos(".", [1, 1, 1, 0])')
|
||||||
eq(0, ret)
|
eq(0, ret)
|
||||||
end)
|
end)
|
||||||
it('can set lowercase marks in the current buffer', function()
|
it('can set lowercase marks in the current buffer', function()
|
||||||
setpos("'d", {0, 2, 1, 0})
|
setpos("'d", {0, 2, 1, 0})
|
||||||
eq(getpos("'d"), {0, 2, 1, 0})
|
eq({0, 2, 1, 0}, getpos("'d"))
|
||||||
command('undo')
|
command('undo')
|
||||||
command('call setpos("\'d", [2, 3, 1, 0])')
|
command('call setpos("\'d", [2, 3, 1, 0])')
|
||||||
eq(getpos("'d"), {0, 3, 1, 0})
|
eq({0, 3, 1, 0}, getpos("'d"))
|
||||||
end)
|
end)
|
||||||
it('can set lowercase marks in other buffers', function()
|
it('can set lowercase marks in other buffers', function()
|
||||||
local retval = setpos("'d", {1, 2, 1, 0})
|
local retval = setpos("'d", {1, 2, 1, 0})
|
||||||
eq(0, retval)
|
eq(0, retval)
|
||||||
setpos("'d", {1, 2, 1, 0})
|
setpos("'d", {1, 2, 1, 0})
|
||||||
eq(getpos("'d"), {0, 0, 0, 0})
|
eq({0, 0, 0, 0}, getpos("'d"))
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
eq(eval('bufnr("%")'), 1)
|
eq(1, eval('bufnr("%")'))
|
||||||
eq(getpos("'d"), {0, 2, 1, 0})
|
eq({0, 2, 1, 0}, getpos("'d"))
|
||||||
end)
|
end)
|
||||||
it("fails when setting a mark in a buffer that doesn't exist", function()
|
it("fails when setting a mark in a buffer that doesn't exist", function()
|
||||||
local retval = setpos("'d", {3, 2, 1, 0})
|
local retval = setpos("'d", {3, 2, 1, 0})
|
||||||
eq(-1, retval)
|
eq(-1, retval)
|
||||||
eq(getpos("'d"), {0, 0, 0, 0})
|
eq({0, 0, 0, 0}, getpos("'d"))
|
||||||
retval = setpos("'D", {3, 2, 1, 0})
|
retval = setpos("'D", {3, 2, 1, 0})
|
||||||
eq(-1, retval)
|
eq(-1, retval)
|
||||||
eq(getpos("'D"), {0, 0, 0, 0})
|
eq({0, 0, 0, 0}, getpos("'D"))
|
||||||
end)
|
end)
|
||||||
it('can set uppercase marks', function()
|
it('can set uppercase marks', function()
|
||||||
setpos("'D", {2, 2, 3, 0})
|
setpos("'D", {2, 2, 3, 0})
|
||||||
eq(getpos("'D"), {2, 2, 3, 0})
|
eq({2, 2, 3, 0}, getpos("'D"))
|
||||||
-- Can set a mark in another buffer
|
-- Can set a mark in another buffer
|
||||||
setpos("'D", {1, 2, 2, 0})
|
setpos("'D", {1, 2, 2, 0})
|
||||||
eq(getpos("'D"), {1, 2, 2, 0})
|
eq({1, 2, 2, 0}, getpos("'D"))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -154,7 +154,7 @@ describe('env.c', function()
|
|||||||
local value = 'TESTVALUE'
|
local value = 'TESTVALUE'
|
||||||
os_setenv(name, value, 1)
|
os_setenv(name, value, 1)
|
||||||
eq(OK, os_unsetenv(name))
|
eq(OK, os_unsetenv(name))
|
||||||
neq(os_getenv(name), value)
|
neq(value, os_getenv(name))
|
||||||
-- Depending on the platform the var might be unset or set as ''
|
-- Depending on the platform the var might be unset or set as ''
|
||||||
assert.True(os_getenv(name) == nil or os_getenv(name) == '')
|
assert.True(os_getenv(name) == nil or os_getenv(name) == '')
|
||||||
if os_getenv(name) == nil then
|
if os_getenv(name) == nil then
|
||||||
|
Reference in New Issue
Block a user