diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-08 20:10:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-08 20:10:10 +0200 |
commit | dcae51facc4d6de1edd62f0242b40972be841103 (patch) | |
tree | cc4ed54ec096b1fb0e036166274d36ea64940990 /src/testdir/test_listdict.vim | |
parent | d8db8383926cb8729417d9515cbfaf455dbbd8d1 (diff) |
patch 8.2.2738: extending a list with itself can give wrong resultv8.2.2738
Problem: Extending a list with itself can give wrong result.
Solution: Remember the item before where the insertion happens and skip to
after the already inserted items. (closes #1112)
Diffstat (limited to 'src/testdir/test_listdict.vim')
-rw-r--r-- | src/testdir/test_listdict.vim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 051a37c3a5..1b0796d816 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -862,6 +862,20 @@ func Test_listdict_extend() " Extend g: dictionary with an invalid variable name call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') + + " Extend a list with itself. + let l = [1, 5, 7] + call extend(l, l, 0) + call assert_equal([1, 5, 7, 1, 5, 7], l) + let l = [1, 5, 7] + call extend(l, l, 1) + call assert_equal([1, 1, 5, 7, 5, 7], l) + let l = [1, 5, 7] + call extend(l, l, 2) + call assert_equal([1, 5, 1, 5, 7, 7], l) + let l = [1, 5, 7] + call extend(l, l, 3) + call assert_equal([1, 5, 7, 1, 5, 7], l) endfunc func Test_listdict_extendnew() |