aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/loop_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua/loop_spec.lua')
-rw-r--r--test/functional/lua/loop_spec.lua59
1 files changed, 21 insertions, 38 deletions
diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua
index c0924fa0c0..71eaf29009 100644
--- a/test/functional/lua/loop_spec.lua
+++ b/test/functional/lua/loop_spec.lua
@@ -1,10 +1,10 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local clear = helpers.clear
-local sleep = helpers.sleep
+local sleep = vim.uv.sleep
local feed = helpers.feed
local eq = helpers.eq
local eval = helpers.eval
@@ -15,23 +15,20 @@ local retry = helpers.retry
before_each(clear)
describe('vim.uv', function()
-
it('version', function()
- assert(funcs.luaeval('vim.uv.version()')>=72961, "libuv version too old")
- matches("(%d+)%.(%d+)%.(%d+)", funcs.luaeval('vim.uv.version_string()'))
+ assert(fn.luaeval('vim.uv.version()') >= 72961, 'libuv version too old')
+ matches('(%d+)%.(%d+)%.(%d+)', fn.luaeval('vim.uv.version_string()'))
end)
it('timer', function()
exec_lua('vim.api.nvim_set_var("coroutine_cnt", 0)', {})
- local code=[[
- local uv = vim.uv
-
+ local code = [[
local touch = 0
local function wait(ms)
local this = coroutine.running()
assert(this)
- local timer = uv.new_timer()
+ local timer = vim.uv.new_timer()
timer:start(ms, 0, vim.schedule_wrap(function ()
timer:close()
touch = touch + 1
@@ -51,24 +48,24 @@ describe('vim.uv', function()
end)()
]]
- eq(0, meths.get_var('coroutine_cnt'))
+ eq(0, api.nvim_get_var('coroutine_cnt'))
exec_lua(code)
retry(2, nil, function()
sleep(50)
- eq(2, meths.get_var('coroutine_cnt'))
+ eq(2, api.nvim_get_var('coroutine_cnt'))
end)
- eq(3, meths.get_var('coroutine_cnt_1'))
+ eq(3, api.nvim_get_var('coroutine_cnt_1'))
end)
it('is API safe', function()
- local screen = Screen.new(50,10)
+ local screen = Screen.new(50, 10)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {bold = true, reverse = true},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {bold = true},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { bold = true, reverse = true },
+ [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { bold = true },
})
-- deferred API functions are disabled, as their safety can't be guaranteed
@@ -96,7 +93,7 @@ describe('vim.uv', function()
]])
feed('<cr>')
eq(false, eval("get(g:, 'valid', v:false)"))
- eq(true, exec_lua("return _G.is_fast"))
+ eq(true, exec_lua('return _G.is_fast'))
-- callbacks can be scheduled to be executed in the main event loop
-- where the entire API is available
@@ -112,18 +109,11 @@ describe('vim.uv', function()
screen:expect([[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*8
howdy |
]])
eq(true, eval("get(g:, 'valid', v:false)"))
- eq(false, exec_lua("return _G.is_fast"))
+ eq(false, exec_lua('return _G.is_fast'))
-- fast (not deferred) API functions are allowed to be called directly
exec_lua([[
@@ -137,17 +127,10 @@ describe('vim.uv', function()
]])
screen:expect([[
sneaky^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*8
{5:-- INSERT --} |
]])
- eq({blocking=false, mode='n'}, exec_lua("return _G.mode"))
+ eq({ blocking = false, mode = 'n' }, exec_lua('return _G.mode'))
end)
it("is equal to require('luv')", function()