Skip to content

Commit a629620

Browse files
committed
patch 8.2.1366: test 49 is old style
Problem: Test 49 is old style. Solution: Convert several tests to new style. (Yegappan Lakshmanan, closes #6629)
1 parent bb1b5e2 commit a629620

5 files changed

Lines changed: 1835 additions & 1752 deletions

File tree

src/testdir/script_util.vim

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
" Functions shared by the tests for Vim Script
2+
3+
" Commands to track the execution path of a script
4+
com! XpathINIT let g:Xpath = ''
5+
com! -nargs=1 -bar Xpath let g:Xpath ..= <args>
6+
com! XloopINIT let g:Xloop = 1
7+
com! -nargs=1 -bar Xloop let g:Xpath ..= <args> .. g:Xloop
8+
com! XloopNEXT let g:Xloop += 1
9+
10+
" MakeScript() - Make a script file from a function. {{{2
11+
"
12+
" Create a script that consists of the body of the function a:funcname.
13+
" Replace any ":return" by a ":finish", any argument variable by a global
14+
" variable, and every ":call" by a ":source" for the next following argument
15+
" in the variable argument list. This function is useful if similar tests are
16+
" to be made for a ":return" from a function call or a ":finish" in a script
17+
" file.
18+
func MakeScript(funcname, ...)
19+
let script = tempname()
20+
execute "redir! >" . script
21+
execute "function" a:funcname
22+
redir END
23+
execute "edit" script
24+
" Delete the "function" and the "endfunction" lines. Do not include the
25+
" word "function" in the pattern since it might be translated if LANG is
26+
" set. When MakeScript() is being debugged, this deletes also the debugging
27+
" output of its line 3 and 4.
28+
exec '1,/.*' . a:funcname . '(.*)/d'
29+
/^\d*\s*endfunction\>/,$d
30+
%s/^\d*//e
31+
%s/return/finish/e
32+
%s/\<a:\(\h\w*\)/g:\1/ge
33+
normal gg0
34+
let cnt = 0
35+
while search('\<call\s*\%(\u\|s:\)\w*\s*(.*)', 'W') > 0
36+
let cnt = cnt + 1
37+
s/\<call\s*\%(\u\|s:\)\w*\s*(.*)/\='source ' . a:{cnt}/
38+
endwhile
39+
g/^\s*$/d
40+
write
41+
bwipeout
42+
return script
43+
endfunc
44+
45+
" ExecAsScript - Source a temporary script made from a function. {{{2
46+
"
47+
" Make a temporary script file from the function a:funcname, ":source" it, and
48+
" delete it afterwards. However, if an exception is thrown the file may remain,
49+
" the caller should call DeleteTheScript() afterwards.
50+
let s:script_name = ''
51+
function! ExecAsScript(funcname)
52+
" Make a script from the function passed as argument.
53+
let s:script_name = MakeScript(a:funcname)
54+
55+
" Source and delete the script.
56+
exec "source" s:script_name
57+
call delete(s:script_name)
58+
let s:script_name = ''
59+
endfunction
60+
61+
function! DeleteTheScript()
62+
if s:script_name
63+
call delete(s:script_name)
64+
let s:script_name = ''
65+
endif
66+
endfunc
67+
68+
com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)
69+

src/testdir/test49.ok

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
Results of test49.vim:
2-
*** Test 18: OK (67224583)
3-
*** Test 19: OK (69275973)
4-
*** Test 20: OK (1874575085)
5-
*** Test 21: OK (147932225)
6-
*** Test 22: OK (4161)
7-
*** Test 23: OK (49)
8-
*** Test 24: OK (41)
9-
*** Test 27: OK (1996459)
10-
*** Test 28: OK (1996459)
11-
*** Test 29: OK (170428555)
12-
*** Test 30: OK (190905173)
13-
*** Test 31: OK (190905173)
14-
*** Test 34: OK (2146584868)
15-
*** Test 35: OK (2146584868)
16-
*** Test 36: OK (1071644672)
17-
*** Test 37: OK (1071644672)
18-
*** Test 38: OK (357908480)
19-
*** Test 39: OK (357908480)
20-
*** Test 40: OK (357908480)
21-
*** Test 49: OK (179000669)
22-
*** Test 50: OK (363550045)
232
*** Test 52: OK (1247112011)
243
*** Test 53: OK (131071)
254
*** Test 54: OK (2047)

0 commit comments

Comments
 (0)