To: vim_dev@googlegroups.com Subject: Patch 8.2.0134 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0134 Problem: Some map functionality not covered by tests. Solution: Add tests. (Yegappan Lakshmanan, closes #5504) Files: src/testdir/test_maparg.vim, src/testdir/test_mapping.vim *** ../vim-8.2.0133/src/testdir/test_maparg.vim 2019-09-01 18:54:54.000000000 +0200 --- src/testdir/test_maparg.vim 2020-01-20 20:39:47.494304898 +0100 *************** *** 42,47 **** --- 42,52 ---- map abc yy 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 call assert_equal("", maparg('abc')) unmap abc *************** *** 102,104 **** --- 107,111 ---- execute "normal a\uf040\" call assert_equal("abcd", getline(1)) endfunction + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0133/src/testdir/test_mapping.vim 2019-11-22 20:50:37.000000000 +0100 --- src/testdir/test_mapping.vim 2020-01-20 20:39:47.494304898 +0100 *************** *** 492,494 **** --- 492,567 ---- 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 /[#&!] + call assert_fails("map ,w /[#&!]", 'E227:') + " unique buffer-local map + call assert_fails("map ,w /[.,;]", 'E225:') + unmap ,w + + " unique abbreviation + abbr SP special + call assert_fails("abbr SP special", 'E226:') + " unique buffer-local map + call assert_fails("abbr SP special", 'E224:') + unabbr SP + + call assert_fails('mapclear abc', 'E474:') + call assert_fails('abclear abc', 'E474:') + endfunc + + " Test for key mapping + func Test_map_special() + new + let old_cpo = &cpo + set cpo+=< + imap Blue + call feedkeys("i\", "x") + call assert_equal("", getline(1)) + call feedkeys("ddi", "x") + call assert_equal("Blue", getline(1)) + iunmap + imap Green + call feedkeys("ddi\", "x") + call assert_equal("Green", getline(1)) + call feedkeys("ddi", "x") + call assert_equal("", getline(1)) + iunmap + 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\+ ( + 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(['', '', '', '