test: fix wrong order of args to eq(), neq() #41499

This commit is contained in:
zeertzjq
2026-08-26 19:18:22 +08:00
committed by GitHub
parent 6e1744c092
commit d393abad77
23 changed files with 423 additions and 424 deletions

View File

@@ -590,11 +590,11 @@ describe('autocmd api', function()
local aus = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }
local first = aus[1]
eq(first.id, nil)
eq(nil, first.id)
-- TODO: Maybe don't have this number, just assert it's not nil
local second = aus[2]
neq(second.id, nil)
neq(nil, second.id)
api.nvim_del_autocmd(second.id)
local new_aus = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } }

View File

@@ -449,7 +449,7 @@ describe('server -> client', function()
call chansend(chan, 0Z71616C6C21)
let g:statuses = jobwait([chan])
]])
eq(eval('g:statuses'), { 0 })
eq({ 0 }, eval('g:statuses'))
assert_alive()
end)
end)

View File

@@ -6,7 +6,6 @@ local describe, it, before_each = t.describe, t.it, t.before_each
local clear, eq, ok = n.clear, t.eq, t.ok
local matches = t.matches
local exec = n.exec
local feed = n.feed
local api = n.api
local fn = n.fn
local request = n.request
@@ -201,12 +200,12 @@ describe('api/tabpage', function()
local newtabs = api.nvim_list_tabpages()
eq(3, #newtabs)
eq(newtabs, {
eq({
tab1,
tab2,
-- new_tab,
tab3,
})
}, newtabs)
local new_tab = api.nvim_open_tabpage(0, false, { after = api.nvim_tabpage_get_number(tab2) })
local newtabs2 = api.nvim_list_tabpages()
@@ -217,7 +216,7 @@ describe('api/tabpage', function()
new_tab,
tab3,
}, newtabs2)
eq(api.nvim_get_current_tabpage(), tab3)
eq(tab3, api.nvim_get_current_tabpage())
end)
it('respects the `enter` argument', function()
@@ -228,8 +227,8 @@ describe('api/tabpage', function()
local new_tab = api.nvim_open_tabpage(0, false, {})
local newtabs = api.nvim_list_tabpages()
eq(2, #newtabs)
eq(newtabs, { tab1, new_tab })
eq(api.nvim_get_current_tabpage(), tab1)
eq({ tab1, new_tab }, newtabs)
eq(tab1, api.nvim_get_current_tabpage())
-- Tabline redrawn when not entering.
screen:expect([[
{5: [No Name] }{24: [No Name] }{2: }{24:X}|
@@ -241,8 +240,8 @@ describe('api/tabpage', function()
local new_tab2 = api.nvim_open_tabpage(0, true, {})
local newtabs2 = api.nvim_list_tabpages()
eq(3, #newtabs2)
eq(newtabs2, { tab1, new_tab2, new_tab })
eq(api.nvim_get_current_tabpage(), new_tab2)
eq({ tab1, new_tab2, new_tab }, newtabs2)
eq(new_tab2, api.nvim_get_current_tabpage())
-- Tabline redrawn. (when entering)
screen:expect([[
{24: [No Name] }{5: [No Name] }{24: [No Name] }{2: }{24:X}|
@@ -364,7 +363,7 @@ describe('api/tabpage', function()
eq(6, #tabs_after_middle)
eq({ first_tab, tab1, before_middle, tab2, tab3, explicit_after_current }, tabs_after_middle)
eq(api.nvim_get_current_tabpage(), tab3)
eq(tab3, api.nvim_get_current_tabpage())
-- Test default behavior (after current)
local default_after_current = api.nvim_open_tabpage(0, false, {})

View File

@@ -48,9 +48,9 @@ describe('API/win', function()
it('works', function()
command('new')
local windows = api.nvim_list_wins()
neq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1]))
neq(api.nvim_win_get_buf(windows[1]), api.nvim_win_get_buf(windows[2]))
api.nvim_win_set_buf(windows[2], api.nvim_win_get_buf(windows[1]))
eq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1]))
eq(api.nvim_win_get_buf(windows[1]), api.nvim_win_get_buf(windows[2]))
end)
it('validates args', function()
@@ -651,13 +651,13 @@ describe('API/win', function()
end)
end)
describe('get_position', function()
describe('get_tabpage', function()
it('works', function()
command('tabnew')
command('vsplit')
eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[1]), api.nvim_list_tabpages()[1])
eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[2]), api.nvim_list_tabpages()[2])
eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[3]), api.nvim_list_tabpages()[2])
eq(api.nvim_list_tabpages()[1], api.nvim_win_get_tabpage(api.nvim_list_wins()[1]))
eq(api.nvim_list_tabpages()[2], api.nvim_win_get_tabpage(api.nvim_list_wins()[2]))
eq(api.nvim_list_tabpages()[2], api.nvim_win_get_tabpage(api.nvim_list_wins()[3]))
end)
end)
@@ -1693,8 +1693,8 @@ describe('API/win', function()
row = 1,
col = 1,
})
eq(api.nvim_win_get_tabpage(win), first_tab)
eq(api.nvim_get_current_tabpage(), new_tab)
eq(first_tab, api.nvim_win_get_tabpage(win))
eq(new_tab, api.nvim_get_current_tabpage())
end)
it('switches to new windows in non-current tabpages when enter=true', function()
@@ -1709,8 +1709,8 @@ describe('API/win', function()
row = 1,
col = 1,
})
eq(api.nvim_win_get_tabpage(win), first_tab)
eq(api.nvim_get_current_tabpage(), first_tab)
eq(first_tab, api.nvim_win_get_tabpage(win))
eq(first_tab, api.nvim_get_current_tabpage())
end)
local function setup_tabbed_autocmd_test()

View File

@@ -626,7 +626,7 @@ describe('menu_get', function()
},
}
eq(m, expected)
eq(expected, m)
end)
it('works with right-aligned text and spaces', function()
@@ -707,6 +707,6 @@ describe('menu_get', function()
},
}
eq(m, expected)
eq(expected, m)
end)
end)

View File

@@ -65,19 +65,19 @@ describe('commenting', function()
it('works', function()
toggle_lines(3, 5)
eq(get_lines(2, 5), { ' # aa', ' #', ' # aa' })
eq({ ' # aa', ' #', ' # aa' }, get_lines(2, 5))
toggle_lines(3, 5)
eq(get_lines(2, 5), { ' aa', '', ' aa' })
eq({ ' aa', '', ' aa' }, get_lines(2, 5))
end)
it("works with different 'commentstring' options", function()
local validate = function(lines_before, lines_after, lines_again)
set_lines(lines_before)
toggle_lines(1, #lines_before)
eq(get_lines(), lines_after)
eq(lines_after, get_lines())
toggle_lines(1, #lines_before)
eq(get_lines(), lines_again or lines_before)
eq(lines_again or lines_before, get_lines())
end
-- Single whitespace inside comment parts (main case)
@@ -259,7 +259,7 @@ describe('commenting', function()
local validate = function(line, ref_output)
set_lines(lines)
toggle_lines(line, line)
eq(get_lines(line - 1, line)[1], ref_output)
eq(ref_output, get_lines(line - 1, line)[1])
end
validate(1, '"set background=dark')
@@ -274,21 +274,21 @@ describe('commenting', function()
set_lines(lines)
toggle_lines(1, 3)
local out_lines = get_lines()
eq(out_lines[1], '"set background=dark')
eq(out_lines[2], '"lua << EOF')
eq(out_lines[3], '"print(1)')
eq('"set background=dark', out_lines[1])
eq('"lua << EOF', out_lines[2])
eq('"print(1)', out_lines[3])
end)
it('correctly computes indent', function()
toggle_lines(2, 4)
eq(get_lines(1, 4), { ' # aa', ' # aa', ' #' })
eq({ ' # aa', ' # aa', ' #' }, get_lines(1, 4))
end)
it('correctly detects comment/uncomment', function()
local validate = function(from, to, ref_lines)
set_lines({ '', 'aa', '# aa', '# aa', 'aa', '' })
toggle_lines(from, to)
eq(get_lines(), ref_lines)
eq(ref_lines, get_lines())
end
-- It should uncomment only if all non-blank lines are comments
@@ -300,14 +300,14 @@ describe('commenting', function()
-- Blank lines should be ignored when making a decision
set_lines({ '# aa', '', ' ', '\t', '# aa' })
toggle_lines(1, 5)
eq(get_lines(), { 'aa', '', ' ', '\t', 'aa' })
eq({ 'aa', '', ' ', '\t', 'aa' }, get_lines())
end)
it('correctly matches comment parts during checking and uncommenting', function()
local validate = function(from, to, ref_lines)
set_lines({ '/*aa*/', '/* aa */', '/* aa */' })
toggle_lines(from, to)
eq(get_lines(), ref_lines)
eq(ref_lines, get_lines())
end
-- Should first try to match 'commentstring' parts exactly with their
@@ -336,7 +336,7 @@ describe('commenting', function()
it('uncomments on inconsistent indent levels', function()
set_lines({ '# aa', ' # aa', ' # aa' })
toggle_lines(1, 3)
eq(get_lines(), { 'aa', ' aa', ' aa' })
eq({ 'aa', ' aa', ' aa' }, get_lines())
end)
it('respects tabs', function()
@@ -344,10 +344,10 @@ describe('commenting', function()
set_lines({ '\t\taa', '\t\taa' })
toggle_lines(1, 2)
eq(get_lines(), { '\t\t# aa', '\t\t# aa' })
eq({ '\t\t# aa', '\t\t# aa' }, get_lines())
toggle_lines(1, 2)
eq(get_lines(), { '\t\taa', '\t\taa' })
eq({ '\t\taa', '\t\taa' }, get_lines())
end)
it('works with trailing whitespace', function()
@@ -355,23 +355,23 @@ describe('commenting', function()
set_commentstring('# %s')
set_lines({ ' aa', ' aa ', ' ' })
toggle_lines(1, 3)
eq(get_lines(), { ' # aa', ' # aa ', ' #' })
eq({ ' # aa', ' # aa ', ' #' }, get_lines())
toggle_lines(1, 3)
eq(get_lines(), { ' aa', ' aa ', '' })
eq({ ' aa', ' aa ', '' }, get_lines())
-- With right-hand side
set_commentstring('%s #')
set_lines({ ' aa', ' aa ', ' ' })
toggle_lines(1, 3)
eq(get_lines(), { ' aa #', ' aa #', ' #' })
eq({ ' aa #', ' aa #', ' #' }, get_lines())
toggle_lines(1, 3)
eq(get_lines(), { ' aa', ' aa ', '' })
eq({ ' aa', ' aa ', '' }, get_lines())
-- Trailing whitespace after right side should be preserved for non-blanks
set_commentstring('%s #')
set_lines({ ' aa # ', ' aa #\t', ' # ', ' #\t' })
toggle_lines(1, 4)
eq(get_lines(), { ' aa ', ' aa\t', '', '' })
eq({ ' aa ', ' aa\t', '', '' }, get_lines())
end)
end)
@@ -379,15 +379,15 @@ describe('commenting', function()
it('works in Normal mode', function()
set_cursor(2, 2)
feed('gc', 'ap')
eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' })
eq({ '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }, get_lines())
-- Cursor moves to start line
eq(get_cursor(), { 1, 0 })
eq({ 1, 0 }, get_cursor())
-- Supports `v:count`
set_lines(example_lines)
set_cursor(2, 0)
feed('2gc', 'ap')
eq(get_lines(), { '# aa', '# aa', '# aa', '#', '# aa', '# aa', '# aa' })
eq({ '# aa', '# aa', '# aa', '#', '# aa', '# aa', '# aa' }, get_lines())
end)
it('allows dot-repeat in Normal mode', function()
@@ -397,7 +397,7 @@ describe('commenting', function()
set_cursor(2, 2)
feed('gc', 'ap')
feed('.')
eq(get_lines(), doubly_commented)
eq(doubly_commented, get_lines())
-- Not immediate dot-repeat
set_lines(example_lines)
@@ -405,16 +405,16 @@ describe('commenting', function()
feed('gc', 'ap')
set_cursor(7, 0)
feed('.')
eq(get_lines(), doubly_commented)
eq(doubly_commented, get_lines())
end)
it('works in Visual mode', function()
set_cursor(2, 2)
feed('v', 'ap', 'gc')
eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' })
eq({ '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }, get_lines())
-- Cursor moves to start line
eq(get_cursor(), { 1, 0 })
eq({ 1, 0 }, get_cursor())
end)
it('allows dot-repeat after initial Visual mode', function()
@@ -423,32 +423,32 @@ describe('commenting', function()
set_lines(example_lines)
set_cursor(2, 2)
feed('vip', 'gc')
eq(get_lines(), { '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' })
eq(get_cursor(), { 1, 0 })
eq({ '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }, get_lines())
eq({ 1, 0 }, get_cursor())
-- Dot-repeat after first application in Visual mode applies to the paragraph at cursor (not
-- a fixed-size region).
feed('.')
eq(get_lines(), example_lines)
eq(example_lines, get_lines())
set_cursor(3, 0)
feed('.')
eq(get_lines(), { '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' })
eq({ '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }, get_lines())
end)
it("respects 'commentstring'", function()
set_commentstring('/*%s*/')
set_cursor(2, 2)
feed('gc', 'ap')
eq(get_lines(), { '/*aa*/', '/* aa*/', '/* aa*/', '/**/', ' aa', ' aa', 'aa' })
eq({ '/*aa*/', '/* aa*/', '/* aa*/', '/**/', ' aa', ' aa', 'aa' }, get_lines())
end)
it("works with empty 'commentstring'", function()
set_commentstring('')
set_cursor(2, 2)
feed('gc', 'ap')
eq(get_lines(), example_lines)
eq(exec_capture('1messages'), [[Option 'commentstring' is empty.]])
eq(example_lines, get_lines())
eq([[Option 'commentstring' is empty.]], exec_capture('1messages'))
end)
it('respects tree-sitter injections', function()
@@ -469,7 +469,7 @@ describe('commenting', function()
set_lines(lines)
set_cursor(line, 0)
feed('gc_')
eq(get_lines(line - 1, line)[1], ref_output)
eq(ref_output, get_lines(line - 1, line)[1])
end
validate(1, '"set background=dark')
@@ -485,11 +485,11 @@ describe('commenting', function()
set_cursor(1, 0)
feed('gc_')
eq(get_lines()[1], '"set background=dark')
eq('"set background=dark', get_lines()[1])
set_cursor(3, 0)
feed('.')
eq(get_lines()[3], '-- print(1)')
eq('-- print(1)', get_lines()[3])
-- Multiline comments should be computed based on cursor position
-- which in case of Visual selection means its left part
@@ -497,9 +497,9 @@ describe('commenting', function()
set_cursor(1, 0)
feed('v2j', 'gc')
local out_lines = get_lines()
eq(out_lines[1], '"set background=dark')
eq(out_lines[2], '"lua << EOF')
eq(out_lines[3], '"print(1)')
eq('"set background=dark', out_lines[1])
eq('"lua << EOF', out_lines[2])
eq('"print(1)', out_lines[3])
end)
it("recomputes local 'commentstring' based on cursor position", function()
@@ -514,12 +514,12 @@ describe('commenting', function()
set_cursor(1, 1)
feed('gc_')
eq(get_lines()[1], ' "print(1)')
eq(' "print(1)', get_lines()[1])
set_lines(lines)
set_cursor(3, 2)
feed('.')
eq(get_lines()[3], ' -- print(1)')
eq(' -- print(1)', get_lines()[3])
end)
it('preserves marks', function()
@@ -527,8 +527,8 @@ describe('commenting', function()
-- Set '`<' and '`>' marks
feed('VV')
feed('gc', 'ip')
eq(api.nvim_buf_get_mark(0, '<'), { 2, 0 })
eq(api.nvim_buf_get_mark(0, '>'), { 2, 2147483647 })
eq({ 2, 0 }, api.nvim_buf_get_mark(0, '<'))
eq({ 2, 2147483647 }, api.nvim_buf_get_mark(0, '>'))
end)
end)
@@ -537,19 +537,19 @@ describe('commenting', function()
set_lines(example_lines)
set_cursor(1, 1)
feed('gcc')
eq(get_lines(0, 2), { '# aa', ' aa' })
eq({ '# aa', ' aa' }, get_lines(0, 2))
-- Does not comment empty line
set_lines(example_lines)
set_cursor(4, 0)
feed('gcc')
eq(get_lines(2, 5), { ' aa', '', ' aa' })
eq({ ' aa', '', ' aa' }, get_lines(2, 5))
-- Supports `v:count`
set_lines(example_lines)
set_cursor(2, 0)
feed('2gcc')
eq(get_lines(0, 3), { 'aa', ' # aa', ' # aa' })
eq({ 'aa', ' # aa', ' # aa' }, get_lines(0, 3))
end)
it('allows dot-repeat', function()
@@ -557,7 +557,7 @@ describe('commenting', function()
set_cursor(1, 1)
feed('gcc')
feed('.')
eq(get_lines(), example_lines)
eq(example_lines, get_lines())
-- Not immediate dot-repeat
set_lines(example_lines)
@@ -565,7 +565,7 @@ describe('commenting', function()
feed('gcc')
set_cursor(7, 0)
feed('.')
eq(get_lines(6, 7), { '# aa' })
eq({ '# aa' }, get_lines(6, 7))
end)
it('respects tree-sitter injections', function()
@@ -581,12 +581,12 @@ describe('commenting', function()
set_cursor(1, 0)
feed('gcc')
eq(get_lines(), { '"set background=dark', 'lua << EOF', 'print(1)', 'EOF' })
eq({ '"set background=dark', 'lua << EOF', 'print(1)', 'EOF' }, get_lines())
-- Should work with dot-repeat
set_cursor(3, 0)
feed('.')
eq(get_lines(), { '"set background=dark', 'lua << EOF', '-- print(1)', 'EOF' })
eq({ '"set background=dark', 'lua << EOF', '-- print(1)', 'EOF' }, get_lines())
end)
it('respects tree-sitter commentstring metadata', function()
@@ -762,7 +762,7 @@ describe('commenting', function()
set_lines({ 'aa', '# aa', '# aa', 'aa' })
set_cursor(2, 0)
feed('d', 'gc')
eq(get_lines(), { 'aa', 'aa' })
eq({ 'aa', 'aa' }, get_lines())
end)
it('allows dot-repeat', function()
@@ -771,20 +771,20 @@ describe('commenting', function()
feed('d', 'gc')
set_cursor(3, 0)
feed('.')
eq(get_lines(), { 'aa', 'aa' })
eq({ 'aa', 'aa' }, get_lines())
end)
it('does nothing when not inside textobject', function()
-- Builtin operators
feed('d', 'gc')
eq(get_lines(), example_lines)
eq(example_lines, get_lines())
-- Comment operator
local validate_no_action = function(line, col)
set_lines(example_lines)
set_cursor(line, col)
feed('gc', 'gc')
eq(get_lines(), example_lines)
eq(example_lines, get_lines())
end
validate_no_action(1, 1)
@@ -809,12 +809,12 @@ describe('commenting', function()
set_cursor(1, 0)
feed('dgc')
eq(get_lines(), { 'lua << EOF', '-- print(1)', '-- print(2)', 'EOF' })
eq({ 'lua << EOF', '-- print(1)', '-- print(2)', 'EOF' }, get_lines())
-- Should work with dot-repeat
set_cursor(2, 0)
feed('.')
eq(get_lines(), { 'lua << EOF', 'EOF' })
eq({ 'lua << EOF', 'EOF' }, get_lines())
end)
end)
end)

View File

@@ -1019,14 +1019,14 @@ describe('vim.fs', function()
-- File
vim.uv.fs_symlink('Xtest_fs-rm/file-to-link', 'Xtest_fs-rm/file-as-link')
vim.fs.rm('Xtest_fs-rm/file-as-link')
eq(vim.uv.fs_stat('Xtest_fs-rm/file-as-link'), nil)
eq(nil, vim.uv.fs_stat('Xtest_fs-rm/file-as-link'))
eq({ 'File to link' }, fn.readfile('Xtest_fs-rm/file-to-link'))
-- Directory
local function assert_rm_symlinked_dir(opts)
vim.uv.fs_symlink('Xtest_fs-rm/dir-to-link', 'Xtest_fs-rm/dir-as-link')
vim.fs.rm('Xtest_fs-rm/dir-as-link', opts)
eq(vim.uv.fs_stat('Xtest_fs-rm/dir-as-link'), nil)
eq(nil, vim.uv.fs_stat('Xtest_fs-rm/dir-as-link'))
eq({ 'File in dir to link' }, fn.readfile('Xtest_fs-rm/dir-to-link/file'))
end

View File

@@ -53,7 +53,7 @@ describe('vim.range', function()
return vim.range(vim.pos(buf1, 3, 5), vim.pos(buf2, 4, 6))
end)
end)
eq(success, false)
eq(false, success)
end)
it('is modifiable', function()

View File

@@ -203,7 +203,7 @@ describe('vim.ui', function()
})
n.api.nvim_set_option_value('filetype', 'help', { buf = buf, scope = 'local' })
local tags = n.api.nvim_buf_get_extmarks(buf, link_ns, 0, -1, {})
eq(#tags, 0)
eq(0, #tags)
end)
end)
end)

View File

@@ -91,8 +91,8 @@ describe('version', function()
end)
it('tostring() ' .. input, function()
eq(type(tostring(range)), 'string')
eq(vim.version.range(tostring(range)), range)
eq('string', type(tostring(range)))
eq(range, vim.version.range(tostring(range)))
end)
it('[from] in range ' .. input, function()
@@ -150,11 +150,11 @@ describe('version', function()
assert(vim.version.range('>1.2.3-0'):has('1.2.3-1'))
local range_alpha = vim.version.range('1.2.3-alpha')
eq(vim.version.range(tostring(range_alpha)), range_alpha)
eq(range_alpha, vim.version.range(tostring(range_alpha)))
end)
it('returns nil with empty version', function()
eq(vim.version.parse(''), nil)
eq(nil, vim.version.parse(''))
end)
end)
@@ -163,12 +163,12 @@ describe('version', function()
local r1 = vim.version.range(input[1])
local r2 = vim.version.range(input[2])
if output == nil then
eq(vim.version.intersect(r1, r2), nil)
eq(vim.version.intersect(r2, r1), nil)
eq(nil, vim.version.intersect(r1, r2))
eq(nil, vim.version.intersect(r2, r1))
else
local ref = vim.version.range(output)
eq(vim.version.intersect(r1, r2), ref)
eq(vim.version.intersect(r2, r1), ref)
eq(ref, vim.version.intersect(r1, r2))
eq(ref, vim.version.intersect(r2, r1))
end
end
@@ -457,8 +457,8 @@ describe('version', function()
assert(v('v1.2.3') >= v('1.2.2'))
assert(v('v1.2.3') > v('1.2.2'))
assert(v('v1.2.3') > v('1.0.3'))
eq(vim.version.last({ v('1.2.3'), v('2.0.0') }), v('2.0.0'))
eq(vim.version.last({ v('2.0.0'), v('1.2.3') }), v('2.0.0'))
eq(v('2.0.0'), vim.version.last({ v('1.2.3'), v('2.0.0') }))
eq(v('2.0.0'), vim.version.last({ v('2.0.0'), v('1.2.3') }))
end)
it('le()', function()

View File

@@ -1392,7 +1392,7 @@ describe('lua stdlib', function()
it('vim.fn `func_lua` (fast path for Lua-implemented builtins)', function()
-- hostname() is implemented via func_lua, calling Lua directly when invoked from Lua.
local lua_result = exec_lua([[return vim.fn.hostname()]])
eq(type(lua_result), 'string')
eq('string', type(lua_result))
assert(#lua_result > 0, 'hostname() should return a non-empty string')
-- VimScript path (lua_wrapper) should return the same result.
eq(lua_result, eval('hostname()'))

View File

@@ -724,8 +724,8 @@ describe('vim._with', function()
command('wincmd s | wincmd 5+')
win_id_3 = api.nvim_get_current_win()
eq(is_approx_eq('width', win_id_1, win_id_2), false)
eq(is_approx_eq('height', win_id_3, win_id_2), false)
eq(false, is_approx_eq('width', win_id_1, win_id_2))
eq(false, is_approx_eq('height', win_id_3, win_id_2))
end)
pending('works', function()
@@ -735,8 +735,8 @@ describe('vim._with', function()
vim.cmd.wincmd('=')
end)
]]
eq(is_approx_eq('width', win_id_1, win_id_2), true)
eq(is_approx_eq('height', win_id_3, win_id_2), false)
eq(true, is_approx_eq('width', win_id_1, win_id_2))
eq(false, is_approx_eq('height', win_id_3, win_id_2))
end)
pending('can be nested', function()
@@ -748,8 +748,8 @@ describe('vim._with', function()
end)
end)
]]
eq(is_approx_eq('width', win_id_1, win_id_2), true)
eq(is_approx_eq('height', win_id_3, win_id_2), true)
eq(true, is_approx_eq('width', win_id_1, win_id_2))
eq(true, is_approx_eq('height', win_id_3, win_id_2))
end)
end)

View File

@@ -509,8 +509,8 @@ describe('vim.lsp.diagnostic', function()
end)
-- This test case must be run over a multiline diagnostic in which the start line is shorter
-- than the end line, and the end_col exceeds the start line's length.
eq(#lines[1], 8)
eq(#lines[2], 16)
eq(8, #lines[1])
eq(16, #lines[2])
eq(1, #diags)
eq(6, diags[1].col)
eq(10, diags[1].end_col)

View File

@@ -393,12 +393,12 @@ local function assert_progress_report(echo_log, action, step_names)
steps_seen[step] = true
-- Should not add intermediate progress report to history
eq(echo_args[2], false)
eq(false, echo_args[2])
-- Should update a single message by its id (computed after first call)
progress.id = progress.id or echo_args[3].id ---@type integer
progress.percent = math.floor(100 * i / n_steps)
eq(echo_args[3], progress)
eq(progress, echo_args[3])
end
-- Should report all steps
@@ -499,7 +499,7 @@ describe('vim.pack', function()
watch_events({ 'PackChanged' })
vim_pack_add({ repos_src.basic })
eq(exec_lua('return #_G.event_log'), 0)
eq(0, exec_lua('return #_G.event_log'))
-- Should not create redundant stash entry
local basic_path = pack_get_plug_path('basic')
@@ -1338,13 +1338,13 @@ describe('vim.pack', function()
-- Buffer should be special and shown in a separate tabpage
eq(2, #api.nvim_list_tabpages())
eq(2, fn.tabpagenr())
eq(api.nvim_get_option_value('filetype', {}), 'nvim-pack')
eq(api.nvim_get_option_value('modifiable', {}), false)
eq(api.nvim_get_option_value('buftype', {}), 'acwrite')
eq('nvim-pack', api.nvim_get_option_value('filetype', {}))
eq(false, api.nvim_get_option_value('modifiable', {}))
eq('acwrite', api.nvim_get_option_value('buftype', {}))
local confirm_bufnr = api.nvim_get_current_buf()
local confirm_winnr = api.nvim_get_current_win()
local confirm_tabpage = api.nvim_get_current_tabpage()
eq(api.nvim_buf_get_name(0), 'nvim-pack://confirm#' .. confirm_bufnr)
eq('nvim-pack://confirm#' .. confirm_bufnr, api.nvim_buf_get_name(0))
-- Adjust lines for a more robust screenshot testing
local fetch_src = repos_src.fetch
@@ -1826,7 +1826,7 @@ describe('vim.pack', function()
-- - Can still respect `:write` after action
n.exec('write')
eq('vim.pack: Nothing to update', n.exec_capture('1messages'))
eq(api.nvim_get_option_value('filetype', {}), '')
eq('', api.nvim_get_option_value('filetype', {}))
end)
it('has buffer-local mappings', function()

View File

@@ -28,7 +28,7 @@ describe(':terminal', function()
api.nvim_chan_send(chan, input)
--- @type string
local term_title = api.nvim_buf_get_var(0, 'term_title')
t.eq(term_title, 'This title set with OSC 2')
t.eq('This title set with OSC 2', term_title)
assert_alive()
end)
@@ -40,7 +40,7 @@ describe(':terminal', function()
api.nvim_chan_send(chan, input)
--- @type string
local term_title = api.nvim_buf_get_var(0, 'term_title')
t.eq(term_title, 'This title set with OSC 0')
t.eq('This title set with OSC 0', term_title)
assert_alive()
end)

View File

@@ -180,7 +180,7 @@ describe('cmdline2', function()
{1:~ }|*12
{16::}{15:find} ^ |
]])
t.eq(n.eval('v:errmsg'), "E1514: 'findfunc' did not return a List type")
t.eq("E1514: 'findfunc' did not return a List type", n.eval('v:errmsg'))
end)
it('substitution match, empty message does not clear active cmdline', function()

View File

@@ -1427,7 +1427,7 @@ stack traceback:
^ |
{1:~ }|*4
]])
eq(showmode, 0)
eq(0, showmode)
feed('i')
screen:expect({
grid = [[
@@ -1436,17 +1436,17 @@ stack traceback:
]],
showmode = { { '-- INSERT --', 5, 'ModeMsg' } },
})
eq(showmode, 2)
eq(2, showmode)
command('set noshowmode')
feed('<Esc>')
screen:expect([[
^ |
{1:~ }|*4
]])
eq(showmode, 3)
eq(3, showmode)
feed('i')
screen:expect_unchanged()
eq(showmode, 3)
eq(3, showmode)
end)
it('emits single message for multiline print())', function()

View File

@@ -398,8 +398,8 @@ describe('Scrollbind', function()
n.feed('<C-y>')
n.feed('<C-y>')
t.eq(n.exec_lua [[return vim.fn.line('w0', 1001)]], 6)
t.eq(n.exec_lua [[return vim.fn.line('w0', 1000)]], 3)
t.eq(6, n.exec_lua [[return vim.fn.line('w0', 1001)]])
t.eq(3, n.exec_lua [[return vim.fn.line('w0', 1000)]])
screen:expect({
grid = [[

View File

@@ -312,9 +312,9 @@ describe('mbyte', function()
pos = pos + clen
table.insert(breaks, pos)
end
eq(breaks[#breaks], len) -- include EOT as break
eq(len, breaks[#breaks]) -- include EOT as break
-- we could also send in breaks, but this is more human readable
eq(mb_glyphs, expected_glyphs)
eq(expected_glyphs, mb_glyphs)
for i = 1, #breaks - 1 do
local start, next = breaks[i], breaks[i + 1]

View File

@@ -508,7 +508,7 @@ describe('fs.c', function()
for _, _ in pairs(tbl) do
i = i + 1
end
eq(i, 6) -- All fds must be unique
eq(6, i) -- All fds must be unique
end)
end)

File diff suppressed because it is too large Load Diff

View File

@@ -70,7 +70,7 @@ describe('u_write_undo', function()
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
local undo_file = io.open(correct_name, 'r')
neq(undo_file, nil)
neq(nil, undo_file)
local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
print(err) -- inform tester if undofile fails to delete
@@ -82,7 +82,7 @@ describe('u_write_undo', function()
u_write_undo(correct_name, false, file_buffer, buffer_hash)
local undo_file = io.open(correct_name, 'r')
neq(undo_file, nil)
neq(nil, undo_file)
local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
print(err) -- inform tester if undofile fails to delete
@@ -206,6 +206,6 @@ describe('u_write_undo', function()
u_write_undo(nil, false, file_buffer, buffer_hash)
local undo_file = io.open(correct_name, 'r')
eq(undo_file, nil)
eq(nil, undo_file)
end)
end)

View File

@@ -315,9 +315,9 @@ local function lineinfo(row, expected, state)
local dhl = info.doubleheight == 1
local cont = info.continuation == 1
t.eq(dwl, expected.dwl or false)
t.eq(dhl, expected.dhl or false)
t.eq(cont, expected.cont or false)
t.eq(expected.dwl or false, dwl)
t.eq(expected.dhl or false, dhl)
t.eq(expected.cont or false, cont)
end
local function pen(attribute, expected, state)