Skip to content

Commit 08cf0c0

Browse files
committed
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Problem: Vim9: function argument of sort() and map() not tested. Solution: Add a couple of tests.
1 parent 56602ba commit 08cf0c0

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/testdir/test_vim9_builtin.vim

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ def Wrong_dict_key_type(items: list<number>): list<number>
229229
return filter(items, {_, val -> get({[val]: 1}, 'x')})
230230
enddef
231231

232+
def Test_map_function_arg()
233+
var lines =<< trim END
234+
def MapOne(i: number, v: string): string
235+
return i .. ':' .. v
236+
enddef
237+
var l = ['a', 'b', 'c']
238+
map(l, MapOne)
239+
assert_equal(['0:a', '1:b', '2:c'], l)
240+
END
241+
CheckDefAndScriptSuccess(lines)
242+
enddef
243+
232244
def Test_filter_wrong_dict_key_type()
233245
assert_fails('Wrong_dict_key_type([1, 2, 3])', 'E1012:')
234246
enddef
@@ -523,8 +535,18 @@ def Test_sort_return_type()
523535
enddef
524536

525537
def Test_sort_argument()
526-
var res = ['b', 'a', 'c']->sort('i')
527-
res->assert_equal(['a', 'b', 'c'])
538+
var lines =<< trim END
539+
var res = ['b', 'a', 'c']->sort('i')
540+
res->assert_equal(['a', 'b', 'c'])
541+
542+
def Compare(a: number, b: number): number
543+
return a - b
544+
enddef
545+
var l = [3, 6, 7, 1, 8, 2, 4, 5]
546+
sort(l, Compare)
547+
assert_equal([1, 2, 3, 4, 5, 6, 7, 8], l)
548+
END
549+
CheckDefAndScriptSuccess(lines)
528550
enddef
529551

530552
def Test_split()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2098,
753755
/**/
754756
2097,
755757
/**/

0 commit comments

Comments
 (0)