Mercurial > vim
diff src/testdir/test_listdict.vim @ 23588:510088f8c66f v8.2.2336
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Commit: https://github.com/vim/vim/commit/b0e6b513648db7035046613431a4aa9d71ef4653
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 12 20:23:40 2021 +0100
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Problem: Vim9: it is not possible to extend a dictionary with different
item types.
Solution: Add extendnew(). (closes #7666)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 12 Jan 2021 20:30:07 +0100 |
parents | 690b84a6a7ce |
children | d406858354a6 |
line wrap: on
line diff
--- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -864,6 +864,18 @@ func Test_listdict_extend() call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') endfunc +func Test_listdict_extendnew() + " Test extendnew() with lists + let l = [1, 2, 3] + call assert_equal([1, 2, 3, 4, 5], extendnew(l, [4, 5])) + call assert_equal([1, 2, 3], l) + + " Test extend() with dictionaries. + let d = {'a': {'b': 'B'}} + call assert_equal({'a': {'b': 'B'}, 'c': 'cc'}, extendnew(d, {'c': 'cc'})) + call assert_equal({'a': {'b': 'B'}}, d) +endfunc + func s:check_scope_dict(x, fixed) func s:gen_cmd(cmd, x) return substitute(a:cmd, '\<x\ze:', a:x, 'g')