aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/overrides_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
commit21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch)
tree84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /test/functional/lua/overrides_spec.lua
parentd9c904f85a23a496df4eb6be42aa43f007b22d50 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-colorcolchar.tar.gz
rneovim-colorcolchar.tar.bz2
rneovim-colorcolchar.zip
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'test/functional/lua/overrides_spec.lua')
-rw-r--r--test/functional/lua/overrides_spec.lua57
1 files changed, 49 insertions, 8 deletions
diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua
index 3f107811ae..c08f3d06a9 100644
--- a/test/functional/lua/overrides_spec.lua
+++ b/test/functional/lua/overrides_spec.lua
@@ -15,8 +15,6 @@ local exec_lua = helpers.exec_lua
local pcall_err = helpers.pcall_err
local is_os = helpers.is_os
-local screen
-
local fname = 'Xtest-functional-lua-overrides-luafile'
before_each(clear)
@@ -56,7 +54,7 @@ describe('print', function()
-- TODO(bfredl): these look weird, print() should not use "E5114:" style errors..
eq('Vim(lua):E5108: Error executing lua E5114: Error while converting print argument #2: [NULL]',
pcall_err(command, 'lua print("foo", v_nilerr, "bar")'))
- eq('Vim(lua):E5108: Error executing lua E5114: Error while converting print argument #2: Xtest-functional-lua-overrides-luafile:0: abc',
+ eq('Vim(lua):E5108: Error executing lua E5114: Error while converting print argument #2: Xtest-functional-lua-overrides-luafile:2: abc',
pcall_err(command, 'lua print("foo", v_abcerr, "bar")'))
eq('Vim(lua):E5108: Error executing lua E5114: Error while converting print argument #2: <Unknown error: lua_tolstring returned NULL for tostring result>',
pcall_err(command, 'lua print("foo", v_tblout, "bar")'))
@@ -86,9 +84,9 @@ describe('print', function()
end
]])
eq('', exec_capture('luafile ' .. fname))
- eq('Vim(lua):E5108: Error executing lua Xtest-functional-lua-overrides-luafile:0: my mistake',
+ eq('Vim(lua):E5108: Error executing lua Xtest-functional-lua-overrides-luafile:1: my mistake',
pcall_err(command, 'lua string_error()'))
- eq('Vim(lua):E5108: Error executing lua Xtest-functional-lua-overrides-luafile:0: 1234',
+ eq('Vim(lua):E5108: Error executing lua Xtest-functional-lua-overrides-luafile:2: 1234',
pcall_err(command, 'lua number_error()'))
eq('Vim(lua):E5108: Error executing lua [NULL]',
pcall_err(command, 'lua nil_error()'))
@@ -100,7 +98,7 @@ describe('print', function()
pcall_err(command, 'lua bad_custom_error()'))
end)
it('prints strings with NULs and NLs correctly', function()
- meths.set_option('more', true)
+ meths.set_option_value('more', true, {})
eq('abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT\n',
exec_capture([[lua print("abc \0 def\nghi\0\0\0jkl\nTEST\n\n\nT\n")]]))
eq('abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT^@',
@@ -119,7 +117,7 @@ describe('print', function()
exec_lua([[
local cmd = ...
function test()
- local timer = vim.loop.new_timer()
+ local timer = vim.uv.new_timer()
local done = false
timer:start(10, 0, function()
print("very fast")
@@ -130,7 +128,7 @@ describe('print', function()
-- loop until we know for sure the callback has been executed
while not done do
os.execute(cmd)
- vim.loop.run("nowait") -- fake os_breakcheck()
+ vim.uv.run("nowait") -- fake os_breakcheck()
end
print("very slow")
vim.api.nvim_command("sleep 1m") -- force deferred event processing
@@ -138,9 +136,44 @@ describe('print', function()
]], (is_os('win') and "timeout 1") or "sleep 0.1")
eq('very slow\nvery fast', exec_capture('lua test()'))
end)
+
+ it('blank line in message works', function()
+ local screen = Screen.new(40, 8)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground=Screen.colors.Blue},
+ [1] = {bold = true, foreground = Screen.colors.SeaGreen},
+ [2] = {bold = true, reverse = true},
+ })
+ feed([[:lua print('\na')<CR>]])
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {2: }|
+ |
+ a |
+ {1:Press ENTER or type command to continue}^ |
+ ]]}
+ feed('<CR>')
+ feed([[:lua print('b\n\nc')<CR>]])
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2: }|
+ b |
+ |
+ c |
+ {1:Press ENTER or type command to continue}^ |
+ ]]}
+ end)
end)
describe('debug.debug', function()
+ local screen
+
before_each(function()
screen = Screen.new()
screen:attach()
@@ -338,3 +371,11 @@ describe('os.getenv', function()
eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
end)
end)
+
+-- "bit" module is always available, regardless if nvim is built with
+-- luajit or PUC lua 5.1.
+describe('bit module', function()
+ it('works', function()
+ eq (9, exec_lua [[ return require'bit'.band(11,13) ]])
+ end)
+end)