• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision643c6c3c0da4826a7daa4af213c608aaa0036661 (tree)
l'heure2020-01-21 04:45:04
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.0134: some map functionality not covered by tests

Commit: https://github.com/vim/vim/commit/8ba6bb7c94229f1e6f85ea5152ed8b4fbbbd9d20
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 20 20:41:42 2020 +0100

patch 8.2.0134: some map functionality not covered by tests
Problem: Some map functionality not covered by tests.
Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5504)

Change Summary

Modification

diff -r b75ea81727be -r 643c6c3c0da4 src/testdir/test_maparg.vim
--- a/src/testdir/test_maparg.vim Mon Jan 20 20:30:05 2020 +0100
+++ b/src/testdir/test_maparg.vim Mon Jan 20 20:45:04 2020 +0100
@@ -42,6 +42,11 @@
4242 map abc y<S-char-114>y
4343 call assert_equal("yRy", maparg('abc'))
4444
45+ omap { w
46+ let d = maparg('{', 'o', 0, 1)
47+ call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode])
48+ ounmap {
49+
4550 map abc <Nop>
4651 call assert_equal("<Nop>", maparg('abc'))
4752 unmap abc
@@ -102,3 +107,5 @@
102107 execute "normal a\uf040\<Esc>"
103108 call assert_equal("abcd", getline(1))
104109 endfunction
110+
111+" vim: shiftwidth=2 sts=2 expandtab
diff -r b75ea81727be -r 643c6c3c0da4 src/testdir/test_mapping.vim
--- a/src/testdir/test_mapping.vim Mon Jan 20 20:30:05 2020 +0100
+++ b/src/testdir/test_mapping.vim Mon Jan 20 20:45:04 2020 +0100
@@ -492,3 +492,76 @@
492492 call StopVimInTerminal(buf)
493493 call delete('XtestExprMap')
494494 endfunc
495+
496+" Test for mapping errors
497+func Test_map_error()
498+ call assert_fails('unmap', 'E474:')
499+ call assert_fails("exe 'map ' .. repeat('a', 51) .. ' :ls'", 'E474:')
500+ call assert_fails('unmap abc', 'E31:')
501+ call assert_fails('unabbr abc', 'E24:')
502+ call assert_equal('', maparg(''))
503+ call assert_fails('echo maparg("abc", [])', 'E730:')
504+
505+ " unique map
506+ map ,w /[#&!]<CR>
507+ call assert_fails("map <unique> ,w /[#&!]<CR>", 'E227:')
508+ " unique buffer-local map
509+ call assert_fails("map <buffer> <unique> ,w /[.,;]<CR>", 'E225:')
510+ unmap ,w
511+
512+ " unique abbreviation
513+ abbr SP special
514+ call assert_fails("abbr <unique> SP special", 'E226:')
515+ " unique buffer-local map
516+ call assert_fails("abbr <buffer> <unique> SP special", 'E224:')
517+ unabbr SP
518+
519+ call assert_fails('mapclear abc', 'E474:')
520+ call assert_fails('abclear abc', 'E474:')
521+endfunc
522+
523+" Test for <special> key mapping
524+func Test_map_special()
525+ new
526+ let old_cpo = &cpo
527+ set cpo+=<
528+ imap <F12> Blue
529+ call feedkeys("i\<F12>", "x")
530+ call assert_equal("<F12>", getline(1))
531+ call feedkeys("ddi<F12>", "x")
532+ call assert_equal("Blue", getline(1))
533+ iunmap <F12>
534+ imap <special> <F12> Green
535+ call feedkeys("ddi\<F12>", "x")
536+ call assert_equal("Green", getline(1))
537+ call feedkeys("ddi<F12>", "x")
538+ call assert_equal("<F12>", getline(1))
539+ iunmap <special> <F12>
540+ let &cpo = old_cpo
541+ %bwipe!
542+endfunc
543+
544+" Test for hasmapto()
545+func Test_hasmapto()
546+ call assert_equal(0, hasmapto('/^\k\+ ('))
547+ call assert_equal(0, hasmapto('/^\k\+ (', 'n'))
548+ nmap ,f /^\k\+ (<CR>
549+ call assert_equal(1, hasmapto('/^\k\+ ('))
550+ call assert_equal(1, hasmapto('/^\k\+ (', 'n'))
551+ call assert_equal(0, hasmapto('/^\k\+ (', 'v'))
552+
553+ call assert_equal(0, hasmapto('/^\k\+ (', 'n', 1))
554+endfunc
555+
556+" Test for command-line completion of maps
557+func Test_mapcomplete()
558+ call assert_equal(['<buffer>', '<expr>', '<nowait>', '<script>',
559+ \ '<silent>', '<special>', '<unique>'],
560+ \ getcompletion('', 'mapping'))
561+ call assert_equal([], getcompletion(',d', 'mapping'))
562+
563+ call feedkeys(":abbr! \<C-A>\<C-B>\"\<CR>", 'tx')
564+ call assert_match("abbr! \x01", @:)
565+endfunc
566+
567+" vim: shiftwidth=2 sts=2 expandtab
diff -r b75ea81727be -r 643c6c3c0da4 src/version.c
--- a/src/version.c Mon Jan 20 20:30:05 2020 +0100
+++ b/src/version.c Mon Jan 20 20:45:04 2020 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 134,
747+/**/
746748 133,
747749 /**/
748750 132,
Afficher sur ancien navigateur de dépôt.