annotate src/testdir/test34.in @ 1894:afb740b5dfab v7.2.191

updated for version 7.2-191
author vimboss
date Tue, 26 May 2009 20:59:55 +0000
parents b63792dadc23
children cd6e6876308e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
856
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
1 Test for user functions.
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
2 Also test an <expr> mapping calling a function.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 STARTTEST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 :so small.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 :function Table(title, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 : let ret = a:title
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 : let idx = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 : while idx <= a:0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 : exe "let ret = ret . a:" . idx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 : let idx = idx + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 : endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 : return ret
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 :endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 :function Compute(n1, n2, divname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 : if a:n2 == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 : return "fail"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 : endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 : exe "let g:" . a:divname . " = ". a:n1 / a:n2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 : return "ok"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 :endfunction
856
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
22 :func Expr1()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
23 : normal! v
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
24 : return "111"
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
25 :endfunc
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
26 :func Expr2()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
27 : call search('XX', 'b')
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
28 : return "222"
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
29 :endfunc
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
30 :func ListItem()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
31 : let g:counter += 1
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
32 : return g:counter . '. '
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
33 :endfunc
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
34 :func ListReset()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
35 : let g:counter = 0
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
36 : return ''
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
37 :endfunc
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
38 :let counter = 0
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
39 :inoremap <expr> ( ListItem()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
40 :inoremap <expr> [ ListReset()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
41 :imap <expr> + Expr1()
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
42 :imap <expr> * Expr2()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 :let retval = "nop"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 /^here
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 C=Table("xxx", 4, "asdf")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 =Compute(45, 0, "retval")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 =retval
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 =Compute(45, 5, "retval")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 =retval
856
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
50
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
51 XX+-XX
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
52 ---*---
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
53 (one
8cd729851562 updated for version 7.0g
vimboss
parents: 7
diff changeset
54 (two
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
55 [(one again:$-5,$w! test.out
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
56 :delfunc Table
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
57 :delfunc Compute
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
58 :delfunc Expr1
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
59 :delfunc Expr2
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
60 :delfunc ListItem
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
61 :delfunc ListReset
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
62 :unlet retval counter
b63792dadc23 updated for version 7.1-120
vimboss
parents: 856
diff changeset
63 :q!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 ENDTEST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 here