diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-17 09:43:00 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-08-17 11:21:10 +0800 |
commit | 8cbb2477cf70ea29105e3df17308e6d6a067c8e6 (patch) | |
tree | d0f81b872a4220930736f9e276b2eb4eac802f02 /test | |
parent | 22d9338afceae5f8ef3845f152dea07a19d512d1 (diff) | |
download | rneovim-8cbb2477cf70ea29105e3df17308e6d6a067c8e6.tar.gz rneovim-8cbb2477cf70ea29105e3df17308e6d6a067c8e6.tar.bz2 rneovim-8cbb2477cf70ea29105e3df17308e6d6a067c8e6.zip |
vim-patch:8.2.1969: Vim9: map() may change the list or dict item type
Problem: Vim9: map() may change the list or dict item type.
Solution: Add mapnew().
https://github.com/vim/vim/commit/ea696852e7abcdebaf7f17a7f23dc90df1f5e2ed
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_filter_map.vim | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/old/testdir/test_filter_map.vim b/test/old/testdir/test_filter_map.vim index e2216e4d68..880162c2b9 100644 --- a/test/old/testdir/test_filter_map.vim +++ b/test/old/testdir/test_filter_map.vim @@ -111,4 +111,25 @@ func Test_map_and_modify() call assert_fails('echo map(d, {k,v -> remove(d, k)})', 'E741:') endfunc +func Test_mapnew_dict() + let din = #{one: 1, two: 2} + let dout = mapnew(din, {k, v -> string(v)}) + call assert_equal(#{one: 1, two: 2}, din) + call assert_equal(#{one: '1', two: '2'}, dout) +endfunc + +func Test_mapnew_list() + let lin = [1, 2, 3] + let lout = mapnew(lin, {k, v -> string(v)}) + call assert_equal([1, 2, 3], lin) + call assert_equal(['1', '2', '3'], lout) +endfunc + +func Test_mapnew_blob() + let bin = 0z123456 + let bout = mapnew(bin, {k, v -> k == 1 ? 0x99 : v}) + call assert_equal(0z123456, bin) + call assert_equal(0z129956, bout) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |