Mercurial > vim
comparison src/testdir/test_vim9_cmd.vim @ 24488:f293bb501b30 v8.2.2784
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Commit: https://github.com/vim/vim/commit/4c13721482d7786f92f5a56e43b0f5c499264b7e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 19 16:48:48 2021 +0200
patch 8.2.2784: Vim9: cannot use \=expr in :substitute
Problem: Vim9: cannot use \=expr in :substitute.
Solution: Compile the expression into instructions and execute them when
invoked.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 19 Apr 2021 17:00:04 +0200 |
parents | d0e86f1b34e7 |
children | 08050e45bd06 |
comparison
equal
deleted
inserted
replaced
24487:2bcec3ba6a08 | 24488:f293bb501b30 |
---|---|
1170 unlockvar theList | 1170 unlockvar theList |
1171 END | 1171 END |
1172 CheckDefFailure(lines, 'E1178', 2) | 1172 CheckDefFailure(lines, 'E1178', 2) |
1173 enddef | 1173 enddef |
1174 | 1174 |
1175 def Test_substitute_expr() | |
1176 var to = 'repl' | |
1177 new | |
1178 setline(1, 'one from two') | |
1179 s/from/\=to | |
1180 assert_equal('one repl two', getline(1)) | |
1181 | |
1182 setline(1, 'one from two') | |
1183 s/from/\=to .. '_x' | |
1184 assert_equal('one repl_x two', getline(1)) | |
1185 | |
1186 setline(1, 'one from two from three') | |
1187 var also = 'also' | |
1188 s/from/\=to .. '_' .. also/g#e | |
1189 assert_equal('one repl_also two repl_also three', getline(1)) | |
1190 | |
1191 CheckDefFailure(['s/from/\="x")/'], 'E488:') | |
1192 CheckDefFailure(['s/from/\="x"/9'], 'E488:') | |
1193 | |
1194 bwipe! | |
1195 enddef | |
1196 | |
1175 | 1197 |
1176 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 1198 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |