aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/buffer_updates_spec.lua2
-rw-r--r--test/functional/core/startup_spec.lua6
-rw-r--r--test/functional/insert/ctrl_o_spec.lua11
-rw-r--r--test/functional/lua/utility_functions_spec.lua50
4 files changed, 52 insertions, 17 deletions
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index b894d2facd..89d0c6f000 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -760,7 +760,7 @@ describe('API: buffer events:', function()
it('returns a proper error on nonempty options dict', function()
clear()
local b = editoriginal(false)
- expect_err("dict isn't empty", buffer, 'attach', b, false, {builtin="asfd"})
+ expect_err("unexpected key: builtin", buffer, 'attach', b, false, {builtin="asfd"})
end)
it('nvim_buf_attach returns response after delay #8634', function()
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index f77af836a6..45bfa93b56 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -46,7 +46,7 @@ describe('startup', function()
]])
end)
it('in a TTY: has("ttyin")==1 has("ttyout")==1', function()
- local screen = Screen.new(25, 3)
+ local screen = Screen.new(25, 4)
screen:attach()
if iswin() then
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
@@ -58,6 +58,7 @@ describe('startup', function()
..[[, shellescape(v:progpath))]])
screen:expect([[
^ |
+ ~ |
1 1 |
|
]])
@@ -96,7 +97,7 @@ describe('startup', function()
end)
end)
it('input from pipe (implicit) #7679', function()
- local screen = Screen.new(25, 3)
+ local screen = Screen.new(25, 4)
screen:attach()
if iswin() then
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
@@ -109,6 +110,7 @@ describe('startup', function()
..[[, shellescape(v:progpath))]])
screen:expect([[
^foo |
+ ~ |
0 1 |
|
]])
diff --git a/test/functional/insert/ctrl_o_spec.lua b/test/functional/insert/ctrl_o_spec.lua
index fbdff8a3a0..543d0a7d68 100644
--- a/test/functional/insert/ctrl_o_spec.lua
+++ b/test/functional/insert/ctrl_o_spec.lua
@@ -5,6 +5,7 @@ local eval = helpers.eval
local expect = helpers.expect
local feed = helpers.feed
local insert = helpers.insert
+local meths = helpers.meths
describe('insert-mode Ctrl-O', function()
before_each(clear)
@@ -40,4 +41,14 @@ describe('insert-mode Ctrl-O', function()
feed('ooo')
expect('hello oooworld')
end)
+
+ it("doesn't cancel Ctrl-O mode when processing event", function()
+ feed('iHello World<c-o>')
+ eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event
+ eq(2, eval('1+1')) -- causes K_EVENT key
+ eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode
+ feed('dd')
+ eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode
+ expect('') -- executed the command
+ end)
end)
diff --git a/test/functional/lua/utility_functions_spec.lua b/test/functional/lua/utility_functions_spec.lua
index 67f5ce24f7..780d3a1565 100644
--- a/test/functional/lua/utility_functions_spec.lua
+++ b/test/functional/lua/utility_functions_spec.lua
@@ -5,10 +5,13 @@ local funcs = helpers.funcs
local meths = helpers.meths
local clear = helpers.clear
local eq = helpers.eq
+local eval = helpers.eval
+local feed = helpers.feed
+local meth_pcall = helpers.meth_pcall
before_each(clear)
-describe('vim.stricmp', function()
+describe('lua function', function()
-- İ: `tolower("İ")` is `i` which has length 1 while `İ` itself has
-- length 2 (in bytes).
-- Ⱥ: `tolower("Ⱥ")` is `ⱥ` which has length 2 while `Ⱥ` itself has
@@ -17,7 +20,7 @@ describe('vim.stricmp', function()
-- Note: 'i' !=? 'İ' and 'ⱥ' !=? 'Ⱥ' on some systems.
-- Note: Built-in Nvim comparison (on systems lacking `strcasecmp`) works
-- only on ASCII characters.
- it('works', function()
+ it('vim.stricmp', function()
eq(0, funcs.luaeval('vim.stricmp("a", "A")'))
eq(0, funcs.luaeval('vim.stricmp("A", "a")'))
eq(0, funcs.luaeval('vim.stricmp("a", "a")'))
@@ -106,10 +109,35 @@ describe('vim.stricmp', function()
eq(1, funcs.luaeval('vim.stricmp("\\0c\\0", "\\0b\\0")'))
eq(1, funcs.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
end)
-end)
-describe("vim.split", function()
- it("works", function()
+ it("vim.schedule", function()
+ meths.execute_lua([[
+ test_table = {}
+ vim.schedule(function()
+ table.insert(test_table, "xx")
+ end)
+ table.insert(test_table, "yy")
+ ]], {})
+ eq({"yy","xx"}, meths.execute_lua("return test_table", {}))
+
+ -- type checked args
+ eq({false, 'Error executing lua: vim.schedule: expected function'},
+ meth_pcall(meths.execute_lua, "vim.schedule('stringly')", {}))
+
+ eq({false, 'Error executing lua: vim.schedule: expected function'},
+ meth_pcall(meths.execute_lua, "vim.schedule()", {}))
+
+ meths.execute_lua([[
+ vim.schedule(function()
+ error("big failure\nvery async")
+ end)
+ ]], {})
+
+ feed("<cr>")
+ eq('Error executing vim.schedule lua callback: [string "<nvim>"]:2: big failure\nvery async', eval("v:errmsg"))
+ end)
+
+ it("vim.split", function()
local split = function(str, sep)
return meths.execute_lua('return vim.split(...)', {str, sep})
end
@@ -141,10 +169,8 @@ describe("vim.split", function()
assert(string.match(err, "Infinite loop detected"))
end
end)
-end)
-describe("vim.trim", function()
- it('works', function()
+ it('vim.trim', function()
local trim = function(s)
return meths.execute_lua('return vim.trim(...)', { s })
end
@@ -164,10 +190,8 @@ describe("vim.trim", function()
eq(false, status)
assert(string.match(err, "Only strings can be trimmed"))
end)
-end)
-describe("vim.inspect", function()
- it('works', function()
+ it('vim.inspect', function()
-- just make sure it basically works, it has its own test suite
local inspect = function(t, opts)
return meths.execute_lua('return vim.inspect(...)', { t, opts })
@@ -187,10 +211,8 @@ describe("vim.inspect", function()
end})
]], {}))
end)
-end)
-describe("vim.deepcopy", function()
- it("works", function()
+ it("vim.deepcopy", function()
local is_dc = meths.execute_lua([[
local a = { x = { 1, 2 }, y = 5}
local b = vim.deepcopy(a)