Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 20089:7fc5d62fe2a5 v8.2.0600
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Commit: https://github.com/vim/vim/commit/d3aac2917db38f8590648ee76eebfa178fc4c069
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 19 14:32:17 2020 +0200
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Problem: Vim9: cannot read or write w:, t: and b: variables.
Solution: Implement load and store for w:, t: and b: variables.
(closes #5950)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Apr 2020 14:45:03 +0200 |
parents | 336483164ca6 |
children | a64c16ff98b8 |
comparison
equal
deleted
inserted
replaced
20088:004788f1261e | 20089:7fc5d62fe2a5 |
---|---|
133 assert_equal('noneagain', v:errmsg) | 133 assert_equal('noneagain', v:errmsg) |
134 call CheckDefFailure(['v:errmsg += "more"'], 'E1013:') | 134 call CheckDefFailure(['v:errmsg += "more"'], 'E1013:') |
135 call CheckDefFailure(['v:errmsg += 123'], 'E1013:') | 135 call CheckDefFailure(['v:errmsg += 123'], 'E1013:') |
136 enddef | 136 enddef |
137 | 137 |
138 def Test_assignment_local() | |
139 " Test in a separated file in order not to the current buffer/window/tab is | |
140 " changed. | |
141 let script_lines: list<string> =<< trim END | |
142 let b:existing = 'yes' | |
143 let w:existing = 'yes' | |
144 let t:existing = 'yes' | |
145 | |
146 def Test_assignment_local_internal() | |
147 b:newvar = 'new' | |
148 assert_equal('new', b:newvar) | |
149 assert_equal('yes', b:existing) | |
150 b:existing = 'no' | |
151 assert_equal('no', b:existing) | |
152 | |
153 w:newvar = 'new' | |
154 assert_equal('new', w:newvar) | |
155 assert_equal('yes', w:existing) | |
156 w:existing = 'no' | |
157 assert_equal('no', w:existing) | |
158 | |
159 t:newvar = 'new' | |
160 assert_equal('new', t:newvar) | |
161 assert_equal('yes', t:existing) | |
162 t:existing = 'no' | |
163 assert_equal('no', t:existing) | |
164 enddef | |
165 call Test_assignment_local_internal() | |
166 END | |
167 call CheckScriptSuccess(script_lines) | |
168 enddef | |
169 | |
138 def Test_assignment_default() | 170 def Test_assignment_default() |
139 | 171 |
140 # Test default values. | 172 # Test default values. |
141 let thebool: bool | 173 let thebool: bool |
142 assert_equal(v:false, thebool) | 174 assert_equal(v:false, thebool) |
199 | 231 |
200 call CheckDefFailure(['let @~ = 5'], 'E354:') | 232 call CheckDefFailure(['let @~ = 5'], 'E354:') |
201 call CheckDefFailure(['let @a = 5'], 'E1066:') | 233 call CheckDefFailure(['let @a = 5'], 'E1066:') |
202 | 234 |
203 call CheckDefFailure(['let g:var = 5'], 'E1016:') | 235 call CheckDefFailure(['let g:var = 5'], 'E1016:') |
236 call CheckDefFailure(['let w:var = 5'], 'E1079:') | |
237 call CheckDefFailure(['let b:var = 5'], 'E1078:') | |
238 call CheckDefFailure(['let t:var = 5'], 'E1080:') | |
204 | 239 |
205 call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:') | 240 call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:') |
206 call CheckDefFailure(['let xnr += 4'], 'E1020:') | 241 call CheckDefFailure(['let xnr += 4'], 'E1020:') |
207 | 242 |
208 call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef'], 'E1050:') | 243 call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef'], 'E1050:') |
244 " TODO: implement this error | |
245 "call CheckScriptFailure(['vim9script', 'let svar = 123', 'unlet svar'], 'E1050:') | |
246 "call CheckScriptFailure(['vim9script', 'let svar = 123', 'unlet s:svar'], 'E1050:') | |
209 | 247 |
210 call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>') | 248 call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>') |
211 call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>') | 249 call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>') |
212 | 250 |
213 call CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>') | 251 call CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>') |