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