Mercurial > vim
annotate src/testdir/test_eval.in @ 15474:79e3dcc5aa50 v8.1.0745
patch 8.1.0745: compiler warnings for signed/unsigned string
commit https://github.com/vim/vim/commit/99b1272f88a493421d438e5e184003763efb4b8f
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 14 20:16:40 2019 +0100
patch 8.1.0745: compiler warnings for signed/unsigned string
Problem: Compiler warnings for signed/unsigned string.
Solution: Remove type casts. (John Marriott)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Jan 2019 20:30:06 +0100 |
parents | 30f9a62f5f51 |
children | 0da696bd7352 |
rev | line source |
---|---|
5798 | 1 Test for various eval features. vim: set ft=vim : |
2 | |
13096
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
7611
diff
changeset
|
3 NOTE: Do not add more here, use new style test test_eval_stuff.vim |
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
7611
diff
changeset
|
4 |
6543 | 5 Note: system clipboard is saved, changed and restored. |
5796 | 6 |
6563 | 7 clipboard contents |
8 something else | |
9 | |
5796 | 10 STARTTEST |
11 :so small.vim | |
5798 | 12 :set encoding=latin1 |
13 :set noswapfile | |
14 :lang C | |
15 :fun AppendRegContents(reg) | |
6563 | 16 call AppendRegParts(a:reg, getregtype(a:reg), getreg(a:reg), string(getreg(a:reg, 0, 1)), getreg(a:reg, 1), string(getreg(a:reg, 1, 1))) |
17 :endfun | |
18 :fun AppendRegParts(reg, type, cont, strcont, cont1, strcont1) | |
19 call append('$', printf('%s: type %s; value: %s (%s), expr: %s (%s)', a:reg, a:type, a:cont, a:strcont, a:cont1, a:strcont1)) | |
5798 | 20 endfun |
21 :command -nargs=? AR :call AppendRegContents(<q-args>) | |
22 :fun SetReg(...) | |
23 call call('setreg', a:000) | |
24 call append('$', printf('{{{2 setreg(%s)', string(a:000)[1:-2])) | |
25 call AppendRegContents(a:1) | |
26 if a:1 isnot# '=' | |
27 execute "silent normal! Go==\n==\e\"".a:1."P" | |
28 endif | |
29 endfun | |
30 :fun ErrExe(str) | |
31 call append('$', 'Executing '.a:str) | |
32 try | |
33 execute a:str | |
34 catch | |
35 $put =v:exception | |
36 endtry | |
37 endfun | |
38 :fun Test() | |
39 $put ='{{{1 let tests' | |
40 let @" = 'abc' | |
41 AR " | |
42 let @" = "abc\n" | |
43 AR " | |
44 let @" = "abc\<C-m>" | |
45 AR " | |
46 let @= = '"abc"' | |
47 AR = | |
48 | |
49 $put ='{{{1 Basic setreg tests' | |
50 call SetReg('a', 'abcA', 'c') | |
51 call SetReg('b', 'abcB', 'v') | |
52 call SetReg('c', 'abcC', 'l') | |
53 call SetReg('d', 'abcD', 'V') | |
54 call SetReg('e', 'abcE', 'b') | |
55 call SetReg('f', 'abcF', "\<C-v>") | |
56 call SetReg('g', 'abcG', 'b10') | |
57 call SetReg('h', 'abcH', "\<C-v>10") | |
58 call SetReg('I', 'abcI') | |
59 | |
60 $put ='{{{1 Appending single lines with setreg()' | |
61 call SetReg('A', 'abcAc', 'c') | |
62 call SetReg('A', 'abcAl', 'l') | |
63 call SetReg('A', 'abcAc2','c') | |
64 call SetReg('b', 'abcBc', 'ca') | |
65 call SetReg('b', 'abcBb', 'ba') | |
66 call SetReg('b', 'abcBc2','ca') | |
67 call SetReg('b', 'abcBb2','b50a') | |
68 | |
69 call SetReg('C', 'abcCl', 'l') | |
70 call SetReg('C', 'abcCc', 'c') | |
71 call SetReg('D', 'abcDb', 'b') | |
72 | |
73 call SetReg('E', 'abcEb', 'b') | |
74 call SetReg('E', 'abcEl', 'l') | |
75 call SetReg('F', 'abcFc', 'c') | |
76 | |
77 $put ='{{{1 Appending NL with setreg()' | |
78 call setreg('a', 'abcA2', 'c') | |
79 call setreg('b', 'abcB2', 'v') | |
80 call setreg('c', 'abcC2', 'l') | |
81 call setreg('d', 'abcD2', 'V') | |
82 call setreg('e', 'abcE2', 'b') | |
83 call setreg('f', 'abcF2', "\<C-v>") | |
84 call setreg('g', 'abcG2', 'b10') | |
85 call setreg('h', 'abcH2', "\<C-v>10") | |
86 call setreg('I', 'abcI2') | |
87 | |
88 call SetReg('A', "\n") | |
89 call SetReg('B', "\n", 'c') | |
90 call SetReg('C', "\n") | |
91 call SetReg('D', "\n", 'l') | |
92 call SetReg('E', "\n") | |
93 call SetReg('F', "\n", 'b') | |
94 | |
95 $put ='{{{1 Setting lists with setreg()' | |
96 call SetReg('a', ['abcA3'], 'c') | |
97 call SetReg('b', ['abcB3'], 'l') | |
98 call SetReg('c', ['abcC3'], 'b') | |
99 call SetReg('d', ['abcD3']) | |
5810 | 100 call SetReg('e', [1, 2, 'abc', 3]) |
101 call SetReg('f', [1, 2, 3]) | |
5798 | 102 |
103 $put ='{{{1 Appending lists with setreg()' | |
104 call SetReg('A', ['abcA3c'], 'c') | |
105 call SetReg('b', ['abcB3l'], 'la') | |
106 call SetReg('C', ['abcC3b'], 'lb') | |
107 call SetReg('D', ['abcD32']) | |
108 | |
109 call SetReg('A', ['abcA32']) | |
110 call SetReg('B', ['abcB3c'], 'c') | |
111 call SetReg('C', ['abcC3l'], 'l') | |
112 call SetReg('D', ['abcD3b'], 'b') | |
113 | |
114 $put ='{{{1 Appending lists with NL with setreg()' | |
115 call SetReg('A', ["\n", 'abcA3l2'], 'l') | |
116 call SetReg('B', ["\n", 'abcB3c2'], 'c') | |
117 call SetReg('C', ["\n", 'abcC3b2'], 'b') | |
118 call SetReg('D', ["\n", 'abcD3b50'],'b50') | |
119 | |
120 $put ='{{{1 Setting lists with NLs with setreg()' | |
121 call SetReg('a', ['abcA4-0', "\n", "abcA4-2\n", "\nabcA4-3", "abcA4-4\nabcA4-4-2"]) | |
122 call SetReg('b', ['abcB4c-0', "\n", "abcB4c-2\n", "\nabcB4c-3", "abcB4c-4\nabcB4c-4-2"], 'c') | |
123 call SetReg('c', ['abcC4l-0', "\n", "abcC4l-2\n", "\nabcC4l-3", "abcC4l-4\nabcC4l-4-2"], 'l') | |
124 call SetReg('d', ['abcD4b-0', "\n", "abcD4b-2\n", "\nabcD4b-3", "abcD4b-4\nabcD4b-4-2"], 'b') | |
125 call SetReg('e', ['abcE4b10-0', "\n", "abcE4b10-2\n", "\nabcE4b10-3", "abcE4b10-4\nabcE4b10-4-2"], 'b10') | |
126 | |
127 $put ='{{{1 Search and expressions' | |
128 call SetReg('/', ['abc/']) | |
129 call SetReg('/', ["abc/\n"]) | |
130 call SetReg('=', ['"abc/"']) | |
131 call SetReg('=', ["\"abc/\n\""]) | |
6543 | 132 $put ='{{{1 System clipboard' |
6563 | 133 if has('clipboard') |
6543 | 134 " Save and restore system clipboard. |
135 " If no connection to X-Server is possible, test should succeed. | |
6571 | 136 let _clipreg = ['*', getreg('*'), getregtype('*')] |
6563 | 137 let _clipopt = &cb |
6571 | 138 let &cb='unnamed' |
13096
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
7611
diff
changeset
|
139 7y |
6571 | 140 AR * |
6563 | 141 tabdo :windo :echo "hi" |
13096
30f9a62f5f51
patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
7611
diff
changeset
|
142 8y |
6571 | 143 AR * |
6563 | 144 let &cb=_clipopt |
145 call call('setreg', _clipreg) | |
146 else | |
6571 | 147 call AppendRegParts('*', 'V', "clipboard contents\n", "['clipboard contents']", "clipboard contents\n", "['clipboard contents']") |
148 call AppendRegParts('*', 'V', "something else\n", "['something else']", "something else\n", "['something else']") | |
6563 | 149 endif |
5798 | 150 $put ='{{{1 Errors' |
151 call ErrExe('call setreg()') | |
152 call ErrExe('call setreg(1)') | |
153 call ErrExe('call setreg(1, 2, 3, 4)') | |
154 call ErrExe('call setreg([], 2)') | |
155 call ErrExe('call setreg(1, {})') | |
156 call ErrExe('call setreg(1, 2, [])') | |
5810 | 157 call ErrExe('call setreg("/", ["1", "2"])') |
158 call ErrExe('call setreg("=", ["1", "2"])') | |
5798 | 159 call ErrExe('call setreg(1, ["", "", [], ""])') |
160 endfun | |
5796 | 161 :" |
5798 | 162 :call Test() |
5796 | 163 :" |
5798 | 164 :delfunction SetReg |
165 :delfunction AppendRegContents | |
166 :delfunction ErrExe | |
167 :delfunction Test | |
168 :delcommand AR | |
169 :call garbagecollect(1) | |
170 :" | |
5842 | 171 :" function name not starting with capital |
172 :try | |
173 :func! g:test() | |
174 :echo "test" | |
175 :endfunc | |
176 :catch | |
177 :$put =v:exception | |
178 :endtry | |
179 :" | |
5834 | 180 :" function name includes a colon |
181 :try | |
5842 | 182 :func! b:test() |
5834 | 183 :echo "test" |
184 :endfunc | |
185 :catch | |
186 :$put =v:exception | |
187 :endtry | |
188 :" | |
189 :" function name folowed by # | |
190 :try | |
191 :func! test2() "# | |
192 :echo "test2" | |
193 :endfunc | |
194 :catch | |
195 :$put =v:exception | |
196 :endtry | |
197 :" | |
5842 | 198 :" function name starting with/without "g:", buffer-local funcref. |
5844 | 199 :function! g:Foo(n) |
200 : $put ='called Foo(' . a:n . ')' | |
5842 | 201 :endfunction |
202 :let b:my_func = function('Foo') | |
5844 | 203 :call b:my_func(1) |
204 :echo g:Foo(2) | |
205 :echo Foo(3) | |
5842 | 206 :" |
5850 | 207 :" script-local function used in Funcref must exist. |
208 :so test_eval_func.vim | |
209 :" | |
5858 | 210 :" Using $ instead of '$' must give an error |
211 :try | |
212 : call append($, 'foobar') | |
213 :catch | |
214 :$put =v:exception | |
215 :endtry | |
216 :" | |
5944 | 217 :$put ='{{{1 getcurpos/setpos' |
5938 | 218 /^012345678 |
5944 | 219 6l:let sp = getcurpos() |
5938 | 220 0:call setpos('.', sp) |
221 jyl:$put | |
222 :" | |
7611
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
223 :" substring and variable name |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
224 :let str = 'abcdef' |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
225 :let n = 3 |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
226 :$put =str[n:] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
227 :$put =str[:n] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
228 :$put =str[n:n] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
229 :unlet n |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
230 :let nn = 3 |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
231 :$put =str[nn:] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
232 :$put =str[:nn] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
233 :$put =str[nn:nn] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
234 :unlet nn |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
235 :let b:nn = 4 |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
236 :$put =str[b:nn:] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
237 :$put =str[:b:nn] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
238 :$put =str[b:nn:b:nn] |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
239 :unlet b:nn |
9c420b8db435
commit https://github.com/vim/vim/commit/9bbf63dbf8286fadc0cd6b3428010abb67b1b64d
Christian Brabandt <cb@256bit.org>
parents:
6571
diff
changeset
|
240 :" |
5798 | 241 :/^start:/+1,$wq! test.out |
242 :" vim: et ts=4 isk-=\: fmr=???,??? | |
243 :call getchar() | |
5796 | 244 ENDTEST |
245 | |
5938 | 246 012345678 |
247 012345678 | |
248 | |
5798 | 249 start: |