diff src/testdir/test_search.vim @ 12722:7749260f261c v8.0.1239

patch 8.0.1239: cannot use a lambda for the skip argument to searchpair() commit https://github.com/vim/vim/commit/48570488f17e397183ea7d5c7ca67d6e4ffb013d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 30 21:48:41 2017 +0100 patch 8.0.1239: cannot use a lambda for the skip argument to searchpair() Problem: Cannot use a lambda for the skip argument to searchpair(). Solution: Evaluate a partial, funcref and lambda. (LemonBoy, closes https://github.com/vim/vim/issues/1454, closes #2265)
author Christian Brabandt <cb@256bit.org>
date Mon, 30 Oct 2017 22:00:05 +0100
parents 37c384802df4
children 6fa9f6b4d159
line wrap: on
line diff
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -296,6 +296,25 @@ func Test_searchpair()
   q!
 endfunc
 
+func Test_searchpair_skip()
+    func Zero()
+	return 0
+    endfunc
+    func Partial(x)
+	return a:x
+    endfunc
+    new
+    call setline(1, ['{', 'foo', 'foo', 'foo', '}'])
+    3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', ''))
+    3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', '0'))
+    3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', {-> 0}))
+    3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Zero')))
+    3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Partial', [0])))
+    " invalid argument
+    3 | call assert_equal(0, searchpair('{', '', '}', 'bWn', 0))
+    bw!
+endfunc
+
 func Test_searchc()
   " These commands used to cause memory overflow in searchc().
   new