Mercurial > vim
annotate src/testdir/test_viml.vim @ 7393:467b7c511585 v7.4.1001
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 30 15:59:25 2015 +0100
patch 7.4.1001
Problem: test_viml isn't run.
Solution: Include change in makefile.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 30 Dec 2015 16:00:05 +0100 |
parents | |
children | 4ff843da79fd |
rev | line source |
---|---|
7393
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test various aspects of the Vim language. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " This was formerly in test49. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " Test environment {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 com! XpathINIT let g:Xpath = '' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 com! -nargs=1 -bar Xpath let g:Xpath = g:Xpath . <args> |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " Append a message to the "messages" file |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 func! Xout(text) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 split messages |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 $put =a:text |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 wq |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfunc |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 com! -nargs=1 Xout call Xout(<args>) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 " MakeScript() - Make a script file from a function. {{{2 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 " Create a script that consists of the body of the function a:funcname. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " Replace any ":return" by a ":finish", any argument variable by a global |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " variable, and and every ":call" by a ":source" for the next following argument |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " in the variable argument list. This function is useful if similar tests are |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " to be made for a ":return" from a function call or a ":finish" in a script |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " file. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 function! MakeScript(funcname, ...) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 let script = tempname() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 execute "redir! >" . script |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 execute "function" a:funcname |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 redir END |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 execute "edit" script |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 " Delete the "function" and the "endfunction" lines. Do not include the |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 " word "function" in the pattern since it might be translated if LANG is |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 " set. When MakeScript() is being debugged, this deletes also the debugging |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " output of its line 3 and 4. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 exec '1,/.*' . a:funcname . '(.*)/d' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 /^\d*\s*endfunction\>/,$d |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 %s/^\d*//e |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 %s/return/finish/e |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 %s/\<a:\(\h\w*\)/g:\1/ge |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 normal gg0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 let cnt = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 while search('\<call\s*\%(\u\|s:\)\w*\s*(.*)', 'W') > 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 let cnt = cnt + 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 s/\<call\s*\%(\u\|s:\)\w*\s*(.*)/\='source ' . a:{cnt}/ |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 g/^\s*$/d |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 write |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 bwipeout |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 return script |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 " ExecAsScript - Source a temporary script made from a function. {{{2 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 " Make a temporary script file from the function a:funcname, ":source" it, and |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 " delete it afterwards. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 function! ExecAsScript(funcname) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 " Make a script from the function passed as argument. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let script = MakeScript(a:funcname) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 " Source and delete the script. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 exec "source" script |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 call delete(script) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 " Test 1: :endwhile in function {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 " Detect if a broken loop is (incorrectly) reactivated by the |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 " :endwhile. Use a :return to prevent an endless loop, and make |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 " this test first to get a meaningful result on an error before other |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 " tests will hang. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 function! T1_F() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 Xpath 'a' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 let first = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 while 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 Xpath 'b' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 if first |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 Xpath 'c' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 let first = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 break |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 else |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 Xpath 'd' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 return |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 function! T1_G() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 Xpath 'h' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 let first = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 while 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 Xpath 'i' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 if first |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 Xpath 'j' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 let first = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 break |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 else |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 Xpath 'k' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 return |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 if 1 " unmatched :if |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 func Test_endwhile_function() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 call T1_F() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 Xpath 'F' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 try |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 call T1_G() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 catch |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 " Catch missing :endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 call assert_true(v:exception =~ 'E171') |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 Xpath 'x' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 endtry |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 Xpath 'G' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 call assert_equal('abcFhijxG', g:Xpath) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 endfunc |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 " Test 2: :endwhile in script {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 " Detect if a broken loop is (incorrectly) reactivated by the |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 " :endwhile. Use a :finish to prevent an endless loop, and place |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 " this test before others that might hang to get a meaningful result |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 " on an error. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 " This test executes the bodies of the functions T1_F and T1_G from |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 " the previous test as script files (:return replaced by :finish). |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 func Test_endwhile_script() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 ExecAsScript T1_F |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 Xpath 'F' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 try |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 ExecAsScript T1_G |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 catch |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 " Catch missing :endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 call assert_true(v:exception =~ 'E171') |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 Xpath 'x' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 endtry |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 Xpath 'G' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 call assert_equal('abcFhijxG', g:Xpath) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 endfunc |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 " Test 3: :if, :elseif, :while, :continue, :break {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 function Test_if_while() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 if 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 Xpath 'a' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 let loops = 3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 while loops > -1 " main loop: loops == 3, 2, 1 (which breaks) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 if loops <= 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 let break_err = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 let loops = -1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 else |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 Xpath 'b' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 if (loops == 2) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 while loops == 2 " dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 Xpath 'c' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 let loops = loops - 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 continue " stop dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 Xpath 'd' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 continue " continue main loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 Xpath 'e' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 elseif (loops == 1) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 let p = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 while p " dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 Xpath 'f' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 let p = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 break " break dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 Xpath 'g' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 Xpath 'h' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 unlet p |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 break " break main loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 Xpath 'i' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 if (loops > 0) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 Xpath 'j' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 while loops == 3 " dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 let loops = loops - 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 endwhile " end dummy loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 endwhile " end main loop |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 Xpath 'k' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 else |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 Xpath 'l' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 Xpath 'm' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 if exists("break_err") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 Xpath 'm' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 unlet break_err |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 unlet loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 endfunc |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 " Test 4: :return {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 function! T4_F() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 if 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 Xpath 'a' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 let loops = 3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 while loops > 0 " 3: 2: 1: |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 Xpath 'b' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 if (loops == 2) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 Xpath 'c' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 return |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 Xpath 'd' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 Xpath 'e' . loops |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 let loops = loops - 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 Xpath 'f' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 else |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 Xpath 'g' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 function Test_return() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 call T4_F() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 Xpath '4' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 call assert_equal('ab3e3b2c24', g:Xpath) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 " Test 5: :finish {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 " This test executes the body of the function T4_F from the previous |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 " test as a script file (:return replaced by :finish). |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 function Test_finish() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 ExecAsScript T4_F |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 Xpath '5' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 call assert_equal('ab3e3b2c25', g:Xpath) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
265 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 " Test 6: Defining functions in :while loops {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 " Functions can be defined inside other functions. An inner function |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
273 " gets defined when the outer function is executed. Functions may |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 " also be defined inside while loops. Expressions in braces for |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 " defining the function name are allowed. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 " The functions are defined when sourcing the script, only the |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 " resulting path is checked in the test function. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 XpathINIT |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 " The command CALL collects the argument of all its invocations in "calls" |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 " when used from a function (that is, when the global variable "calls" needs |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 " the "g:" prefix). This is to check that the function code is skipped when |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 " the function is defined. For inner functions, do so only if the outer |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
287 " function is not being executed. |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 " |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
289 let calls = "" |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
290 com! -nargs=1 CALL |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
291 \ if !exists("calls") && !exists("outer") | |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
292 \ let g:calls = g:calls . <args> | |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
293 \ endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
294 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 let i = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 while i < 3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
297 let i = i + 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
298 if i == 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
299 Xpath 'a' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
300 function! F1(arg) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
301 CALL a:arg |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
302 let outer = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
303 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
304 let j = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 while j < 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 Xpath 'b' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 let j = j + 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
308 function! G1(arg) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
309 CALL a:arg |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 Xpath 'c' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 Xpath 'd' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 continue |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
317 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
318 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
319 Xpath 'e' . i |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
320 function! F{i}(i, arg) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
321 CALL a:arg |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
322 let outer = 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
323 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
324 if a:i == 3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
325 Xpath 'f' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 let k = 0 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
328 while k < 3 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
329 Xpath 'g' . k |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
330 let k = k + 1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 function! G{a:i}{k}(arg) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
332 CALL a:arg |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
333 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
334 Xpath 'h' . k |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
335 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
336 endfunction |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 Xpath 'i' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
339 endwhile |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
340 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 if exists("*G1") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
342 Xpath 'j' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
343 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 if exists("*F1") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 call F1("F1") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 if exists("*G1") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 call G1("G1") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
349 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
350 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
351 if exists("G21") || exists("G22") || exists("G23") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 Xpath 'k' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
354 if exists("*F2") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 call F2(2, "F2") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 if exists("*G21") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
357 call G21("G21") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
358 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
359 if exists("*G22") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 call G22("G22") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
361 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
362 if exists("*G23") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
363 call G23("G23") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
364 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
365 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
366 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
367 if exists("G31") || exists("G32") || exists("G33") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
368 Xpath 'l' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
369 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
370 if exists("*F3") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
371 call F3(3, "F3") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
372 if exists("*G31") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
373 call G31("G31") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
374 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
375 if exists("*G32") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
376 call G32("G32") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
377 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
378 if exists("*G33") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
379 call G33("G33") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
380 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
381 endif |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
382 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
383 Xpath 'm' |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
384 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
385 let g:test6_result = g:Xpath |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
386 let g:test6_calls = calls |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
387 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
388 unlet calls |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
389 delfunction F1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
390 delfunction G1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 delfunction F2 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
392 delfunction G21 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
393 delfunction G22 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
394 delfunction G23 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
395 delfunction G31 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
396 delfunction G32 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
397 delfunction G33 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
398 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
399 function Test_defining_functions() |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
400 call assert_equal('ade2ie3ibcg0h1g1h2g2h3fg0h1g1h2g2h3m', g:test6_result) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
401 call assert_equal('F1G1F2G21G22G23F3G31G32G33', g:test6_calls) |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
402 endfunc |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
403 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
404 "------------------------------------------------------------------------------- |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
405 " Modelines {{{1 |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
406 " vim: ts=8 sw=4 tw=80 fdm=marker |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
407 " vim: fdt=substitute(substitute(foldtext(),\ '\\%(^+--\\)\\@<=\\(\\s*\\)\\(.\\{-}\\)\:\ \\%(\"\ \\)\\=\\(Test\ \\d*\\)\:\\s*',\ '\\3\ (\\2)\:\ \\1',\ \"\"),\ '\\(Test\\s*\\)\\(\\d\\)\\D\\@=',\ '\\1\ \\2',\ "") |
467b7c511585
commit https://github.com/vim/vim/commit/f49e240c2def978247fa457aa105bb3024413f7d
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
408 "------------------------------------------------------------------------------- |