Mercurial > vim
comparison src/testdir/test_filter_map.vim @ 23058:77f181975381 v8.2.2075
patch 8.2.2075: error for const argument to mapnew()
Commit: https://github.com/vim/vim/commit/57cf4973a283941c92744554474b2c52ce892fd1
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 1 21:08:05 2020 +0100
patch 8.2.2075: error for const argument to mapnew()
Problem: Error for const argument to mapnew().
Solution: Don't give an error. (closes https://github.com/vim/vim/issues/7400)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Dec 2020 21:15:03 +0100 |
parents | 36fc73078bce |
children | 06693d1afc48 |
comparison
equal
deleted
inserted
replaced
23057:35ba3a465deb | 23058:77f181975381 |
---|---|
121 func Test_mapnew_dict() | 121 func Test_mapnew_dict() |
122 let din = #{one: 1, two: 2} | 122 let din = #{one: 1, two: 2} |
123 let dout = mapnew(din, {k, v -> string(v)}) | 123 let dout = mapnew(din, {k, v -> string(v)}) |
124 call assert_equal(#{one: 1, two: 2}, din) | 124 call assert_equal(#{one: 1, two: 2}, din) |
125 call assert_equal(#{one: '1', two: '2'}, dout) | 125 call assert_equal(#{one: '1', two: '2'}, dout) |
126 | |
127 const dconst = #{one: 1, two: 2, three: 3} | |
128 call assert_equal(#{one: 2, two: 3, three: 4}, mapnew(dconst, {_, v -> v + 1})) | |
126 endfunc | 129 endfunc |
127 | 130 |
128 func Test_mapnew_list() | 131 func Test_mapnew_list() |
129 let lin = [1, 2, 3] | 132 let lin = [1, 2, 3] |
130 let lout = mapnew(lin, {k, v -> string(v)}) | 133 let lout = mapnew(lin, {k, v -> string(v)}) |
131 call assert_equal([1, 2, 3], lin) | 134 call assert_equal([1, 2, 3], lin) |
132 call assert_equal(['1', '2', '3'], lout) | 135 call assert_equal(['1', '2', '3'], lout) |
136 | |
137 const lconst = [1, 2, 3] | |
138 call assert_equal([2, 3, 4], mapnew(lconst, {_, v -> v + 1})) | |
133 endfunc | 139 endfunc |
134 | 140 |
135 func Test_mapnew_blob() | 141 func Test_mapnew_blob() |
136 let bin = 0z123456 | 142 let bin = 0z123456 |
137 let bout = mapnew(bin, {k, v -> k == 1 ? 0x99 : v}) | 143 let bout = mapnew(bin, {k, v -> k == 1 ? 0x99 : v}) |