Mirror of the Vim source from https://github.com/vim/vim
Révision | 643c6c3c0da4826a7daa4af213c608aaa0036661 (tree) |
---|---|
l'heure | 2020-01-21 04:45:04 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -42,6 +42,11 @@ | ||
42 | 42 | map abc y<S-char-114>y |
43 | 43 | call assert_equal("yRy", maparg('abc')) |
44 | 44 | |
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 | + | |
45 | 50 | map abc <Nop> |
46 | 51 | call assert_equal("<Nop>", maparg('abc')) |
47 | 52 | unmap abc |
@@ -102,3 +107,5 @@ | ||
102 | 107 | execute "normal a\uf040\<Esc>" |
103 | 108 | call assert_equal("abcd", getline(1)) |
104 | 109 | endfunction |
110 | + | |
111 | +" vim: shiftwidth=2 sts=2 expandtab |
@@ -492,3 +492,76 @@ | ||
492 | 492 | call StopVimInTerminal(buf) |
493 | 493 | call delete('XtestExprMap') |
494 | 494 | 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 |
@@ -743,6 +743,8 @@ | ||
743 | 743 | static int included_patches[] = |
744 | 744 | { /* Add new patch number below this line */ |
745 | 745 | /**/ |
746 | + 134, | |
747 | +/**/ | |
746 | 748 | 133, |
747 | 749 | /**/ |
748 | 750 | 132, |