diff src/testdir/test_textprop.vim @ 16060:176872829dc2 v8.1.1035

patch 8.1.1035: prop_remove() second argument is not optional commit https://github.com/vim/vim/commit/0a2f578e22de7e4d82075578afdd5fc2d2dd8134 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 22 13:20:43 2019 +0100 patch 8.1.1035: prop_remove() second argument is not optional Problem: prop_remove() second argument is not optional. Solution: Fix argument count. Use "buf" instead of "curbuf". (closes https://github.com/vim/vim/issues/4147)
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 Mar 2019 13:30:05 +0100
parents 857ce36c8412
children 7a563ee902b6
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -166,28 +166,64 @@ func Test_prop_add_remove_buf()
   new
   let bufnr = bufnr('')
   call AddPropTypes()
-  call setline(1, 'one two three')
+  for lnum in range(1, 4)
+    call setline(lnum, 'one two three')
+  endfor
   wincmd w
-  call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
-  call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
-  call prop_add(1, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr})
-  
+  for lnum in range(1, 4)
+    call prop_add(lnum, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
+    call prop_add(lnum, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
+    call prop_add(lnum, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr})
+  endfor
+
   let props = [
 	\ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
 	\ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
 	\ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1},
 	\]
   call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
- 
+
   " remove by id
+  let before_props = deepcopy(props)
+  unlet props[1]
+
   call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
-  unlet props[1]
+  call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
+
+  call prop_remove({'id': 12, 'bufnr': bufnr}, 3, 4)
   call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+  call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
+  call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
+
+  call prop_remove({'id': 12, 'bufnr': bufnr})
+  for lnum in range(1, 4)
+    call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
+  endfor
 
   " remove by type
-  call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
+  let before_props = deepcopy(props)
   unlet props[0]
+
+  call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
   call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
+
+  call prop_remove({'type': 'one', 'bufnr': bufnr}, 3, 4)
+  call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+  call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+  call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
+  call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
+
+  call prop_remove({'type': 'one', 'bufnr': bufnr})
+  for lnum in range(1, 4)
+    call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
+  endfor
 
   call DeletePropTypes()
   wincmd w