diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-11 17:09:31 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-11 17:09:31 +0200 |
commit | 004a6781b3cf15ca5dd632c38cc09bb3b253d1f8 (patch) | |
tree | 7f71edb5284a22ff7e24b638303e0f5c1f5988d6 /src/testdir/test_expr.vim | |
parent | d1caa941d876181aae0ebebc6ea954045bf0da24 (diff) | |
download | vim-git-004a6781b3cf15ca5dd632c38cc09bb3b253d1f8.tar.gz |
patch 8.2.0540: regexp and other code not testedv8.2.0540
Problem: Regexp and other code not tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes #5904)
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r-- | src/testdir/test_expr.vim | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 116f71364..ed8fa2bc0 100644 --- 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) |