diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-31 13:08:38 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-31 13:08:38 +0100 |
commit | 3445320839a38b3b0c253513b125da8298ec27d6 (patch) | |
tree | 36de5f4e0a019c497710a3cfd6908a5fed0feed4 /src/testdir | |
parent | f2b26bcf8f498fed72759af4aa768fb2aab3118c (diff) | |
download | vim-git-3445320839a38b3b0c253513b125da8298ec27d6.tar.gz |
patch 8.2.2435: setline() gives an error for some typesv8.2.2435
Problem: setline() gives an error for some types.
Solution: Allow any type, convert each item to a string.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_bufline.vim | 7 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 48 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index 0f5bac873..b2de198ef 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -5,6 +5,7 @@ source screendump.vim source check.vim func Test_setbufline_getbufline() + " similar to Test_set_get_bufline() new let b = bufnr('%') hide @@ -38,6 +39,12 @@ func Test_setbufline_getbufline() call assert_equal(['e'], getbufline(b, 5)) call assert_equal([], getbufline(b, 6)) call assert_equal([], getbufline(b, 2, 1)) + + call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()]) + call assert_equal(["function('eval')", + \ "{'key': 123}", + \ "no process"], + \ getbufline(b, 2, 4)) exe "bwipe! " . b endfunc diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 292910016..d9275e617 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -767,6 +767,54 @@ def Test_searchcount() bwipe! enddef +def Test_set_get_bufline() + # similar to Test_setbufline_getbufline() + var lines =<< trim END + new + var b = bufnr('%') + hide + assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) + assert_equal(['foo'], getbufline(b, 1)) + assert_equal(['bar'], getbufline(b, '$')) + assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) + exe "bd!" b + assert_equal([], getbufline(b, 1, 2)) + + split Xtest + setline(1, ['a', 'b', 'c']) + b = bufnr('%') + wincmd w + + assert_equal(1, setbufline(b, 5, 'x')) + assert_equal(1, setbufline(b, 5, ['x'])) + assert_equal(1, setbufline(b, 5, [])) + assert_equal(1, setbufline(b, 5, test_null_list())) + + assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1)) + assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) + assert_equal(1, []->setbufline(bufnr('$') + 1, 1)) + assert_equal(1, test_null_list()->setbufline(bufnr('$') + 1, 1)) + + assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) + + assert_equal(0, setbufline(b, 4, ['d', 'e'])) + assert_equal(['c'], b->getbufline(3)) + assert_equal(['d'], getbufline(b, 4)) + assert_equal(['e'], getbufline(b, 5)) + assert_equal([], getbufline(b, 6)) + assert_equal([], getbufline(b, 2, 1)) + + setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()]) + assert_equal(["function('eval')", + "{'key': 123}", + "no process"], + getbufline(b, 2, 4)) + + exe 'bwipe! ' .. b + END + CheckDefAndScriptSuccess(lines) +enddef + def Test_searchdecl() searchdecl('blah', true, true)->assert_equal(1) enddef |