comparison src/testdir/test_vim9_script.vim @ 19874:f92435f0f449 v8.2.0493

patch 8.2.0493: Vim9: some error messages not tested Commit: https://github.com/vim/vim/commit/e69f6d044c420d41dced9ba96a3b90f25788e39a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 1 22:11:01 2020 +0200 patch 8.2.0493: Vim9: some error messages not tested Problem: Vim9: some error messages not tested. Solution: Add more tests. Fix uncovered bugs.
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Apr 2020 22:15:04 +0200
parents 8a7bede7b138
children dd3c80122a0e
comparison
equal deleted inserted replaced
19873:b256cdad1dbf 19874:f92435f0f449
115 @a = 'areg' 115 @a = 'areg'
116 @a ..= 'add' 116 @a ..= 'add'
117 assert_equal('aregadd', @a) 117 assert_equal('aregadd', @a)
118 call CheckDefFailure(['@a += "more"'], 'E1013:') 118 call CheckDefFailure(['@a += "more"'], 'E1013:')
119 call CheckDefFailure(['@a += 123'], 'E1013:') 119 call CheckDefFailure(['@a += 123'], 'E1013:')
120
121 v:errmsg = 'none'
122 v:errmsg ..= 'again'
123 assert_equal('noneagain', v:errmsg)
124 call CheckDefFailure(['v:errmsg += "more"'], 'E1013:')
125 call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
126
127 " Test default values.
128 let thebool: bool
129 assert_equal(v:false, thebool)
130
131 let thenumber: number
132 assert_equal(0, thenumber)
133
134 if has('float')
135 let thefloat: float
136 assert_equal(0.0, thefloat)
137 endif
138
139 let thestring: string
140 assert_equal('', thestring)
141
142 let theblob: blob
143 assert_equal(0z, theblob)
144
145 let thefunc: func
146 assert_equal(test_null_function(), thefunc)
147
148 let thepartial: partial
149 assert_equal(test_null_partial(), thepartial)
150
151 let thelist: list<any>
152 assert_equal([], thelist)
153
154 let thedict: dict<any>
155 assert_equal({}, thedict)
156
157 let thejob: job
158 assert_equal(test_null_job(), thejob)
159
160 let thechannel: channel
161 assert_equal(test_null_channel(), thechannel)
120 enddef 162 enddef
121 163
122 func Test_assignment_failure() 164 func Test_assignment_failure()
123 call CheckDefFailure(['let var=234'], 'E1004:') 165 call CheckDefFailure(['let var=234'], 'E1004:')
124 call CheckDefFailure(['let var =234'], 'E1004:') 166 call CheckDefFailure(['let var =234'], 'E1004:')
127 call CheckDefFailure(['let true = 1'], 'E1034:') 169 call CheckDefFailure(['let true = 1'], 'E1034:')
128 call CheckDefFailure(['let false = 1'], 'E1034:') 170 call CheckDefFailure(['let false = 1'], 'E1034:')
129 171
130 call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:') 172 call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:')
131 173
174 call CheckDefFailure(['let somevar'], "E1022:")
132 call CheckDefFailure(['let &option'], 'E1052:') 175 call CheckDefFailure(['let &option'], 'E1052:')
133 call CheckDefFailure(['&g:option = 5'], 'E113:') 176 call CheckDefFailure(['&g:option = 5'], 'E113:')
134 177
135 call CheckDefFailure(['let $VAR = 5'], 'E1065:') 178 call CheckDefFailure(['let $VAR = 5'], 'E1065:')
136 179