2021-06-01 20:32:37 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
|
|
|
local exec = helpers.exec
|
|
|
|
local mkdir_p = helpers.mkdir_p
|
|
|
|
local rmdir = helpers.rmdir
|
|
|
|
local write_file = helpers.write_file
|
|
|
|
|
|
|
|
describe('runtime:', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local plug_dir = 'Test_Plugin'
|
|
|
|
local sep = helpers.get_pathsep()
|
|
|
|
local init = 'dummy_init.lua'
|
|
|
|
|
|
|
|
setup(function()
|
|
|
|
io.open(init, 'w'):close() -- touch init file
|
|
|
|
clear{args = {'-u', init}}
|
|
|
|
exec('set rtp+=' .. plug_dir)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
teardown(function()
|
|
|
|
os.remove(init)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
before_each(function()
|
|
|
|
mkdir_p(plug_dir)
|
|
|
|
end)
|
2021-06-01 20:32:37 -07:00
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
after_each(function()
|
|
|
|
rmdir(plug_dir)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('colors', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local colorscheme_folder = plug_dir .. sep .. 'colors'
|
|
|
|
|
2021-06-01 20:32:37 -07:00
|
|
|
it('loads lua colorscheme', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local colorscheme_file = colorscheme_folder .. sep .. 'new_colorscheme.lua'
|
2021-06-01 20:32:37 -07:00
|
|
|
mkdir_p(colorscheme_folder)
|
|
|
|
write_file(colorscheme_file, [[vim.g.lua_colorscheme = 1]])
|
|
|
|
|
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
|
|
|
|
eq(1, eval('g:lua_colorscheme'))
|
|
|
|
rmdir(colorscheme_folder)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('loads vim colorscheme when both lua and vim version exist', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local colorscheme_file = colorscheme_folder .. sep .. 'new_colorscheme'
|
2021-06-01 20:32:37 -07:00
|
|
|
mkdir_p(colorscheme_folder)
|
|
|
|
write_file(colorscheme_file..'.vim', [[let g:colorscheme = 'vim']])
|
|
|
|
write_file(colorscheme_file..'.lua', [[vim.g.colorscheme = 'lua']])
|
|
|
|
|
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
|
|
|
|
eq('vim', eval('g:colorscheme'))
|
|
|
|
rmdir(colorscheme_folder)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2021-06-02 00:48:13 -07:00
|
|
|
describe('compiler', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local compiler_folder = plug_dir .. sep .. 'compiler'
|
2021-06-02 00:48:13 -07:00
|
|
|
|
|
|
|
it('loads lua compilers', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local compiler_file = compiler_folder .. sep .. 'new_compiler.lua'
|
2021-06-02 00:48:13 -07:00
|
|
|
mkdir_p(compiler_folder)
|
|
|
|
write_file(compiler_file, [[vim.g.lua_compiler = 1]])
|
|
|
|
|
|
|
|
exec('compiler new_compiler')
|
|
|
|
|
|
|
|
eq(1, eval('g:lua_compiler'))
|
|
|
|
rmdir(compiler_folder)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('loads vim compilers when both lua and vim version exist', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local compiler_file = compiler_folder .. sep .. 'new_compiler'
|
2021-06-02 00:48:13 -07:00
|
|
|
mkdir_p(compiler_folder)
|
|
|
|
write_file(compiler_file..'.vim', [[let g:compiler = 'vim']])
|
|
|
|
write_file(compiler_file..'.lua', [[vim.g.compiler = 'lua']])
|
|
|
|
|
|
|
|
exec('compiler new_compiler')
|
|
|
|
|
|
|
|
eq('vim', eval('g:compiler'))
|
|
|
|
rmdir(compiler_folder)
|
|
|
|
end)
|
|
|
|
end)
|
2021-06-02 03:25:50 -07:00
|
|
|
|
|
|
|
describe('ftplugin', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local ftplugin_folder = table.concat({plug_dir, 'ftplugin'}, sep)
|
2021-06-02 03:25:50 -07:00
|
|
|
|
|
|
|
it('loads lua ftplugins', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local ftplugin_file = table.concat({ftplugin_folder , 'new-ft.lua'}, sep)
|
2021-06-02 03:25:50 -07:00
|
|
|
mkdir_p(ftplugin_folder)
|
2021-06-02 04:04:42 -07:00
|
|
|
write_file(ftplugin_file , [[vim.g.lua_ftplugin = 1]])
|
2021-06-02 03:25:50 -07:00
|
|
|
|
|
|
|
exec [[set filetype=new-ft]]
|
|
|
|
eq(1, eval('g:lua_ftplugin'))
|
|
|
|
rmdir(ftplugin_folder)
|
|
|
|
end)
|
|
|
|
end)
|
2021-06-02 03:33:40 -07:00
|
|
|
|
|
|
|
describe('indent', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local indent_folder = table.concat({plug_dir, 'indent'}, sep)
|
2021-06-02 03:33:40 -07:00
|
|
|
|
|
|
|
it('loads lua indents', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local indent_file = table.concat({indent_folder , 'new-ft.lua'}, sep)
|
2021-06-02 03:33:40 -07:00
|
|
|
mkdir_p(indent_folder)
|
2021-06-02 04:04:42 -07:00
|
|
|
write_file(indent_file , [[vim.g.lua_indent = 1]])
|
2021-06-02 03:33:40 -07:00
|
|
|
|
|
|
|
exec [[set filetype=new-ft]]
|
|
|
|
eq(1, eval('g:lua_indent'))
|
|
|
|
rmdir(indent_folder)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2021-06-02 08:08:28 -07:00
|
|
|
describe('syntax', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local syntax_folder = table.concat({plug_dir, 'syntax'}, sep)
|
2021-06-02 08:08:28 -07:00
|
|
|
|
|
|
|
it('loads lua syntaxes on filetype change', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local syntax_file = table.concat({syntax_folder , 'my-lang.lua'}, sep)
|
2021-06-02 08:08:28 -07:00
|
|
|
mkdir_p(syntax_folder)
|
|
|
|
write_file(syntax_file , [[vim.g.lua_syntax = 1]])
|
|
|
|
|
|
|
|
exec('set filetype=my-lang')
|
|
|
|
eq(1, eval('g:lua_syntax'))
|
|
|
|
rmdir(syntax_folder)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('loads lua syntaxes on syntax change', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local syntax_file = table.concat({syntax_folder , 'my-lang.lua'}, sep)
|
2021-06-02 08:08:28 -07:00
|
|
|
mkdir_p(syntax_folder)
|
|
|
|
write_file(syntax_file , [[vim.g.lua_syntax = 5]])
|
|
|
|
|
|
|
|
exec('set syntax=my-lang')
|
|
|
|
eq(5, eval('g:lua_syntax'))
|
|
|
|
rmdir(syntax_folder)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|