aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/source_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/ex_cmds/source_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/ex_cmds/source_spec.lua')
-rw-r--r--test/functional/ex_cmds/source_spec.lua47
1 files changed, 28 insertions, 19 deletions
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 24987354a4..e822fe78b8 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -52,13 +52,16 @@ describe(':source', function()
meths.set_option_value('shellslash', false, {})
mkdir('Xshellslash')
- write_file([[Xshellslash/Xstack.vim]], [[
+ write_file(
+ [[Xshellslash/Xstack.vim]],
+ [[
let g:stack1 = expand('<stack>')
set shellslash
let g:stack2 = expand('<stack>')
set noshellslash
let g:stack3 = expand('<stack>')
- ]])
+ ]]
+ )
for _ = 1, 2 do
command([[source Xshellslash/Xstack.vim]])
@@ -67,13 +70,16 @@ describe(':source', function()
matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack3'))
end
- write_file([[Xshellslash/Xstack.lua]], [[
+ write_file(
+ [[Xshellslash/Xstack.lua]],
+ [[
vim.g.stack1 = vim.fn.expand('<stack>')
vim.o.shellslash = true
vim.g.stack2 = vim.fn.expand('<stack>')
vim.o.shellslash = false
vim.g.stack3 = vim.fn.expand('<stack>')
- ]])
+ ]]
+ )
for _ = 1, 2 do
command([[source Xshellslash/Xstack.lua]])
@@ -101,11 +107,11 @@ describe(':source', function()
eq("{'k': 'v'}", exec_capture('echo b'))
-- Script items are created only on script var access
- eq("1", exec_capture('echo c'))
- eq("0zBEEFCAFE", exec_capture('echo d'))
+ eq('1', exec_capture('echo c'))
+ eq('0zBEEFCAFE', exec_capture('echo d'))
exec('set cpoptions+=C')
- eq('Vim(let):E723: Missing end of Dictionary \'}\': ', exc_exec('source'))
+ eq("Vim(let):E723: Missing end of Dictionary '}': ", exc_exec('source'))
end)
it('selection in current buffer', function()
@@ -132,14 +138,14 @@ describe(':source', function()
feed_command(':source')
eq('4', exec_capture('echo a'))
eq("{'K': 'V'}", exec_capture('echo b'))
- eq("<SNR>1_C()", exec_capture('echo D()'))
+ eq('<SNR>1_C()', exec_capture('echo D()'))
-- Source last line only
feed_command(':$source')
eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
exec('set cpoptions+=C')
- eq('Vim(let):E723: Missing end of Dictionary \'}\': ', exc_exec("'<,'>source"))
+ eq("Vim(let):E723: Missing end of Dictionary '}': ", exc_exec("'<,'>source"))
end)
it('does not break if current buffer is modified while sourced', function()
@@ -163,12 +169,15 @@ describe(':source', function()
it('can source lua files', function()
local test_file = 'test.lua'
- write_file(test_file, [[
+ write_file(
+ test_file,
+ [[
vim.g.sourced_lua = 1
vim.g.sfile_value = vim.fn.expand('<sfile>')
vim.g.stack_value = vim.fn.expand('<stack>')
vim.g.script_value = vim.fn.expand('<script>')
- ]])
+ ]]
+ )
command('set shellslash')
command('source ' .. test_file)
@@ -245,22 +254,22 @@ describe(':source', function()
local test_file = 'test.lua'
-- Does throw E484 for unreadable files
- local ok, result = pcall(exec_capture, ":source "..test_file ..'noexisting')
+ local ok, result = pcall(exec_capture, ':source ' .. test_file .. 'noexisting')
eq(false, ok)
- neq(nil, result:find("E484"))
+ neq(nil, result:find('E484'))
-- Doesn't throw for parsing error
- write_file (test_file, "vim.g.c = ")
- ok, result = pcall(exec_capture, ":source "..test_file)
+ write_file(test_file, 'vim.g.c = ')
+ ok, result = pcall(exec_capture, ':source ' .. test_file)
eq(false, ok)
- eq(nil, result:find("E484"))
+ eq(nil, result:find('E484'))
os.remove(test_file)
-- Doesn't throw for runtime error
- write_file (test_file, "error('Cause error anyway :D')")
- ok, result = pcall(exec_capture, ":source "..test_file)
+ write_file(test_file, "error('Cause error anyway :D')")
+ ok, result = pcall(exec_capture, ':source ' .. test_file)
eq(false, ok)
- eq(nil, result:find("E484"))
+ eq(nil, result:find('E484'))
os.remove(test_file)
end)
end)