Mercurial > vim
comparison src/testdir/test_listdict.vim @ 24396:d406858354a6 v8.2.2738
patch 8.2.2738: extending a list with itself can give wrong result
Commit: https://github.com/vim/vim/commit/dcae51facc4d6de1edd62f0242b40972be841103
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 8 20:10:10 2021 +0200
patch 8.2.2738: extending a list with itself can give wrong result
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 08 Apr 2021 20:15:03 +0200 |
parents | 510088f8c66f |
children | 4aebea72c397 |
comparison
equal
deleted
inserted
replaced
24395:5cd55703c76d | 24396:d406858354a6 |
---|---|
860 call assert_fails("call extend([1, 2], 1)", 'E712:') | 860 call assert_fails("call extend([1, 2], 1)", 'E712:') |
861 call assert_fails("call extend([1, 2], {})", 'E712:') | 861 call assert_fails("call extend([1, 2], {})", 'E712:') |
862 | 862 |
863 " Extend g: dictionary with an invalid variable name | 863 " Extend g: dictionary with an invalid variable name |
864 call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') | 864 call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') |
865 | |
866 " Extend a list with itself. | |
867 let l = [1, 5, 7] | |
868 call extend(l, l, 0) | |
869 call assert_equal([1, 5, 7, 1, 5, 7], l) | |
870 let l = [1, 5, 7] | |
871 call extend(l, l, 1) | |
872 call assert_equal([1, 1, 5, 7, 5, 7], l) | |
873 let l = [1, 5, 7] | |
874 call extend(l, l, 2) | |
875 call assert_equal([1, 5, 1, 5, 7, 7], l) | |
876 let l = [1, 5, 7] | |
877 call extend(l, l, 3) | |
878 call assert_equal([1, 5, 7, 1, 5, 7], l) | |
865 endfunc | 879 endfunc |
866 | 880 |
867 func Test_listdict_extendnew() | 881 func Test_listdict_extendnew() |
868 " Test extendnew() with lists | 882 " Test extendnew() with lists |
869 let l = [1, 2, 3] | 883 let l = [1, 2, 3] |