summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_vim9_builtin.vim
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-08-13 21:35:13 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-13 21:35:13 +0100
commit3fbf6cd355de2212e9227f57d545592aae3f688f (patch)
tree659f4b00bea60f1935a683a5b6a51ab19912d3d4 /src/testdir/test_vim9_builtin.vim
parent9113c2cd19c72c0973ee5dc095a0a7f03f2af344 (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.vim11
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()