Mercurial > vim
comparison src/testdir/test_vim9_assign.vim @ 23297:40f1d3f0c53e v8.2.2194
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Commit: https://github.com/vim/vim/commit/89b474dd4f0de878b4c48eeb9e223f0c22ee1442
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 22 21:19:39 2020 +0100
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Problem: Vim9: cannot use :const or :final at the script level.
Solution: Support using :const and :final. (closes https://github.com/vim/vim/issues/7526)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Dec 2020 21:30:04 +0100 |
parents | 00f7cd9b6033 |
children | 9c5275b1c763 |
comparison
equal
deleted
inserted
replaced
23296:c9123e2447bc | 23297:40f1d3f0c53e |
---|---|
1125 s:name = 'prefixed' | 1125 s:name = 'prefixed' |
1126 g:var_prefixed = s:name | 1126 g:var_prefixed = s:name |
1127 | 1127 |
1128 const FOO: number = 123 | 1128 const FOO: number = 123 |
1129 assert_equal(123, FOO) | 1129 assert_equal(123, FOO) |
1130 const FOOS = 'foos' | |
1131 assert_equal('foos', FOOS) | |
1132 final FLIST = [1] | |
1133 assert_equal([1], FLIST) | |
1134 FLIST[0] = 11 | |
1135 assert_equal([11], FLIST) | |
1136 | |
1137 const g:FOO: number = 321 | |
1138 assert_equal(321, g:FOO) | |
1139 const g:FOOS = 'gfoos' | |
1140 assert_equal('gfoos', g:FOOS) | |
1141 final g:FLIST = [2] | |
1142 assert_equal([2], g:FLIST) | |
1143 g:FLIST[0] = 22 | |
1144 assert_equal([22], g:FLIST) | |
1145 | |
1146 const w:FOO: number = 46 | |
1147 assert_equal(46, w:FOO) | |
1148 const w:FOOS = 'wfoos' | |
1149 assert_equal('wfoos', w:FOOS) | |
1150 final w:FLIST = [3] | |
1151 assert_equal([3], w:FLIST) | |
1152 w:FLIST[0] = 33 | |
1153 assert_equal([33], w:FLIST) | |
1130 | 1154 |
1131 var s:other: number | 1155 var s:other: number |
1132 other = 1234 | 1156 other = 1234 |
1133 g:other_var = other | 1157 g:other_var = other |
1134 | 1158 |
1148 | 1172 |
1149 unlet g:var_uninit | 1173 unlet g:var_uninit |
1150 unlet g:var_test | 1174 unlet g:var_test |
1151 unlet g:var_prefixed | 1175 unlet g:var_prefixed |
1152 unlet g:other_var | 1176 unlet g:other_var |
1177 unlet g:FOO | |
1178 unlet g:FOOS | |
1179 unlet g:FLIST | |
1180 unlet w:FOO | |
1181 unlet w:FOOS | |
1182 unlet w:FLIST | |
1153 enddef | 1183 enddef |
1154 | 1184 |
1155 def Test_var_declaration_fails() | 1185 def Test_var_declaration_fails() |
1156 var lines =<< trim END | 1186 var lines =<< trim END |
1157 vim9script | 1187 vim9script |
1158 final var: string | 1188 final var: string |
1159 END | 1189 END |
1160 CheckScriptFailure(lines, 'E1125:') | 1190 CheckScriptFailure(lines, 'E1125:') |
1191 | |
1192 lines =<< trim END | |
1193 vim9script | |
1194 const g:constvar = 'string' | |
1195 g:constvar = 'xx' | |
1196 END | |
1197 CheckScriptFailure(lines, 'E741:') | |
1198 unlet g:constvar | |
1199 | |
1200 lines =<< trim END | |
1201 vim9script | |
1202 final w:finalvar = [9] | |
1203 w:finalvar = [8] | |
1204 END | |
1205 CheckScriptFailure(lines, 'E1122:') | |
1206 unlet w:finalvar | |
1161 | 1207 |
1162 lines =<< trim END | 1208 lines =<< trim END |
1163 vim9script | 1209 vim9script |
1164 const var: string | 1210 const var: string |
1165 END | 1211 END |