Commits

ZyX_I committed 564fdd7

Added test for reloading plugin with global functions

Comments (0)

Files changed (4)

plugin/frawor/functions.vim

 endif
 execute frawor#Setup('0.0', {}, 1)
 let s:g.sidfpref=substitute(s:Eval('expand("<sfile>")[9:-5]'), s:g._sid,'%u','')
+"▶1 _messages
+if v:lang=~?'ru'
+    let s:g._messages={
+                \'fnotdict': 'Ошибка создания функций для дополнения %s: '.
+                \            'аргумент, описывающий функции, '.
+                \            'должен быть словарём',
+            \}
+else
+    let s:g._messages={
+                \'fnotdict': 'Error while creating functions for %s: '.
+                \            'functions argument must be a dictionary',
+            \}
+endif
 "▶1 delfunctions
 function s:F.delfunctions(plugdict)
     let d={}
 endfunction
 call s:F._frawor.newfeature('delfunctions', {'unloadpre': s:F.delfunctions,
             \                               'ignoredeps': 1})
+"▶1 addextfunctions
+function s:F.addextfunctions(plugdict, functions)
+    if type(a:function)!=type({})
+        call s:F._frawor.throw('fnotdict', a:plugdict.id)
+    endif
+    let d={}
+    for [fname, d.fopts] in items(a:function)
+    endfor
+endfunction
+call s:F._frawor.newfeature('addextfunctions', {'cons': s:F.addextfunctions})
 

test/global-functions-reload.in

+:let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
+:let g:testfile="plugin/global-function.vim"
+:source test.vim
+:redir @f
+:scriptnames
+:let g:lastsid=+matchstr(@f, '^.*\zs\d\+')
+:execute "redir! >> ".g:outfile
+:function TestFunction
+:execute "function <SNR>".g:lastsid."_testFunction"
+:call frawor#Reload("plugin/global-function")
+:function TestFunction
+:execute "function <SNR>".g:lastsid."_testFunction"

test/global-functions-reload.ok

+
+
+   function TestFunction()
+1      echo 1
+   endfunction
+
+   function <SNR>6_testFunction()
+1      echo 2
+   endfunction
+
+
+   function TestFunction()
+1      echo 1
+   endfunction
+
+   function <SNR>6_testFunction()
+1      echo 2
+   endfunction

test/rtp/plugin/global-function.vim

+execute frawor#Setup('0.0', {}, 1)
+
+function TestFunction()
+    echo 1
+endfunction
+let s:F._functions.TestFunction=function("TestFunction")
+
+function s:testFunction()
+    echo 2
+endfunction
+let s:F._functions["s:testFunction"]=function("s:testFunction")