annotate src/testdir/test_exists.vim @ 35121:28f2e09012ac default tip

runtime(doc): Fix typos in help documents Commit: https://github.com/vim/vim/commit/53753f6a49253cdb3f98f6461d3de3b07ed67451 Author: h-east <h.east.727@gmail.com> Date: Sun May 5 18:42:31 2024 +0200 runtime(doc): Fix typos in help documents closes: https://github.com/vim/vim/issues/14720 Co-authored-by: Christian Clason <c.clason@uni-graz.at> Signed-off-by: h-east <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 05 May 2024 18:45:09 +0200
parents 2c0b18822510
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the exists() function
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19805
diff changeset
2
34427
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
3 import './vim9.vim' as v9
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
4
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_exists()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 augroup myagroup
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 autocmd! BufEnter *.my echo "myfile edited"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 autocmd! FuncUndefined UndefFun exec "fu UndefFun()\nendfu"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 augroup END
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 set rtp+=./sautest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " valid autocmd group
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(1, exists('#myagroup'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " valid autocmd group with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(0, exists('#myagroup+b'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " Valid autocmd group and event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal(1, exists('#myagroup#BufEnter'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 " Valid autocmd group, event and pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(1, exists('#myagroup#BufEnter#*.my'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 " Valid autocmd event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal(1, exists('#BufEnter'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " Valid autocmd event and pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(1, exists('#BufEnter#*.my'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " Non-existing autocmd group or event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal(0, exists('#xyzagroup'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " Non-existing autocmd group and valid autocmd event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal(0, exists('#xyzagroup#BufEnter'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 " Valid autocmd group and event with no matching pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_equal(0, exists('#myagroup#CmdwinEnter'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 " Valid autocmd group and non-existing autocmd event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal(0, exists('#myagroup#xyzacmd'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " Valid autocmd group and event and non-matching pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal(0, exists('#myagroup#BufEnter#xyzpat'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " Valid autocmd event and non-matching pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal(0, exists('#BufEnter#xyzpat'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " Empty autocmd group, event and pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal(0, exists('###'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " Empty autocmd group and event or empty event and pattern
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal(0, exists('##'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " Valid autocmd event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_equal(1, exists('##FileReadCmd'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 " Non-existing autocmd event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(0, exists('##MySpecialCmd'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " Existing and working option (long form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal(1, exists('&textwidth'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " Existing and working option (short form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(1, exists('&tw'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 " Existing and working option with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_equal(0, exists('&tw-'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " Global option
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(1, exists('&g:errorformat'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Local option
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call assert_equal(1, exists('&l:errorformat'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 " Negative form of existing and working option (long form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call assert_equal(0, exists('&nojoinspaces'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Negative form of existing and working option (short form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal(0, exists('&nojs'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 " Non-existing option
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_equal(0, exists('&myxyzoption'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 " Existing and working option (long form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(1, exists('+incsearch'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 " Existing and working option with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_equal(0, exists('+incsearch!1'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 " Existing and working option (short form)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 call assert_equal(1, exists('+is'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 " Existing option that is hidden.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call assert_equal(0, exists('+autoprint'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 " Existing environment variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 let $EDITOR_NAME = 'Vim Editor'
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call assert_equal(1, exists('$EDITOR_NAME'))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
74 if has('unix')
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
75 " ${name} environment variables are supported only on Unix-like systems
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
76 call assert_equal(1, exists('${VIM}'))
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
77 endif
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 " Non-existing environment variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 call assert_equal(0, exists('$NON_ENV_VAR'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 " Valid internal function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 call assert_equal(1, exists('*bufnr'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 " Valid internal function with ()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 call assert_equal(1, exists('*bufnr()'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 " Non-existing internal function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call assert_equal(0, exists('*myxyzfunc'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 " Valid internal function with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_equal(0, exists('*bufnr&6'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 " Valid user defined function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 call assert_equal(1, exists('*Test_exists'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 " Non-existing user defined function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 call assert_equal(0, exists('*MyxyzFunc'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 " Function that may be created by FuncUndefined event
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call assert_equal(0, exists('*UndefFun'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 " Function that may be created by script autoloading
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 call assert_equal(0, exists('*footest#F'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
98 call assert_equal(has('float'), exists('*acos'))
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
99 call assert_equal(1, exists('?acos'))
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
100 call assert_equal(has('win32'), exists('*debugbreak'))
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
101 call assert_equal(1, exists('?debugbreak'))
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
102
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 " Valid internal command (full match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 call assert_equal(2, exists(':edit'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 " Valid internal command (full match) with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 call assert_equal(0, exists(':edit/a'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 " Valid internal command (partial match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 call assert_equal(1, exists(':q'))
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 12616
diff changeset
109 " Valid internal command with a digit
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 12616
diff changeset
110 call assert_equal(2, exists(':2match'))
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 " Non-existing internal command
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call assert_equal(0, exists(':invalidcmd'))
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 12616
diff changeset
113 " Internal command with a count
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 12616
diff changeset
114 call assert_equal(0, exists(':3buffer'))
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 " User defined command (full match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 command! MyCmd :echo 'My command'
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 call assert_equal(2, exists(':MyCmd'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 " User defined command (partial match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 command! MyOtherCmd :echo 'Another command'
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 call assert_equal(3, exists(':My'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 " Command modifier
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 call assert_equal(2, exists(':rightbelow'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 " Non-existing user defined command (full match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 delcommand MyCmd
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 call assert_equal(0, exists(':MyCmd'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 " Non-existing user defined command (partial match)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 delcommand MyOtherCmd
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 call assert_equal(0, exists(':My'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 " Valid local variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 let local_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 call assert_equal(1, exists('local_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 " Valid local variable with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 call assert_equal(0, exists('local_var%n'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 " Non-existing local variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 unlet local_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 call assert_equal(0, exists('local_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 " Non-existing autoload variable that may be autoloaded
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 call assert_equal(0, exists('footest#x'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 " Valid local list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 let local_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 call assert_equal(1, exists('local_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 " Valid local list item
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 call assert_equal(1, exists('local_list[1]'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 " Valid local list item with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 call assert_equal(0, exists('local_list[1]+5'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 " Invalid local list item
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 call assert_equal(0, exists('local_list[2]'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 " Non-existing local list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 unlet local_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 call assert_equal(0, exists('local_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 " Valid local dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 let local_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 call assert_equal(1, exists('local_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 " Non-existing local dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 unlet local_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 call assert_equal(0, exists('local_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 " Existing local curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 let str = "local"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 let curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call assert_equal(1, exists('curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 " Non-existing local curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 unlet curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 call assert_equal(0, exists('curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 " Existing global variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 let g:global_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 call assert_equal(1, exists('g:global_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 " Existing global variable with garbage
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 call assert_equal(0, exists('g:global_var-n'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 " Non-existing global variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 unlet g:global_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 call assert_equal(0, exists('g:global_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 " Existing global list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 let g:global_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 call assert_equal(1, exists('g:global_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 " Non-existing global list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 unlet g:global_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 call assert_equal(0, exists('g:global_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 " Existing global dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 let g:global_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 call assert_equal(1, exists('g:global_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 " Non-existing global dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 unlet g:global_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 call assert_equal(0, exists('g:global_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 " Existing global curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 let str = "global"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 let g:curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 call assert_equal(1, exists('g:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 " Non-existing global curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 unlet g:curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 call assert_equal(0, exists('g:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 " Existing window variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 let w:window_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 call assert_equal(1, exists('w:window_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 " Non-existing window variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 unlet w:window_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 call assert_equal(0, exists('w:window_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 " Existing window list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 let w:window_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 call assert_equal(1, exists('w:window_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 " Non-existing window list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 unlet w:window_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 call assert_equal(0, exists('w:window_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 " Existing window dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 let w:window_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 call assert_equal(1, exists('w:window_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 " Non-existing window dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 unlet w:window_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 call assert_equal(0, exists('w:window_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 " Existing window curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 let str = "window"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 let w:curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 call assert_equal(1, exists('w:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 " Non-existing window curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 unlet w:curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 call assert_equal(0, exists('w:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 " Existing tab variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 let t:tab_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 call assert_equal(1, exists('t:tab_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 " Non-existing tab variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 unlet t:tab_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 call assert_equal(0, exists('t:tab_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 " Existing tab list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 let t:tab_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 call assert_equal(1, exists('t:tab_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 " Non-existing tab list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 unlet t:tab_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 call assert_equal(0, exists('t:tab_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 " Existing tab dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 let t:tab_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 call assert_equal(1, exists('t:tab_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 " Non-existing tab dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 unlet t:tab_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 call assert_equal(0, exists('t:tab_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 " Existing tab curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 let str = "tab"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 let t:curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 call assert_equal(1, exists('t:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 " Non-existing tab curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 unlet t:curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 call assert_equal(0, exists('t:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 " Existing buffer variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 let b:buffer_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 call assert_equal(1, exists('b:buffer_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 " Non-existing buffer variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 unlet b:buffer_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 call assert_equal(0, exists('b:buffer_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 " Existing buffer list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 let b:buffer_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 call assert_equal(1, exists('b:buffer_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 " Non-existing buffer list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 unlet b:buffer_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 call assert_equal(0, exists('b:buffer_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 " Existing buffer dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 let b:buffer_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 call assert_equal(1, exists('b:buffer_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 " Non-existing buffer dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 unlet b:buffer_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 call assert_equal(0, exists('b:buffer_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 " Existing buffer curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 let str = "buffer"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 let b:curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 call assert_equal(1, exists('b:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 " Non-existing buffer curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 unlet b:curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 call assert_equal(0, exists('b:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 " Existing Vim internal variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 call assert_equal(1, exists('v:version'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 " Non-existing Vim internal variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 call assert_equal(0, exists('v:non_exists_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 " Existing script-local variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 let s:script_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 call assert_equal(1, exists('s:script_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 " Non-existing script-local variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 unlet s:script_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 call assert_equal(0, exists('s:script_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 " Existing script-local list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 let s:script_list = ["blue", "orange"]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 call assert_equal(1, exists('s:script_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 " Non-existing script-local list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 unlet s:script_list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 call assert_equal(0, exists('s:script_list'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 " Existing script-local dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 let s:script_dict = {"xcord":100, "ycord":2}
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 call assert_equal(1, exists('s:script_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 " Non-existing script-local dictionary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 unlet s:script_dict
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 call assert_equal(0, exists('s:script_dict'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 " Existing script curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 let str = "script"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 let s:curly_{str}_var = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 call assert_equal(1, exists('s:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 " Non-existing script-local curly-brace variable
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 unlet s:curly_{str}_var
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 call assert_equal(0, exists('s:curly_{str}_var'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 " Existing script-local function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 function! s:my_script_func()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 endfunction
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 echo '*s:my_script_func: 1'
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 call assert_equal(1, exists('*s:my_script_func'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 " Non-existing script-local function
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 delfunction s:my_script_func
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 call assert_equal(0, exists('*s:my_script_func'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320 unlet str
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 call assert_equal(1, g:footest#x)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 call assert_equal(0, footest#F())
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 call assert_equal(0, UndefFun())
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 endfunc
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 " exists() test for Function arguments
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 func FuncArg_Tests(func_arg, ...)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 call assert_equal(1, exists('a:func_arg'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 call assert_equal(0, exists('a:non_exists_arg'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 call assert_equal(1, exists('a:1'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 call assert_equal(0, exists('a:2'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 endfunc
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 func Test_exists_funcarg()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 call FuncArg_Tests("arg1", "arg2")
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 endfunc
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
338
34427
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
339 " Test for using exists() with class and object variables and methods.
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
340 func Test_exists_class_object()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
341 let lines =<< trim END
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
342 vim9script
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
343 class A
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
344 var var1: number = 10
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
345 static var var2: number = 10
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
346 static def Foo()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
347 enddef
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
348 def Bar()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
349 enddef
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
350 endclass
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
351
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
352 assert_equal(1, exists("A"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
353 var a = A.new()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
354 assert_equal(1, exists("a"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
355
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
356 assert_equal(1, exists("a.var1"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
357 assert_fails('exists("a.var2")', 'E1375: Class variable "var2" accessible only using class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
358 assert_fails('exists("a.var3")', 'E1326: Variable "var3" not found in object "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
359 assert_equal(1, exists("A.var2"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
360 assert_fails('exists("A.var1")', 'E1376: Object variable "var1" accessible only using class "A" object')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
361 assert_fails('exists("A.var3")', 'E1337: Class variable "var3" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
362
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
363 assert_equal(1, exists("a.Bar"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
364 assert_fails('exists("a.Barz")', 'E1326: Variable "Barz" not found in object "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
365 assert_fails('exists("a.Foo")', 'E1326: Variable "Foo" not found in object "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
366 assert_equal(1, exists("A.Foo"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
367 assert_fails('exists("A.Bar")', 'E1337: Class variable "Bar" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
368 assert_fails('exists("A.Barz")', 'E1337: Class variable "Barz" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
369
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
370 def Baz()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
371 assert_equal(1, exists("A"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
372 var aa = A.new()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
373 assert_equal(1, exists("A.var2"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
374 assert_fails('exists("A.var1")', 'E1376: Object variable "var1" accessible only using class "A" object')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
375 assert_fails('exists("A.var3")', 'E1337: Class variable "var3" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
376
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
377 assert_equal(1, exists("A.Foo"))
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
378 assert_fails('exists("A.Bar")', 'E1337: Class variable "Bar" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
379 assert_fails('exists("A.Barz")', 'E1337: Class variable "Barz" not found in class "A"')
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
380 enddef
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
381 Baz()
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
382 END
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
383 call v9.CheckSourceSuccess(lines)
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
384 endfunc
2c0b18822510 patch 9.1.0136: Vim9: need more test for exists() methods
Christian Brabandt <cb@256bit.org>
parents: 21765
diff changeset
385
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
386 " vim: shiftwidth=2 sts=2 expandtab