diff src/testdir/test_textobjects.vim @ 9642:8cc4dfadfd48 v7.4.2098

commit https://github.com/vim/vim/commit/00b24be454800f544676aa8850fb4378a568901e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 23 22:04:47 2016 +0200 patch 7.4.2098 Problem: Text object tests are old style. Solution: Turn them into new style tests. (James McCoy, closes https://github.com/vim/vim/issues/941)
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Jul 2016 22:15:05 +0200
parents
children ae45d497868f
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_textobjects.vim
@@ -0,0 +1,43 @@
+" Test for textobjects
+
+if !has('textobjects')
+  finish
+endif
+
+function! CpoM(line, useM, expected)
+  new
+
+  if a:useM
+    set cpoptions+=M
+  else
+    set cpoptions-=M
+  endif
+
+  call setline(1, a:line)
+
+  call setreg('"', '')
+  normal! ggfrmavi)y
+  call assert_equal(getreg('"'), a:expected[0])
+
+  call setreg('"', '')
+  normal! `afbmavi)y
+  call assert_equal(getreg('"'), a:expected[1])
+
+  call setreg('"', '')
+  normal! `afgmavi)y
+  call assert_equal(getreg('"'), a:expected[2])
+
+  q!
+endfunction
+
+function! Test_inner_block_without_cpo_M()
+  call CpoM('(red \(blue) green)', 0, ['red \(blue', 'red \(blue', ''])
+endfunction
+
+function! Test_inner_block_with_cpo_M_left_backslash()
+  call CpoM('(red \(blue) green)', 1, ['red \(blue) green', 'blue', 'red \(blue) green'])
+endfunction
+
+function! Test_inner_block_with_cpo_M_right_backslash()
+  call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green'])
+endfunction