vim-patch:7.4.1486

Problem:    ":loadplugin" is not optimal, some people find it confusing.
Solution:   Only use ":packadd" with an optional "!".

f365482736
This commit is contained in:
James McCoy
2016-04-28 22:58:24 -04:00
parent 67d8e58631
commit 2f72f34f04
5 changed files with 106 additions and 100 deletions

View File

@@ -1,4 +1,4 @@
-- Tests for :loadplugin
-- Tests for 'packpath' and :packadd
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
@@ -8,8 +8,8 @@ local function expected_empty()
eq({}, nvim.get_vvar('errors'))
end
describe('loadplugin', function()
setup(function()
describe('packadd', function()
before_each(function()
clear()
source([=[
@@ -23,7 +23,7 @@ describe('loadplugin', function()
call delete(s:topdir, 'rf')
endfunc
func Test_loadplugin()
func Test_packadd()
call mkdir(s:plugdir . '/plugin', 'p')
call mkdir(s:plugdir . '/ftdetect', 'p')
set rtp&
@@ -38,7 +38,7 @@ describe('loadplugin', function()
call setline(1, 'let g:ftdetect_works = 17')
wq
loadplugin mytest
packadd mytest
call assert_true(42, g:plugin_works)
call assert_true(17, g:ftdetect_works)
@@ -46,34 +46,43 @@ describe('loadplugin', function()
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
endfunc
func Test_packadd()
func Test_packadd_noload()
call mkdir(s:plugdir . '/plugin', 'p')
call mkdir(s:plugdir . '/syntax', 'p')
set rtp&
let rtp = &rtp
packadd mytest
exe 'split ' . s:plugdir . '/plugin/test.vim'
call setline(1, 'let g:plugin_works = 42')
wq
let g:plugin_works = 0
packadd! mytest
call assert_true(len(&rtp) > len(rtp))
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
call assert_equal(0, g:plugin_works)
" check the path is not added twice
let new_rtp = &rtp
packadd mytest
packadd! mytest
call assert_equal(new_rtp, &rtp)
endfunc
]=])
call('SetUp')
end)
teardown(function()
after_each(function()
call('TearDown')
end)
it('is working', function()
call('Test_loadplugin')
expected_empty()
end)
it('works with packadd', function()
call('Test_packadd')
expected_empty()
end)
it('works with packadd!', function()
call('Test_packadd_noload')
expected_empty()
end)
end)