comparison src/testdir/test_filter_map.vim @ 22608:f140b9036aa5 v8.2.1852

patch 8.2.1852: map() returing zero for NULL list is unexpected Commit: https://github.com/vim/vim/commit/ffdf8adfa8108d4765fdc68abbd2fe49a4292b25 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 15 22:29:17 2020 +0200 patch 8.2.1852: map() returing zero for NULL list is unexpected Problem: map() returing zero for NULL list is unexpected. Solution: Return the empty list. (closes https://github.com/vim/vim/issues/7133)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Oct 2020 22:30:04 +0200
parents 46956b6811a1
children 36fc73078bce
comparison
equal deleted inserted replaced
22607:95b74784c037 22608:f140b9036aa5
96 call assert_fails("let l = map('abc', '\"> \" . v:val')", 'E896:') 96 call assert_fails("let l = map('abc', '\"> \" . v:val')", 'E896:')
97 call assert_fails("let l = filter('abc', '\"> \" . v:val')", 'E896:') 97 call assert_fails("let l = filter('abc', '\"> \" . v:val')", 'E896:')
98 call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:') 98 call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:')
99 call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:') 99 call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:')
100 call assert_fails("let l = filter([1, 2], {})", 'E731:') 100 call assert_fails("let l = filter([1, 2], {})", 'E731:')
101 call assert_equal(0, filter(test_null_list(), 0)) 101 call assert_equal(test_null_list(), filter(test_null_list(), 0))
102 call assert_equal(0, filter(test_null_dict(), 0)) 102 call assert_equal(test_null_dict(), filter(test_null_dict(), 0))
103 call assert_equal(0, map(test_null_list(), '"> " .. v:val')) 103 call assert_equal(test_null_list(), map(test_null_list(), '"> " .. v:val'))
104 call assert_equal(0, map(test_null_dict(), '"> " .. v:val')) 104 call assert_equal(test_null_dict(), map(test_null_dict(), '"> " .. v:val'))
105 call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_function())) 105 call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_function()))
106 call assert_fails("let l = filter([1, 2], function('min'))", 'E118:') 106 call assert_fails("let l = filter([1, 2], function('min'))", 'E118:')
107 call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial())) 107 call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial()))
108 call assert_fails("let l = filter([1, 2], {a, b, c -> 1})", 'E119:') 108 call assert_fails("let l = filter([1, 2], {a, b, c -> 1})", 'E119:')
109 endfunc 109 endfunc