625
|
1 " Vim script for exists() function test
|
|
2 " Script-local variables are checked here
|
|
3
|
|
4 " Existing script-local variable
|
|
5 let s:script_var = 1
|
|
6 echo 's:script_var: 1'
|
|
7 if exists('s:script_var')
|
|
8 echo "OK"
|
|
9 else
|
|
10 echo "FAILED"
|
|
11 endif
|
|
12
|
|
13 " Non-existing script-local variable
|
|
14 unlet s:script_var
|
|
15 echo 's:script_var: 0'
|
|
16 if !exists('s:script_var')
|
|
17 echo "OK"
|
|
18 else
|
|
19 echo "FAILED"
|
|
20 endif
|
|
21
|
|
22 " Existing script-local list
|
|
23 let s:script_list = ["blue", "orange"]
|
|
24 echo 's:script_list: 1'
|
|
25 if exists('s:script_list')
|
|
26 echo "OK"
|
|
27 else
|
|
28 echo "FAILED"
|
|
29 endif
|
|
30
|
|
31 " Non-existing script-local list
|
|
32 unlet s:script_list
|
|
33 echo 's:script_list: 0'
|
|
34 if !exists('s:script_list')
|
|
35 echo "OK"
|
|
36 else
|
|
37 echo "FAILED"
|
|
38 endif
|
|
39
|
|
40 " Existing script-local dictionary
|
|
41 let s:script_dict = {"xcord":100, "ycord":2}
|
|
42 echo 's:script_dict: 1'
|
|
43 if exists('s:script_dict')
|
|
44 echo "OK"
|
|
45 else
|
|
46 echo "FAILED"
|
|
47 endif
|
|
48
|
|
49 " Non-existing script-local dictionary
|
|
50 unlet s:script_dict
|
|
51 echo 's:script_dict: 0'
|
|
52 if !exists('s:script_dict')
|
|
53 echo "OK"
|
|
54 else
|
|
55 echo "FAILED"
|
|
56 endif
|
|
57
|
|
58 " Existing script curly-brace variable
|
|
59 let str = "script"
|
|
60 let s:curly_{str}_var = 1
|
|
61 echo 's:curly_' . str . '_var: 1'
|
|
62 if exists('s:curly_{str}_var')
|
|
63 echo "OK"
|
|
64 else
|
|
65 echo "FAILED"
|
|
66 endif
|
|
67
|
|
68 " Non-existing script-local curly-brace variable
|
|
69 unlet s:curly_{str}_var
|
|
70 echo 's:curly_' . str . '_var: 0'
|
|
71 if !exists('s:curly_{str}_var')
|
|
72 echo "OK"
|
|
73 else
|
|
74 echo "FAILED"
|
|
75 endif
|
|
76
|
|
77 " Existing script-local function
|
|
78 function! s:my_script_func()
|
|
79 endfunction
|
|
80
|
|
81 echo '*s:my_script_func: 1'
|
|
82 if exists('*s:my_script_func')
|
|
83 echo "OK"
|
|
84 else
|
|
85 echo "FAILED"
|
|
86 endif
|
|
87
|
|
88 " Non-existing script-local function
|
|
89 delfunction s:my_script_func
|
|
90
|
|
91 echo '*s:my_script_func: 0'
|
|
92 if !exists('*s:my_script_func')
|
|
93 echo "OK"
|
|
94 else
|
|
95 echo "FAILED"
|
|
96 endif
|
1405
|
97 unlet str
|
625
|
98
|