aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-28 18:40:24 +0800
committerGitHub <noreply@github.com>2025-02-28 18:40:24 +0800
commit77626ed7fd369b797dcb2ad0714a84bfd9afff36 (patch)
treefce024d2f065017d40f1536fa4d948676da54a76 /test/functional
parent9b25c68db21c4a2c1edc0d9eb2cdb80cf249193a (diff)
parentb66f395ff444643852e3539b849267658e885bf4 (diff)
downloadrneovim-77626ed7fd369b797dcb2ad0714a84bfd9afff36.tar.gz
rneovim-77626ed7fd369b797dcb2ad0714a84bfd9afff36.tar.bz2
rneovim-77626ed7fd369b797dcb2ad0714a84bfd9afff36.zip
Merge pull request #28486 from zeertzjq/vim-8.2.4603
vim-patch:8.2.{4594,4603,4607,4647,4974}
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/vim_spec.lua30
-rw-r--r--test/functional/core/exit_spec.lua18
-rw-r--r--test/functional/editor/mark_spec.lua27
-rw-r--r--test/functional/ex_cmds/source_spec.lua20
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua2
-rw-r--r--test/functional/legacy/assert_spec.lua8
-rw-r--r--test/functional/lua/commands_spec.lua3
-rw-r--r--test/functional/lua/vim_spec.lua2
8 files changed, 72 insertions, 38 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3aa9ba49d5..b5fcd88f71 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -140,7 +140,7 @@ describe('API', function()
it(':verbose set {option}?', function()
api.nvim_exec2('set nowrap', { output = false })
eq(
- { output = 'nowrap\n\tLast set from anonymous :source' },
+ { output = 'nowrap\n\tLast set from anonymous :source line 1' },
api.nvim_exec2('verbose set wrap?', { output = true })
)
@@ -153,7 +153,7 @@ describe('API', function()
{ output = false }
)
eq(
- { output = 'nowrap\n\tLast set from anonymous :source (script id 1)' },
+ { output = 'nowrap\n\tLast set from anonymous :source (script id 1) line 2' },
api.nvim_exec2('verbose set wrap?', { output = true })
)
end)
@@ -296,16 +296,21 @@ describe('API', function()
eq('ñxx', api.nvim_get_current_line())
end)
+ it('can use :finish', function()
+ api.nvim_exec2('let g:var = 123\nfinish\nlet g:var = 456', {})
+ eq(123, api.nvim_get_var('var'))
+ end)
+
it('execution error', function()
eq(
- 'nvim_exec2(): Vim:E492: Not an editor command: bogus_command',
+ 'nvim_exec2(), line 1: Vim:E492: Not an editor command: bogus_command',
pcall_err(request, 'nvim_exec2', 'bogus_command', {})
)
eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
eq(
- 'nvim_exec2(): Vim(buffer):E86: Buffer 23487 does not exist',
+ 'nvim_exec2(), line 1: Vim(buffer):E86: Buffer 23487 does not exist',
pcall_err(request, 'nvim_exec2', 'buffer 23487', {})
)
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
@@ -338,17 +343,28 @@ describe('API', function()
write_file(sourcing_fname, 'call nvim_exec2("source ' .. fname .. '", {"output": v:false})\n')
api.nvim_exec2('set verbose=2', { output = false })
local traceback_output = dedent([[
- line 0: sourcing "%s"
- line 0: sourcing "%s"
+ sourcing "nvim_exec2()"
+ line 1: sourcing "nvim_exec2() called at nvim_exec2():1"
+ line 1: sourcing "%s"
+ line 1: sourcing "nvim_exec2() called at %s:1"
+ line 1: sourcing "%s"
hello
finished sourcing %s
continuing in nvim_exec2() called at %s:1
+ finished sourcing nvim_exec2() called at %s:1
+ continuing in %s
finished sourcing %s
- continuing in nvim_exec2() called at nvim_exec2():0]]):format(
+ continuing in nvim_exec2() called at nvim_exec2():1
+ finished sourcing nvim_exec2() called at nvim_exec2():1
+ continuing in nvim_exec2()
+ finished sourcing nvim_exec2()]]):format(
+ sourcing_fname,
sourcing_fname,
fname,
fname,
sourcing_fname,
+ sourcing_fname,
+ sourcing_fname,
sourcing_fname
)
eq(
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index 65f6bc28a6..aafad4c8a5 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -97,14 +97,26 @@ describe(':cquit', function()
end)
it('exits with redir msg for multiple exit codes after :cquit 1 2', function()
- test_cq('cquit 1 2', nil, 'nvim_exec2(): Vim(cquit):E488: Trailing characters: 2: cquit 1 2')
+ test_cq(
+ 'cquit 1 2',
+ nil,
+ 'nvim_exec2(), line 1: Vim(cquit):E488: Trailing characters: 2: cquit 1 2'
+ )
end)
it('exits with redir msg for non-number exit code after :cquit X', function()
- test_cq('cquit X', nil, 'nvim_exec2(): Vim(cquit):E488: Trailing characters: X: cquit X')
+ test_cq(
+ 'cquit X',
+ nil,
+ 'nvim_exec2(), line 1: Vim(cquit):E488: Trailing characters: X: cquit X'
+ )
end)
it('exits with redir msg for negative exit code after :cquit -1', function()
- test_cq('cquit -1', nil, 'nvim_exec2(): Vim(cquit):E488: Trailing characters: -1: cquit -1')
+ test_cq(
+ 'cquit -1',
+ nil,
+ 'nvim_exec2(), line 1: Vim(cquit):E488: Trailing characters: -1: cquit -1'
+ )
end)
end)
diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua
index 08f90b088d..91bd2f4bbd 100644
--- a/test/functional/editor/mark_spec.lua
+++ b/test/functional/editor/mark_spec.lua
@@ -42,59 +42,62 @@ describe('named marks', function()
it('errors when set out of range with :mark', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, '1000mark x')
- eq('nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x', err)
+ eq('nvim_exec2(), line 1: Vim(mark):E16: Invalid range: 1000mark x', err)
end)
it('errors when set out of range with :k', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, '1000kx')
- eq('nvim_exec2(): Vim(k):E16: Invalid range: 1000kx', err)
+ eq('nvim_exec2(), line 1: Vim(k):E16: Invalid range: 1000kx', err)
end)
it('errors on unknown mark name with :mark', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, 'mark #')
- eq('nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote', err)
+ eq(
+ 'nvim_exec2(), line 1: Vim(mark):E191: Argument must be a letter or forward/backward quote',
+ err
+ )
end)
it("errors on unknown mark name with '", function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, "normal! '#")
- eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E78: Unknown mark', err)
end)
it('errors on unknown mark name with `', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, 'normal! `#')
- eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E78: Unknown mark', err)
end)
it("errors when moving to a mark that is not set with '", function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, "normal! 'z")
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
err = pcall_err(n.exec_capture, "normal! '.")
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
end)
it('errors when moving to a mark that is not set with `', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, 'normal! `z')
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
err = pcall_err(n.exec_capture, 'normal! `>')
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
end)
it("errors when moving to a global mark that is not set with '", function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, "normal! 'Z")
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
end)
it('errors when moving to a global mark that is not set with `', function()
command('edit ' .. file1)
local err = pcall_err(n.exec_capture, 'normal! `Z')
- eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E20: Mark not set', err)
end)
it("can move to them using '", function()
@@ -169,7 +172,7 @@ describe('named marks', function()
command('next')
command('bw! ' .. file1)
local err = pcall_err(n.exec_capture, "normal! 'A")
- eq('nvim_exec2(): Vim(normal):E92: Buffer 1 not found', err)
+ eq('nvim_exec2(), line 1: Vim(normal):E92: Buffer 1 not found', err)
os.remove(file1)
end)
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 8a15aa04d1..4548e51624 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -101,16 +101,14 @@ describe(':source', function()
\ k: "v"
"\ (o_o)
\ }
- let c = expand("<SID>")->empty()
+ let c = expand("<SID>")
let s:s = 0zbeef.cafe
let d = s:s]])
command('source')
eq('2', exec_capture('echo a'))
eq("{'k': 'v'}", exec_capture('echo b'))
-
- -- Script items are created only on script var access
- eq('1', exec_capture('echo c'))
+ eq('<SNR>1_', exec_capture('echo c'))
eq('0zBEEFCAFE', exec_capture('echo d'))
exec('set cpoptions+=C')
@@ -136,6 +134,10 @@ describe(':source', function()
feed_command(':source')
eq('3', exec_capture('echo a'))
+ -- Source last line only
+ feed_command(':$source')
+ eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
+
-- Source from 2nd line to end of file
feed('ggjVG')
feed_command(':source')
@@ -143,9 +145,9 @@ describe(':source', function()
eq("{'K': 'V'}", exec_capture('echo b'))
eq('<SNR>1_C()', exec_capture('echo D()'))
- -- Source last line only
+ -- Source last line after the lines that define s:C() have been sourced
feed_command(':$source')
- eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
+ eq('<SNR>1_C()', exec_capture('echo D()'))
exec('set cpoptions+=C')
eq("Vim(let):E723: Missing end of Dictionary '}': ", exc_exec("'<,'>source"))
@@ -248,9 +250,9 @@ describe(':source', function()
eq(12, eval('g:c'))
eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
- eq(':source (no file)', api.nvim_get_var('sfile_value'))
- eq(':source (no file)', api.nvim_get_var('stack_value'))
- eq(':source (no file)', api.nvim_get_var('script_value'))
+ eq(':source buffer=1', api.nvim_get_var('sfile_value'))
+ eq(':source buffer=1', api.nvim_get_var('stack_value'))
+ eq(':source buffer=1', api.nvim_get_var('script_value'))
end)
end
diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua
index 0187baf4ac..faddab1e42 100644
--- a/test/functional/ex_cmds/verbose_spec.lua
+++ b/test/functional/ex_cmds/verbose_spec.lua
@@ -256,7 +256,7 @@ TestHL2 xxx guibg=Green
local result = exec_capture(':verbose set tw?')
local loc = get_last_set_location(40)
if loc == 'Lua (run Nvim with -V1 for more details)' then
- loc = 'anonymous :source (script id 1)'
+ loc = 'anonymous :source (script id 1) line 5'
end
eq(
string.format(
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 47eea5e7d5..9863d146b1 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -148,10 +148,10 @@ describe('assert function:', function()
call assert_true('', 'file two')
]])
expected_errors({
- 'nvim_exec2(): equal assertion failed: Expected 1 but got 100',
- "nvim_exec2(): true assertion failed: Expected False but got 'true'",
- "nvim_exec2(): false assertion failed: Expected True but got 'false'",
- "nvim_exec2(): file two: Expected True but got ''",
+ 'nvim_exec2() line 1: equal assertion failed: Expected 1 but got 100',
+ "nvim_exec2() line 2: true assertion failed: Expected False but got 'true'",
+ "nvim_exec2() line 3: false assertion failed: Expected True but got 'false'",
+ "nvim_exec2() line 1: file two: Expected True but got ''",
})
end)
end)
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index 1fd01cfd5a..fb55611198 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -207,7 +207,8 @@ describe(':lua', function()
-- ":{range}lua" fails on invalid Lua code.
eq(
- [[:{range}lua: Vim(lua):E5107: Error loading lua [string ":{range}lua"]:0: '=' expected near '<eof>']],
+ [[:{range}lua buffer=1: Vim(lua):E5107: Error loading lua ]]
+ .. [[[string ":{range}lua buffer=1"]:0: '=' expected near '<eof>']],
pcall_err(command, '1lua')
)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 8e22644339..c31ce3c678 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -3956,7 +3956,7 @@ stack traceback:
it('failure modes', function()
matches(
- 'nvim_exec2%(%): Vim:E492: Not an editor command: fooooo',
+ 'nvim_exec2%(%), line 1: Vim:E492: Not an editor command: fooooo',
pcall_err(exec_lua, [[vim.api.nvim_win_call(0, function() vim.cmd 'fooooo' end)]])
)
eq(