diff src/testdir/test_search.vim @ 17994:0dcc2ee838dd v8.1.1993

patch 8.1.1993: more functions can be used as methods Commit: https://github.com/vim/vim/commit/196b4664432f932625cfb6371dc42c24efe6c203 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 6 21:34:30 2019 +0200 patch 8.1.1993: more functions can be used as methods Problem: More functions can be used as methods. Solution: Make various functions usable as a method.
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 Sep 2019 21:45:04 +0200
parents 9606c0adc148
children d7c47e45bcc3
line wrap: on
line diff
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -1280,7 +1280,7 @@ func Test_search_match_at_curpos()
 
   normal gg
 
-  call search('foobar', 'c')
+  eval 'foobar'->search('c')
   call assert_equal([1, 1], [line('.'), col('.')])
 
   normal j
@@ -1318,3 +1318,38 @@ func Test_search_display_pattern()
     set norl
   endif
 endfunc
+
+func Test_searchdecl()
+  let lines =<< trim END
+     int global;
+
+     func()
+     {
+       int global;
+       if (cond) {
+	 int local;
+       }
+       int local;
+       // comment
+     }
+  END
+  new
+  call setline(1, lines)
+  10
+  call assert_equal(0, searchdecl('local', 0, 0))
+  call assert_equal(7, getcurpos()[1])
+
+  10
+  call assert_equal(0, 'local'->searchdecl(0, 1))
+  call assert_equal(9, getcurpos()[1])
+
+  10
+  call assert_equal(0, searchdecl('global'))
+  call assert_equal(5, getcurpos()[1])
+
+  10
+  call assert_equal(0, searchdecl('global', 1))
+  call assert_equal(1, getcurpos()[1])
+
+  bwipe!
+endfunc