test: correct order of arguments to eq() (#27816)

This commit is contained in:
zeertzjq
2024-03-11 22:23:14 +08:00
committed by GitHub
parent 0f20b7d803
commit 1da0f3494e
22 changed files with 85 additions and 85 deletions

View File

@@ -707,13 +707,13 @@ describe('API', function()
it('works', function() it('works', function()
api.nvim_set_current_dir('Xtestdir') api.nvim_set_current_dir('Xtestdir')
eq(fn.getcwd(), start_dir .. helpers.get_pathsep() .. 'Xtestdir') eq(start_dir .. helpers.get_pathsep() .. 'Xtestdir', fn.getcwd())
end) end)
it('sets previous directory', function() it('sets previous directory', function()
api.nvim_set_current_dir('Xtestdir') api.nvim_set_current_dir('Xtestdir')
command('cd -') command('cd -')
eq(fn.getcwd(), start_dir) eq(start_dir, fn.getcwd())
end) end)
end) end)

View File

@@ -72,19 +72,19 @@ describe('TextYankPost', function()
command('set debug=msg') command('set debug=msg')
-- the regcontents should not be changed without copy. -- the regcontents should not be changed without copy.
local status, err = pcall(command, 'call extend(g:event.regcontents, ["more text"])') local status, err = pcall(command, 'call extend(g:event.regcontents, ["more text"])')
eq(status, false) eq(false, status)
neq(nil, string.find(err, ':E742:')) neq(nil, string.find(err, ':E742:'))
-- can't mutate keys inside the autocommand -- can't mutate keys inside the autocommand
command('autocmd! TextYankPost * let v:event.regcontents = 0') command('autocmd! TextYankPost * let v:event.regcontents = 0')
status, err = pcall(command, 'normal yy') status, err = pcall(command, 'normal yy')
eq(status, false) eq(false, status)
neq(nil, string.find(err, ':E46:')) neq(nil, string.find(err, ':E46:'))
-- can't add keys inside the autocommand -- can't add keys inside the autocommand
command('autocmd! TextYankPost * let v:event.mykey = 0') command('autocmd! TextYankPost * let v:event.mykey = 0')
status, err = pcall(command, 'normal yy') status, err = pcall(command, 'normal yy')
eq(status, false) eq(false, status)
neq(nil, string.find(err, ':E742:')) neq(nil, string.find(err, ':E742:'))
end) end)

View File

@@ -505,7 +505,7 @@ describe('mappings with <Cmd>', function()
feed('"bd<F7>') feed('"bd<F7>')
expect([[ expect([[
soest text]]) soest text]])
eq(fn.getreg('b', 1, 1), { 'me short lines', 'of t' }) eq({ 'me short lines', 'of t' }, fn.getreg('b', 1, 1))
-- startinsert aborts operator -- startinsert aborts operator
feed('d<F8>') feed('d<F8>')
@@ -561,7 +561,7 @@ describe('mappings with <Cmd>', function()
of stuff test text]]) of stuff test text]])
feed('<F5>') feed('<F5>')
eq(fn.getreg('a', 1, 1), { 'deed some short little lines', 'of stuff t' }) eq({ 'deed some short little lines', 'of stuff t' }, fn.getreg('a', 1, 1))
-- still in insert -- still in insert
screen:expect([[ screen:expect([[

View File

@@ -59,7 +59,7 @@ local monitor_memory_usage = {
end end
table.remove(self.hist, 1) table.remove(self.hist, 1)
self.last = self.hist[#self.hist] self.last = self.hist[#self.hist]
eq(#result, 1) eq(1, #result)
end) end)
end, end,
dump = function(self) dump = function(self)

View File

@@ -312,15 +312,15 @@ describe('lua buffer event callbacks: on_lines', function()
feed('G0') feed('G0')
feed('p') feed('p')
-- Is the last arg old_byte_size correct? Doesn't matter for this PR -- Is the last arg old_byte_size correct? Doesn't matter for this PR
eq(api.nvim_get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 }) eq({ 'lines', 1, 4, 2, 3, 5, 4 }, api.nvim_get_var('linesev'))
feed('2G0') feed('2G0')
feed('p') feed('p')
eq(api.nvim_get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 }) eq({ 'lines', 1, 5, 1, 4, 4, 8 }, api.nvim_get_var('linesev'))
feed('1G0') feed('1G0')
feed('P') feed('P')
eq(api.nvim_get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 }) eq({ 'lines', 1, 6, 0, 3, 3, 9 }, api.nvim_get_var('linesev'))
end) end)
it( it(

View File

@@ -205,7 +205,7 @@ describe('vim.diagnostic', function()
diag[1].col = 10000 diag[1].col = 10000
return vim.diagnostic.get()[1].col == 10000 return vim.diagnostic.get()[1].col == 10000
]] ]]
eq(result, false) eq(false, result)
end) end)
it('resolves buffer number 0 to the current buffer', function() it('resolves buffer number 0 to the current buffer', function()

View File

@@ -166,7 +166,7 @@ describe('thread', function()
]] ]]
local msg = next_msg() local msg = next_msg()
eq(msg[1], 'notification') eq('notification', msg[1])
assert(tonumber(msg[2]) >= 72961) assert(tonumber(msg[2]) >= 72961)
end) end)
@@ -327,7 +327,7 @@ describe('threadpool', function()
]] ]]
local msg = next_msg() local msg = next_msg()
eq(msg[1], 'notification') eq('notification', msg[1])
assert(tonumber(msg[2]) >= 72961) assert(tonumber(msg[2]) >= 72961)
end) end)

View File

@@ -2016,7 +2016,7 @@ describe('lua stdlib', function()
vim.opt.scrolloff = 10 vim.opt.scrolloff = 10
return vim.o.scrolloff return vim.o.scrolloff
]] ]]
eq(scrolloff, 10) eq(10, scrolloff)
end) end)
pending('should handle STUPID window things', function() pending('should handle STUPID window things', function()
@@ -2037,7 +2037,7 @@ describe('lua stdlib', function()
vim.opt.wildignore = { 'hello', 'world' } vim.opt.wildignore = { 'hello', 'world' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'hello,world') eq('hello,world', wildignore)
end) end)
it('should allow setting tables with shortnames', function() it('should allow setting tables with shortnames', function()
@@ -2045,7 +2045,7 @@ describe('lua stdlib', function()
vim.opt.wig = { 'hello', 'world' } vim.opt.wig = { 'hello', 'world' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'hello,world') eq('hello,world', wildignore)
end) end)
it('should error when you attempt to set string values to numeric options', function() it('should error when you attempt to set string values to numeric options', function()
@@ -2451,13 +2451,13 @@ describe('lua stdlib', function()
vim.opt.wildignore = 'foo' vim.opt.wildignore = 'foo'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo') eq('foo', wildignore)
wildignore = exec_lua [[ wildignore = exec_lua [[
vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' } vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,bar,baz') eq('foo,bar,baz', wildignore)
end) end)
it('should handle adding duplicates', function() it('should handle adding duplicates', function()
@@ -2465,19 +2465,19 @@ describe('lua stdlib', function()
vim.opt.wildignore = 'foo' vim.opt.wildignore = 'foo'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo') eq('foo', wildignore)
wildignore = exec_lua [[ wildignore = exec_lua [[
vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' } vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,bar,baz') eq('foo,bar,baz', wildignore)
wildignore = exec_lua [[ wildignore = exec_lua [[
vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' } vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,bar,baz') eq('foo,bar,baz', wildignore)
end) end)
it('should allow adding multiple times', function() it('should allow adding multiple times', function()
@@ -2486,7 +2486,7 @@ describe('lua stdlib', function()
vim.opt.wildignore = vim.opt.wildignore + 'bar' + 'baz' vim.opt.wildignore = vim.opt.wildignore + 'bar' + 'baz'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,bar,baz') eq('foo,bar,baz', wildignore)
end) end)
it('should remove values when you use minus', function() it('should remove values when you use minus', function()
@@ -2494,19 +2494,19 @@ describe('lua stdlib', function()
vim.opt.wildignore = 'foo' vim.opt.wildignore = 'foo'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo') eq('foo', wildignore)
wildignore = exec_lua [[ wildignore = exec_lua [[
vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' } vim.opt.wildignore = vim.opt.wildignore + { 'bar', 'baz' }
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,bar,baz') eq('foo,bar,baz', wildignore)
wildignore = exec_lua [[ wildignore = exec_lua [[
vim.opt.wildignore = vim.opt.wildignore - 'bar' vim.opt.wildignore = vim.opt.wildignore - 'bar'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'foo,baz') eq('foo,baz', wildignore)
end) end)
it('should prepend values when using ^', function() it('should prepend values when using ^', function()
@@ -2521,7 +2521,7 @@ describe('lua stdlib', function()
vim.opt.wildignore = vim.opt.wildignore ^ 'super_first' vim.opt.wildignore = vim.opt.wildignore ^ 'super_first'
return vim.o.wildignore return vim.o.wildignore
]] ]]
eq(wildignore, 'super_first,first,foo') eq('super_first,first,foo', wildignore)
end) end)
it('should not remove duplicates from wildmode: #14708', function() it('should not remove duplicates from wildmode: #14708', function()
@@ -2530,7 +2530,7 @@ describe('lua stdlib', function()
return vim.o.wildmode return vim.o.wildmode
]] ]]
eq(wildmode, 'full,list,full') eq('full,list,full', wildmode)
end) end)
describe('option types', function() describe('option types', function()
@@ -2738,7 +2738,7 @@ describe('lua stdlib', function()
return vim.go.whichwrap return vim.go.whichwrap
]] ]]
eq(ww, 'b,s') eq('b,s', ww)
eq( eq(
'b,s,<,>,[,]', 'b,s,<,>,[,]',
exec_lua [[ exec_lua [[

View File

@@ -1243,11 +1243,11 @@ describe('autocommands', function()
command('au BufEnter * let g:n = g:n + 1') command('au BufEnter * let g:n = g:n + 1')
command('terminal') command('terminal')
eq(eval('get(g:, "n", 0)'), 1) eq(1, eval('get(g:, "n", 0)'))
helpers.retry(nil, 1000, function() helpers.retry(nil, 1000, function()
neq(api.nvim_get_option_value('buftype', { buf = 0 }), 'terminal') neq('terminal', api.nvim_get_option_value('buftype', { buf = 0 }))
eq(eval('get(g:, "n", 0)'), 2) eq(2, eval('get(g:, "n", 0)'))
end) end)
end) end)
end) end)

View File

@@ -12,7 +12,7 @@ local function should_fail(opt, value, errmsg)
eq(errmsg, eval('v:errmsg'):match('E%d*')) eq(errmsg, eval('v:errmsg'):match('E%d*'))
feed_command('let v:errmsg = ""') feed_command('let v:errmsg = ""')
local status, err = pcall(api.nvim_set_option_value, opt, value, {}) local status, err = pcall(api.nvim_set_option_value, opt, value, {})
eq(status, false) eq(false, status)
eq(errmsg, err:match('E%d*')) eq(errmsg, err:match('E%d*'))
eq('', eval('v:errmsg')) eq('', eval('v:errmsg'))
end end

View File

@@ -257,7 +257,7 @@ describe('vim.lsp.diagnostic', function()
}, {client_id=client_id}) }, {client_id=client_id})
return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2")) return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2"))
]] ]]
eq(bufnr, -1) eq(-1, bufnr)
-- Create buffer on diagnostics -- Create buffer on diagnostics
bufnr = exec_lua [[ bufnr = exec_lua [[
@@ -269,8 +269,8 @@ describe('vim.lsp.diagnostic', function()
}, {client_id=client_id}) }, {client_id=client_id})
return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2")) return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2"))
]] ]]
neq(bufnr, -1) neq(-1, bufnr)
eq(exec_lua([[return #vim.diagnostic.get(...)]], bufnr), 1) eq(1, exec_lua([[return #vim.diagnostic.get(...)]], bufnr))
-- Clear diagnostics after buffer was created -- Clear diagnostics after buffer was created
bufnr = exec_lua [[ bufnr = exec_lua [[
@@ -280,8 +280,8 @@ describe('vim.lsp.diagnostic', function()
}, {client_id=client_id}) }, {client_id=client_id})
return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2")) return vim.fn.bufnr(vim.uri_to_fname("file:///fake/uri2"))
]] ]]
neq(bufnr, -1) neq(-1, bufnr)
eq(exec_lua([[return #vim.diagnostic.get(...)]], bufnr), 0) eq(0, exec_lua([[return #vim.diagnostic.get(...)]], bufnr))
end) end)
end) end)

View File

@@ -169,12 +169,12 @@ describe('vim.lsp.inlay_hint', function()
--- @type vim.lsp.inlay_hint.get.ret --- @type vim.lsp.inlay_hint.get.ret
local res = exec_lua([[return vim.lsp.inlay_hint.get()]]) local res = exec_lua([[return vim.lsp.inlay_hint.get()]])
eq(res, { eq({
{ bufnr = 1, client_id = 1, inlay_hint = expected[1] }, { bufnr = 1, client_id = 1, inlay_hint = expected[1] },
{ bufnr = 1, client_id = 1, inlay_hint = expected[2] }, { bufnr = 1, client_id = 1, inlay_hint = expected[2] },
{ bufnr = 1, client_id = 1, inlay_hint = expected[3] }, { bufnr = 1, client_id = 1, inlay_hint = expected[3] },
{ bufnr = 1, client_id = 2, inlay_hint = expected2 }, { bufnr = 1, client_id = 2, inlay_hint = expected2 },
}) }, res)
--- @type vim.lsp.inlay_hint.get.ret --- @type vim.lsp.inlay_hint.get.ret
res = exec_lua([[return vim.lsp.inlay_hint.get({ res = exec_lua([[return vim.lsp.inlay_hint.get({
@@ -183,9 +183,9 @@ describe('vim.lsp.inlay_hint', function()
["end"] = { line = 2, character = 10 }, ["end"] = { line = 2, character = 10 },
}, },
})]]) })]])
eq(res, { eq({
{ bufnr = 1, client_id = 2, inlay_hint = expected2 }, { bufnr = 1, client_id = 2, inlay_hint = expected2 },
}) }, res)
--- @type vim.lsp.inlay_hint.get.ret --- @type vim.lsp.inlay_hint.get.ret
res = exec_lua([[return vim.lsp.inlay_hint.get({ res = exec_lua([[return vim.lsp.inlay_hint.get({
@@ -195,16 +195,16 @@ describe('vim.lsp.inlay_hint', function()
["end"] = { line = 5, character = 17 }, ["end"] = { line = 5, character = 17 },
}, },
})]]) })]])
eq(res, { eq({
{ bufnr = 1, client_id = 1, inlay_hint = expected[2] }, { bufnr = 1, client_id = 1, inlay_hint = expected[2] },
{ bufnr = 1, client_id = 1, inlay_hint = expected[3] }, { bufnr = 1, client_id = 1, inlay_hint = expected[3] },
}) }, res)
--- @type vim.lsp.inlay_hint.get.ret --- @type vim.lsp.inlay_hint.get.ret
res = exec_lua([[return vim.lsp.inlay_hint.get({ res = exec_lua([[return vim.lsp.inlay_hint.get({
bufnr = vim.api.nvim_get_current_buf() + 1, bufnr = vim.api.nvim_get_current_buf() + 1,
})]]) })]])
eq(res, {}) eq({}, res)
end) end)
end) end)
end) end)

View File

@@ -641,11 +641,11 @@ describe('LSP', function()
vim.lsp.stop_client(client_id) vim.lsp.stop_client(client_id)
return server.messages return server.messages
]]) ]])
eq(#messages, 4) eq(4, #messages)
eq(messages[1].method, 'initialize') eq('initialize', messages[1].method)
eq(messages[2].method, 'initialized') eq('initialized', messages[2].method)
eq(messages[3].method, 'shutdown') eq('shutdown', messages[3].method)
eq(messages[4].method, 'exit') eq('exit', messages[4].method)
end) end)
it('BufWritePre sends willSave / willSaveWaitUntil, applies textEdits', function() it('BufWritePre sends willSave / willSaveWaitUntil, applies textEdits', function()
@@ -4221,7 +4221,7 @@ describe('LSP', function()
server:shutdown() server:shutdown()
return vim.json.decode(init) return vim.json.decode(init)
]] ]]
eq(result.method, 'initialize') eq('initialize', result.method)
end) end)
it('can connect to lsp server via rpc.domain_socket_connect', function() it('can connect to lsp server via rpc.domain_socket_connect', function()
local tmpfile local tmpfile
@@ -4257,7 +4257,7 @@ describe('LSP', function()
]], ]],
tmpfile tmpfile
) )
eq(result.method, 'initialize') eq('initialize', result.method)
end) end)
end) end)

View File

@@ -1003,7 +1003,7 @@ describe('ShaDa jumps support code', function()
eq(jumps[found].line, v.value.l) eq(jumps[found].line, v.value.l)
end end
end end
eq(found, #jumps) eq(#jumps, found)
end) end)
it('merges JUMPLISTSIZE jumps when writing', function() it('merges JUMPLISTSIZE jumps when writing', function()
@@ -1041,7 +1041,7 @@ describe('ShaDa jumps support code', function()
eq(jumps[found].line, v.value.l) eq(jumps[found].line, v.value.l)
end end
end end
eq(found, 100) eq(100, found)
end) end)
end) end)
@@ -1132,7 +1132,7 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l or 1) eq(changes[found].line, v.value.l or 1)
end end
end end
eq(found, #changes) eq(#changes, found)
end) end)
it('merges JUMPLISTSIZE changes when writing', function() it('merges JUMPLISTSIZE changes when writing', function()
@@ -1170,7 +1170,7 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l) eq(changes[found].line, v.value.l)
end end
end end
eq(found, 100) eq(100, found)
end) end)
it('merges JUMPLISTSIZE changes when writing, with new items between old', function() it('merges JUMPLISTSIZE changes when writing, with new items between old', function()
@@ -1213,6 +1213,6 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l) eq(changes[found].line, v.value.l)
end end
end end
eq(found, 100) eq(100, found)
end) end)
end) end)

View File

@@ -828,7 +828,7 @@ end]]
return parser:included_regions() return parser:included_regions()
]] ]]
eq(range_tbl, { { { 0, 0, 0, 17, 1, 508 } } }) eq({ { { 0, 0, 0, 17, 1, 508 } } }, range_tbl)
end) end)
it('allows to set complex ranges', function() it('allows to set complex ranges', function()
@@ -1111,7 +1111,7 @@ int x = INT_MAX;
return sub_tree == parser:children().c return sub_tree == parser:children().c
]]) ]])
eq(result, true) eq(true, result)
end) end)
end) end)
@@ -1135,7 +1135,7 @@ int x = INT_MAX;
return result return result
]]) ]])
eq(result, 'value') eq('value', result)
end) end)
describe('when setting a key on a capture', function() describe('when setting a key on a capture', function()
@@ -1158,7 +1158,7 @@ int x = INT_MAX;
end end
]]) ]])
eq(result, 'value') eq('value', result)
end) end)
it('it should not overwrite the nested table', function() it('it should not overwrite the nested table', function()

View File

@@ -6257,7 +6257,7 @@ describe('float window', function()
run(on_request, nil, on_setup) run(on_request, nil, on_setup)
os.remove('Xtest_written') os.remove('Xtest_written')
os.remove('Xtest_written2') os.remove('Xtest_written2')
eq(exited, true) eq(true, exited)
end) end)
it(':quit two floats in a row', function() it(':quit two floats in a row', function()

View File

@@ -204,8 +204,8 @@ describe(":substitute, 'inccommand' preserves", function()
feed(':%s/as/glork/') feed(':%s/as/glork/')
poke_eventloop() poke_eventloop()
feed('<enter>') feed('<enter>')
eq(api.nvim_get_option_value('undolevels', { scope = 'global' }), 139) eq(139, api.nvim_get_option_value('undolevels', { scope = 'global' }))
eq(api.nvim_get_option_value('undolevels', { buf = 0 }), 34) eq(34, api.nvim_get_option_value('undolevels', { buf = 0 }))
end) end)
end end

View File

@@ -51,11 +51,11 @@ describe('msgpack', function()
unpacker_goto(unpacker, payload, payload:len() - 1) unpacker_goto(unpacker, payload, payload:len() - 1)
local finished = unpacker_advance(unpacker) local finished = unpacker_advance(unpacker)
eq(finished, false) eq(false, finished)
unpacker[0].read_size = unpacker[0].read_size + 1 unpacker[0].read_size = unpacker[0].read_size + 1
finished = unpacker_advance(unpacker) finished = unpacker_advance(unpacker)
eq(finished, true) eq(true, finished)
end end
) )
@@ -73,7 +73,7 @@ describe('msgpack', function()
'\x93\x02\xa6\x72\x65\x64\x72\x61\x77\x91\x92\xa9\x67\x72\x69\x64\x5f\x6c\x69\x6e\x65\x95\x02\x00\x00\x90\xc2' '\x93\x02\xa6\x72\x65\x64\x72\x61\x77\x91\x92\xa9\x67\x72\x69\x64\x5f\x6c\x69\x6e\x65\x95\x02\x00\x00\x90\xc2'
) )
local finished = unpacker_advance(unpacker) local finished = unpacker_advance(unpacker)
eq(finished, true) eq(true, finished)
end) end)
end) end)
end) end)

View File

@@ -306,9 +306,9 @@ describe('env.c', function()
-- expand_env_esc SHOULD NOT expand the variable if there is not enough space to -- expand_env_esc SHOULD NOT expand the variable if there is not enough space to
-- contain the result -- contain the result
for i = 0, 3 do for i = 0, 3 do
eq(output[i], input[i]) eq(input[i], output[i])
end end
eq(output[4], 0) eq(0, output[4])
end) end)
end) end)
end) end)

View File

@@ -125,9 +125,9 @@ describe('shell functions', function()
cimported.p_sxe = to_cstr('"&|<>()@^') cimported.p_sxe = to_cstr('"&|<>()@^')
local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo &|<>()@^'), nil)) local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo &|<>()@^'), nil))
eq(ffi.string(argv[0]), '/bin/sh') eq('/bin/sh', ffi.string(argv[0]))
eq(ffi.string(argv[1]), '-c') eq('-c', ffi.string(argv[1]))
eq(ffi.string(argv[2]), '(echo ^&^|^<^>^(^)^@^^)') eq('(echo ^&^|^<^>^(^)^@^^)', ffi.string(argv[2]))
eq(nil, argv[3]) eq(nil, argv[3])
end) end)
@@ -136,9 +136,9 @@ describe('shell functions', function()
cimported.p_sxe = to_cstr('"&|<>()@^') cimported.p_sxe = to_cstr('"&|<>()@^')
local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil)) local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh') eq('/bin/sh', ffi.string(argv[0]))
eq(ffi.string(argv[1]), '-c') eq('-c', ffi.string(argv[1]))
eq(ffi.string(argv[2]), '"(echo -n some text)"') eq('"(echo -n some text)"', ffi.string(argv[2]))
eq(nil, argv[3]) eq(nil, argv[3])
end) end)
@@ -147,17 +147,17 @@ describe('shell functions', function()
cimported.p_sxe = to_cstr('') cimported.p_sxe = to_cstr('')
local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil)) local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh') eq('/bin/sh', ffi.string(argv[0]))
eq(ffi.string(argv[1]), '-c') eq('-c', ffi.string(argv[1]))
eq(ffi.string(argv[2]), '"echo -n some text"') eq('"echo -n some text"', ffi.string(argv[2]))
eq(nil, argv[3]) eq(nil, argv[3])
end) end)
itp('with empty shellxquote/shellxescape', function() itp('with empty shellxquote/shellxescape', function()
local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil)) local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh') eq('/bin/sh', ffi.string(argv[0]))
eq(ffi.string(argv[1]), '-c') eq('-c', ffi.string(argv[1]))
eq(ffi.string(argv[2]), 'echo -n some text') eq('echo -n some text', ffi.string(argv[2]))
eq(nil, argv[3]) eq(nil, argv[3])
end) end)
end) end)

View File

@@ -229,7 +229,7 @@ describe('profiling related functions', function()
describe('profile_msg', function() describe('profile_msg', function()
itp('prints the zero time as 0.00000', function() itp('prints the zero time as 0.00000', function()
local str = trim(profile_msg(profile_zero())) local str = trim(profile_msg(profile_zero()))
eq(str, '0.000000') eq('0.000000', str)
end) end)
itp('prints the time passed, in seconds.microsends', function() itp('prints the time passed, in seconds.microsends', function()
@@ -245,7 +245,7 @@ describe('profiling related functions', function()
-- zero seconds have passed (if this is not true, either LuaJIT is too -- zero seconds have passed (if this is not true, either LuaJIT is too
-- slow or the profiling functions are too slow and need to be fixed) -- slow or the profiling functions are too slow and need to be fixed)
eq(s, '0') eq('0', s)
-- more or less the same goes for the microsecond part, if it doesn't -- more or less the same goes for the microsecond part, if it doesn't
-- start with 0, it's too slow. -- start with 0, it's too slow.

View File

@@ -28,7 +28,7 @@ describe('tempfile related functions', function()
assert.True(dir ~= nil and dir:len() > 0) assert.True(dir ~= nil and dir:len() > 0)
-- os_file_is_writable returns 2 for a directory which we have rights -- os_file_is_writable returns 2 for a directory which we have rights
-- to write into. -- to write into.
eq(lib.os_file_is_writable(helpers.to_cstr(dir)), 2) eq(2, lib.os_file_is_writable(helpers.to_cstr(dir)))
for entry in vim.fs.dir(dir) do for entry in vim.fs.dir(dir) do
assert.True(entry == '.' or entry == '..') assert.True(entry == '.' or entry == '..')
end end
@@ -57,7 +57,7 @@ describe('tempfile related functions', function()
itp('generate file name in Nvim own temp directory', function() itp('generate file name in Nvim own temp directory', function()
local dir = vim_gettempdir() local dir = vim_gettempdir()
local file = vim_tempname() local file = vim_tempname()
eq(string.sub(file, 1, string.len(dir)), dir) eq(dir, string.sub(file, 1, string.len(dir)))
end) end)
end) end)
end) end)