Commits

ZyX_I committed 8294726

tests: Added tests for _pluginloaded and _loading variable values
doc: Some fixes and clarification when s:_loading may be used

Comments (0)

Files changed (7)

         type         First component of plugin file path that is not part of 
                      runtimepath (or `/unknown' if frawor failed to detect 
                      it).
-        It also sets s:_pluginloaded to either 1 for oneload plugins or 0.
+        It sets s:_pluginloaded to 1 for oneload plugins and 0 for other. Also 
+        see |s:_loading|.
                                                        *frawor-plid-expansion*
         If some key in {dependencies} dictionary starts with `@', then it is 
         transformed:
                                   registered and then to 1 after plugin is 
                                   loaded.
 *s:_loading*       plugin/frawor    Integer. Is set to 1 when frawor started 
-                                  to load plugin and unset after plugin was 
-                                  loaded.
+                                  to load non-oneload plugin and unset after 
+                                  plugin was loaded.
 *s:_frawor*        plugin/frawor    Dictionary. Is set by |FraworRegister()|.
 *s:_messages*      plugin/frawor    Dictionary that contains strings as 
                                   values. Required for |frawor-f-warn| and 

test/oneload-variables.in

+:let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
+:let g:testfile="plugin/".g:curtest.".vim"
+:let g:testcmd='runtime'
+:source test.vim
+:source test.vim
+:call FraworUnload(g:testfile[:-5])
+:source test.vim
+:source test.vim

test/oneload-variables.ok

+Before registration: 
+pl: undef
+ l: undef
+After registration: 
+pl: 1
+ l: undef
+Second run: 
+pl: 1
+ l: undef
+Before registration: 
+pl: undef
+ l: undef
+After registration: 
+pl: 1
+ l: undef
+Second run: 
+pl: 1
+ l: undef

test/rtp/plugin/oneload-variables.vim

+let s:vexpr='((exists("@@@"))?(string(@@@)):("undef"))'
+let s:wexpr = '["pl: ".'.substitute(s:vexpr, '@@@', 's:_pluginloaded', 'g')
+            \.'," l: ".'.substitute(s:vexpr, '@@@', 's:_loading',      'g').']'
+if exists('s:_pluginloaded')
+    call WriteFile(['Second run: ']+eval(s:wexpr))
+else
+    call WriteFile(['Before registration: ']+eval(s:wexpr))
+endif
+execute frawor#Setup('0.0', {})
+call WriteFile(['After registration: ']+eval(s:wexpr))

test/rtp/plugin/twoload-variables.vim

+let s:vexpr='((exists("@@@"))?(string(@@@)):("undef"))'
+let s:wexpr = '["pl: ".'.substitute(s:vexpr, '@@@', 's:_pluginloaded', 'g')
+            \.'," l: ".'.substitute(s:vexpr, '@@@', 's:_loading',      'g').']'
+if !exists('s:_pluginloaded')
+    call WriteFile(['Before registration: ']+eval(s:wexpr))
+    execute frawor#Setup('0.0', {}, 0)
+    call WriteFile(['After registration: ']+eval(s:wexpr))
+    finish
+elseif s:_pluginloaded
+    call WriteFile(['Second run: ']+eval(s:wexpr))
+    finish
+elseif !exists('s:_loading')
+    call WriteFile(['Runtime: ']+eval(s:wexpr))
+    call FraworLoad(s:_frawor.id)
+    finish
+endif
+call WriteFile(['After load: ']+eval(s:wexpr))

test/twoload-variables.in

+:let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
+:let g:testfile="plugin/".g:curtest.".vim"
+:let g:testcmd='runtime'
+:source test.vim
+:source test.vim
+:source test.vim
+:call FraworUnload(g:testfile[:-5])
+:source test.vim
+:source test.vim
+:source test.vim

test/twoload-variables.ok

+Before registration: 
+pl: undef
+ l: undef
+After registration: 
+pl: 0
+ l: undef
+Runtime: 
+pl: 0
+ l: undef
+After load: 
+pl: 0
+ l: 1
+Second run: 
+pl: 1
+ l: undef
+Before registration: 
+pl: undef
+ l: undef
+After registration: 
+pl: 0
+ l: undef
+Runtime: 
+pl: 0
+ l: undef
+After load: 
+pl: 0
+ l: 1
+Second run: 
+pl: 1
+ l: undef
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.