comparison src/testdir/test_filter_map.vim @ 26907:6f43253463cc v8.2.3982

patch 8.2.3982: some lines of code not covered by tests Commit: https://github.com/vim/vim/commit/8bfa0eb863357c1013024233ebb2e95a0a848002 Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Sun Jan 2 16:16:33 2022 +0000 patch 8.2.3982: some lines of code not covered by tests Problem: Some lines of code not covered by tests. Solution: Add a few more test cases. (Dominique Pell?, closes https://github.com/vim/vim/issues/9453)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Jan 2022 17:30:02 +0100
parents 31c23760d590
children 4c16acb2525f
comparison
equal deleted inserted replaced
26906:1b8859235072 26907:6f43253463cc
149 func Test_filter_map_string() 149 func Test_filter_map_string()
150 " filter() 150 " filter()
151 let lines =<< trim END 151 let lines =<< trim END
152 VAR s = "abc" 152 VAR s = "abc"
153 call filter(s, '"b" != v:val') 153 call filter(s, '"b" != v:val')
154 call assert_equal(s, s) 154 call assert_equal('abc', s)
155 call assert_equal('ac', filter('abc', '"b" != v:val')) 155 call assert_equal('ac', filter('abc', '"b" != v:val'))
156 call assert_equal('あいうえお', filter('あxいxうxえxお', '"x" != v:val')) 156 call assert_equal('あいうえお', filter('あxいxうxえxお', '"x" != v:val'))
157 call assert_equal('あa😊💕💕b💕', filter('あxax😊x💕💕b💕x', '"x" != v:val')) 157 call assert_equal('あa😊💕💕b💕', filter('あxax😊x💕💕b💕x', '"x" != v:val'))
158 call assert_equal('xxxx', filter('あxax😊x💕💕b💕x', '"x" == v:val')) 158 call assert_equal('xxxx', filter('あxax😊x💕💕b💕x', '"x" == v:val'))
159 VAR t = "%),:;>?]}’”†‡…‰,‱‼⁇⁈⁉℃℉,、。〉》」,』】〕〗〙〛,!),.:,;?,]}" 159 VAR t = "%),:;>?]}’”†‡…‰,‱‼⁇⁈⁉℃℉,、。〉》」,』】〕〗〙〛,!),.:,;?,]}"
170 170
171 " map() 171 " map()
172 let lines =<< trim END 172 let lines =<< trim END
173 VAR s = "abc" 173 VAR s = "abc"
174 call map(s, 'nr2char(char2nr(v:val) + 2)') 174 call map(s, 'nr2char(char2nr(v:val) + 2)')
175 call assert_equal(s, s) 175 call assert_equal('abc', s)
176 call assert_equal('cde', map('abc', 'nr2char(char2nr(v:val) + 2)')) 176 call assert_equal('cde', map('abc', 'nr2char(char2nr(v:val) + 2)'))
177 call assert_equal('[あ][i][う][え][お]', map('あiうえお', '"[" .. v:val .. "]"')) 177 call assert_equal('[あ][i][う][え][お]', map('あiうえお', '"[" .. v:val .. "]"'))
178 call assert_equal('[あ][a][😊][,][‱][‼][⁇][⁈][⁉][💕][b][💕][c][💕]', map('あa😊,‱‼⁇⁈⁉💕b💕c💕', '"[" .. v:val .. "]"')) 178 call assert_equal('[あ][a][😊][,][‱][‼][⁇][⁈][⁉][💕][b][💕][c][💕]', map('あa😊,‱‼⁇⁈⁉💕b💕c💕', '"[" .. v:val .. "]"'))
179 call assert_equal('', map('abc', '""')) 179 call assert_equal('', map('abc', '""'))
180 call assert_equal('cde', map('abc', LSTART i, x LMIDDLE nr2char(char2nr(x) + 2) LEND)) 180 call assert_equal('cde', map('abc', LSTART i, x LMIDDLE nr2char(char2nr(x) + 2) LEND))
189 189
190 " mapnew() 190 " mapnew()
191 let lines =<< trim END 191 let lines =<< trim END
192 VAR s = "abc" 192 VAR s = "abc"
193 call mapnew(s, 'nr2char(char2nr(v:val) + 2)') 193 call mapnew(s, 'nr2char(char2nr(v:val) + 2)')
194 call assert_equal(s, s) 194 call assert_equal('abc', s)
195 call assert_equal('cde', mapnew('abc', 'nr2char(char2nr(v:val) + 2)')) 195 call assert_equal('cde', mapnew('abc', 'nr2char(char2nr(v:val) + 2)'))
196 call assert_equal('[あ][i][う][え][お]', mapnew('あiうえお', '"[" .. v:val .. "]"')) 196 call assert_equal('[あ][i][う][え][お]', mapnew('あiうえお', '"[" .. v:val .. "]"'))
197 call assert_equal('[あ][a][😊][,][‱][‼][⁇][⁈][⁉][💕][b][💕][c][💕]', mapnew('あa😊,‱‼⁇⁈⁉💕b💕c💕', '"[" .. v:val .. "]"')) 197 call assert_equal('[あ][a][😊][,][‱][‼][⁇][⁈][⁉][💕][b][💕][c][💕]', mapnew('あa😊,‱‼⁇⁈⁉💕b💕c💕', '"[" .. v:val .. "]"'))
198 call assert_equal('', mapnew('abc', '""')) 198 call assert_equal('', mapnew('abc', '""'))
199 call assert_equal('cde', mapnew('abc', LSTART i, x LMIDDLE nr2char(char2nr(x) + 2) LEND)) 199 call assert_equal('cde', mapnew('abc', LSTART i, x LMIDDLE nr2char(char2nr(x) + 2) LEND))