Commits

ZyX_I committed 9e57e58

Added WriteFile function to test/test.vim

Comments (0)

Files changed (8)

test/rtp/plugin/plugin-with-dependencies.vim

 execute frawor#Setup('1.1', {'plugin/register-return-value': [0]}, 1)
-let s:r=[]
-if filereadable(g:outfile)
-    let s:r+=readfile(g:outfile, 'b')
-endif
-for s:key in sort(keys(s:g._frawor))
-    call add(s:r, s:key.': '.string(s:g._frawor[s:key]))
-endfor
-call writefile(s:r, g:outfile, 'b')
+call call("WriteFile", map(sort(keys(s:g._frawor)),
+            \               'v:val.": ".string(s:g._frawor[v:val])'))
 

test/rtp/plugin/plugin-with-feature.vim

     try
         call s:F._frawor.throw('testmsg', 'test')
     catch /^Frawor:plugin\%x2Fplugin-with-feature:testmsg:This is a test message: test$/
-        let r=[]
-        if filereadable(g:outfile)
-            let r+=readfile(g:outfile, 'b')
-        endif
-        call add(r, v:exception)
-        call add(r, 'cons: '.a:plugdict.id)
-        call writefile(r, g:outfile, 'b')
+        call WriteFile(v:exception, 'cons: '.a:plugdict.id)
     endtry
 endfunction
 function s:F.testfeatureload(plugdict)
-    let r=[]
-    if filereadable(g:outfile)
-        let r+=readfile(g:outfile, 'b')
-    endif
-    call add(r, 'load: '.a:plugdict.id)
-    call writefile(r, g:outfile, 'b')
+    call WriteFile('load: '.a:plugdict.id)
 endfunction
 call s:F._frawor.newfeature('testfeature', {'cons': s:F.testfeaturecons,
             \                               'load': s:F.testfeatureload})

test/rtp/plugin/recursive-dependent.2.vim

 execute frawor#Setup('1.1', {'plugin/recursive-dependent': [1]}, 1)
-let s:r=[]
-if filereadable(g:outfile)
-    let s:r+=readfile(g:outfile, 'b')
-endif
-for s:key in sort(keys(s:g._frawor))
-    call add(s:r, s:key.': '.string(s:g._frawor[s:key]))
-endfor
-call writefile(s:r, g:outfile, 'b')
+call call("WriteFile", map(sort(keys(s:g._frawor)),
+            \               'v:val.": ".string(s:g._frawor[v:val])'))
 

test/rtp/plugin/recursive-dependent.vim

 execute frawor#Setup('1.1', {'plugin/recursive-dependent.2':    [1, 1],
             \                'plugin/plugin-with-dependencies': [1, 1]}, 1)
-let s:r=[]
-if filereadable(g:outfile)
-    let s:r+=readfile(g:outfile, 'b')
-endif
-for s:key in sort(keys(s:g._frawor))
-    call add(s:r, s:key.': '.string(s:g._frawor[s:key]))
-endfor
-call writefile(s:r, g:outfile, 'b')
+call call("WriteFile", map(sort(keys(s:g._frawor)),
+            \               'v:val.": ".string(s:g._frawor[v:val])'))
 

test/rtp/plugin/register-feature-list.vim

 execute frawor#Setup('0.0', {}, 1)
-let s:r=[]
-if filereadable(g:outfile)
-    let s:r+=readfile(g:outfile, 'b')
-endif
-let s:r+=sort(keys(s:F._frawor))
-call writefile(s:r, g:outfile, 'b')
+call call("WriteFile", sort(keys(s:F._frawor)))
 

test/rtp/plugin/register-return-value.vim

 execute frawor#Setup('0.0', {}, 1)
-let s:r=[]
-if filereadable(g:outfile)
-    let s:r+=readfile(g:outfile, 'b')
-endif
-for s:key in sort(keys(s:g._frawor))
-    call add(s:r, s:key.': '.string(s:g._frawor[s:key]))
-endfor
-call writefile(s:r, g:outfile, 'b')
+call call("WriteFile", map(sort(keys(s:g._frawor)),
+            \               'v:val.": ".string(s:g._frawor[v:val])'))
 

test/rtp/plugin/writefile-feature.vim

 execute frawor#Setup('0.0', {}, 1)
 function s:F.writefile(plugdict, ...)
-    let r=[]
-    if filereadable(g:outfile)
-        let r+=readfile(g:outfile, 'b')
-    endif
-    let r+=a:000
-    return writefile(r, g:outfile, 'b')
+    return call("WriteFile", a:000)
 endfunction
 call s:F._frawor.newfeature('writefile', {'cons': s:F.writefile})
 
 let g:outfile=g:curtest.'.out'
+function WriteFile(...)
+    let r=[]
+    if filereadable(g:outfile)
+        let r+=readfile(g:outfile, 'b')
+    endif
+    let r+=a:000
+    return writefile(r, g:outfile, 'b')
+endfunction
 if !exists('g:testcmd')
     let s:testcmd='call FraworLoad(g:testfile[:-5])'
 else
 try
     execute s:testcmd
 catch
-    let r=[substitute(v:exception,
-                \'Frawor:\%(\\.\|[^:]\)\+:\%(\\.\|[^:]\)\+\zs:.*', '', '')]
-    if filereadable(g:outfile)
-        call extend(r, readfile(g:outfile, 'b'), 0)
-    endif
-    call writefile(r, g:outfile, 'b')
+    call WriteFile(substitute(v:exception,
+                \'Frawor:\%(\\.\|[^:]\)\+:\%(\\.\|[^:]\)\+\zs:.*', '', ''))
 endtry