Mercurial > vim
diff src/testdir/test_expr.vim @ 19969:b07672d13ff9 v8.2.0540
patch 8.2.0540: regexp and other code not tested
Commit: https://github.com/vim/vim/commit/004a6781b3cf15ca5dd632c38cc09bb3b253d1f8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 11 17:09:31 2020 +0200
patch 8.2.0540: regexp and other code not tested
Problem: Regexp and other code not tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5904)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 11 Apr 2020 17:15:06 +0200 |
parents | 2c4d9ca33769 |
children | 3601e816a569 |
line wrap: on
line diff
--- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -429,52 +429,6 @@ function Test_printf_spec_b() call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) endfunc -func Test_substitute_expr() - let g:val = 'XXX' - call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', '')) - call assert_equal('XXX', substitute('yyy', 'y*', {-> g:val}, '')) - call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)', - \ '\=nr2char("0x" . submatch(1))', 'g')) - call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)', - \ {-> nr2char("0x" . submatch(1))}, 'g')) - - call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)', - \ {-> submatch(2) . submatch(3) . submatch(1)}, '')) - - func Recurse() - return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '') - endfunc - " recursive call works - call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) - - call assert_fails("let s=submatch([])", 'E745:') - call assert_fails("let s=submatch(2, [])", 'E745:') -endfunc - -func Test_invalid_submatch() - " This was causing invalid memory access in Vim-7.4.2232 and older - call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:') -endfunc - -func Test_substitute_expr_arg() - call assert_equal('123456789-123456789=', substitute('123456789', - \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', - \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) - - call assert_equal('123456-123456=789', substitute('123456789', - \ '\(.\)\(.\)\(.\)\(a*\)\(n*\)\(.\)\(.\)\(.\)\(x*\)', - \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) - - call assert_equal('123456789-123456789x=', substitute('123456789', - \ '\(.\)\(.\)\(.*\)', - \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . 'x' . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) - - call assert_fails("call substitute('xxx', '.', {m -> string(add(m, 'x'))}, '')", 'E742:') - call assert_fails("call substitute('xxx', '.', {m -> string(insert(m, 'x'))}, '')", 'E742:') - call assert_fails("call substitute('xxx', '.', {m -> string(extend(m, ['x']))}, '')", 'E742:') - call assert_fails("call substitute('xxx', '.', {m -> string(remove(m, 1))}, '')", 'E742:') -endfunc - func Test_function_with_funcref() let s:f = function('type') let s:fref = function(s:f)