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/test_vim9_builtin.vim | |
parent | f2b26bcf8f498fed72759af4aa768fb2aab3118c (diff) |
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/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 2929100162..d9275e617b 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 |