]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0134: some map functionality not covered by tests v8.2.0134
authorBram Moolenaar <Bram@vim.org>
Mon, 20 Jan 2020 19:41:42 +0000 (20:41 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 20 Jan 2020 19:41:42 +0000 (20:41 +0100)
Problem:    Some map functionality not covered by tests.
Solution:   Add tests. (Yegappan Lakshmanan, closes #5504)

src/testdir/test_maparg.vim
src/testdir/test_mapping.vim
src/version.c

index 0284f31cbb1594c40751dafc86a9cbf15c4cec99..15bbf3b9b7b00fc2130f630c0c6d79f96a5b75a9 100644 (file)
@@ -42,6 +42,11 @@ function Test_maparg()
   map abc y<S-char-114>y
   call assert_equal("yRy", maparg('abc'))
 
+  omap { w
+  let d = maparg('{', 'o', 0, 1)
+  call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode])
+  ounmap {
+
   map abc <Nop>
   call assert_equal("<Nop>", maparg('abc'))
   unmap abc
@@ -102,3 +107,5 @@ function Test_range_map()
   execute "normal a\uf040\<Esc>"
   call assert_equal("abcd", getline(1))
 endfunction
+
+" vim: shiftwidth=2 sts=2 expandtab
index d3abaff9bfd19681d757d800cec74b97b074561a..3d5bb19a20b47d5fe8b6688e329357ac93ef839a 100644 (file)
@@ -492,3 +492,76 @@ func Test_expr_map_restore_cursor()
   call StopVimInTerminal(buf)
   call delete('XtestExprMap')
 endfunc
+
+" Test for mapping errors
+func Test_map_error()
+  call assert_fails('unmap', 'E474:')
+  call assert_fails("exe 'map ' .. repeat('a', 51) .. ' :ls'", 'E474:')
+  call assert_fails('unmap abc', 'E31:')
+  call assert_fails('unabbr abc', 'E24:')
+  call assert_equal('', maparg(''))
+  call assert_fails('echo maparg("abc", [])', 'E730:')
+
+  " unique map
+  map ,w /[#&!]<CR>
+  call assert_fails("map <unique> ,w /[#&!]<CR>", 'E227:')
+  " unique buffer-local map
+  call assert_fails("map <buffer> <unique> ,w /[.,;]<CR>", 'E225:')
+  unmap ,w
+
+  " unique abbreviation
+  abbr SP special
+  call assert_fails("abbr <unique> SP special", 'E226:')
+  " unique buffer-local map
+  call assert_fails("abbr <buffer> <unique> SP special", 'E224:')
+  unabbr SP
+
+  call assert_fails('mapclear abc', 'E474:')
+  call assert_fails('abclear abc', 'E474:')
+endfunc
+
+" Test for <special> key mapping
+func Test_map_special()
+  new
+  let old_cpo = &cpo
+  set cpo+=<
+  imap <F12> Blue
+  call feedkeys("i\<F12>", "x")
+  call assert_equal("<F12>", getline(1))
+  call feedkeys("ddi<F12>", "x")
+  call assert_equal("Blue", getline(1))
+  iunmap <F12>
+  imap <special> <F12> Green
+  call feedkeys("ddi\<F12>", "x")
+  call assert_equal("Green", getline(1))
+  call feedkeys("ddi<F12>", "x")
+  call assert_equal("<F12>", getline(1))
+  iunmap <special> <F12>
+  let &cpo = old_cpo
+  %bwipe!
+endfunc
+
+" Test for hasmapto()
+func Test_hasmapto()
+  call assert_equal(0, hasmapto('/^\k\+ ('))
+  call assert_equal(0, hasmapto('/^\k\+ (', 'n'))
+  nmap ,f /^\k\+ (<CR>
+  call assert_equal(1, hasmapto('/^\k\+ ('))
+  call assert_equal(1, hasmapto('/^\k\+ (', 'n'))
+  call assert_equal(0, hasmapto('/^\k\+ (', 'v'))
+
+  call assert_equal(0, hasmapto('/^\k\+ (', 'n', 1))
+endfunc
+
+" Test for command-line completion of maps
+func Test_mapcomplete()
+  call assert_equal(['<buffer>', '<expr>', '<nowait>', '<script>',
+             \ '<silent>', '<special>', '<unique>'],
+             \ getcompletion('', 'mapping'))
+  call assert_equal([], getcompletion(',d', 'mapping'))
+
+  call feedkeys(":abbr! \<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_match("abbr! \x01", @:)
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
index 6b905515437aebf6bbf44f8cd93b3ea8a44aee50..de6f9f012d2e51a09e06a0813d0e7cd0679ef3cc 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    134,
 /**/
     133,
 /**/