diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-08-13 21:35:13 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-13 21:35:13 +0100 |
commit | 3fbf6cd355de2212e9227f57d545592aae3f688f (patch) | |
tree | 659f4b00bea60f1935a683a5b6a51ab19912d3d4 /src/testdir/test_vim9_builtin.vim | |
parent | 9113c2cd19c72c0973ee5dc095a0a7f03f2af344 (diff) |
patch 9.0.0202: code and help for indexof() is not idealv9.0.0202
Problem: Code and help for indexof() is not ideal.
Solution: Refactor the code, improve the help. (Yegappan Lakshmanan,
closes #10908)
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 212e9f11b7..244021c7eb 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -2067,10 +2067,17 @@ def Test_index() enddef def Test_indexof() - var l = [{color: 'red'}, {color: 'blue'}, {color: 'green'}] - indexof(l, (i, v) => v.color == 'green')->assert_equal(2) + var l = [{color: 'red'}, {color: 'blue'}, {color: 'green'}, {color: 'blue'}] + indexof(l, (i, v) => v.color == 'blue')->assert_equal(1) + indexof(l, (i, v) => v.color == 'blue', {startidx: 1})->assert_equal(1) + indexof(l, (i, v) => v.color == 'blue', {startidx: 2})->assert_equal(3) var b = 0zdeadbeef indexof(b, "v:val == 0xef")->assert_equal(3) + + def TestIdx(k: number, v: dict<any>): bool + return v.color == 'blue' + enddef + indexof(l, TestIdx)->assert_equal(1) enddef def Test_input() |