Mercurial > vim
comparison src/testdir/test_maparg.vim @ 17930:0cdb6ac20748 v8.1.1961
patch 8.1.1961: more functions can be used as a method
Commit: https://github.com/vim/vim/commit/a1449836334355b1fb00cd1bf083e7d353f6c4d7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 1 20:16:52 2019 +0200
patch 8.1.1961: more functions can be used as a method
Problem: More functions can be used as a method.
Solution: Allow more functions to be used as a method. Add a test for
mapcheck().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Sep 2019 20:30:04 +0200 |
parents | e17cbc3e545d |
children | 643c6c3c0da4 |
comparison
equal
deleted
inserted
replaced
17929:3d3ccf634254 | 17930:0cdb6ac20748 |
---|---|
1 " Tests for maparg(). | 1 " Tests for maparg(). |
2 " Also test utf8 map with a 0x80 byte. | 2 " Also test utf8 map with a 0x80 byte. |
3 " Also test mapcheck() | |
3 | 4 |
4 function s:SID() | 5 function s:SID() |
5 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) | 6 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) |
6 endfun | 7 endfun |
7 | 8 |
20 \ 'rhs': 'is<F4>foo', 'buffer': 0}, | 21 \ 'rhs': 'is<F4>foo', 'buffer': 0}, |
21 \ maparg('foo<C-V>', '', 0, 1)) | 22 \ maparg('foo<C-V>', '', 0, 1)) |
22 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', | 23 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', |
23 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, | 24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, |
24 \ 'rhs': 'isbar', 'buffer': 1}, | 25 \ 'rhs': 'isbar', 'buffer': 1}, |
25 \ maparg('bar', '', 0, 1)) | 26 \ 'bar'->maparg('', 0, 1)) |
26 let lnum = expand('<sflnum>') | 27 let lnum = expand('<sflnum>') |
27 map <buffer> <nowait> foo bar | 28 map <buffer> <nowait> foo bar |
28 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', | 29 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', |
29 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', | 30 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', |
30 \ 'buffer': 1}, | 31 \ 'buffer': 1}, |
44 map abc <Nop> | 45 map abc <Nop> |
45 call assert_equal("<Nop>", maparg('abc')) | 46 call assert_equal("<Nop>", maparg('abc')) |
46 unmap abc | 47 unmap abc |
47 endfunction | 48 endfunction |
48 | 49 |
50 func Test_mapcheck() | |
51 call assert_equal('', mapcheck('a')) | |
52 call assert_equal('', mapcheck('abc')) | |
53 call assert_equal('', mapcheck('ax')) | |
54 call assert_equal('', mapcheck('b')) | |
55 | |
56 map a something | |
57 call assert_equal('something', mapcheck('a')) | |
58 call assert_equal('something', mapcheck('a', 'n')) | |
59 call assert_equal('', mapcheck('a', 'c')) | |
60 call assert_equal('', mapcheck('a', 'i')) | |
61 call assert_equal('something', 'abc'->mapcheck()) | |
62 call assert_equal('something', 'ax'->mapcheck()) | |
63 call assert_equal('', mapcheck('b')) | |
64 unmap a | |
65 | |
66 map ab foobar | |
67 call assert_equal('foobar', mapcheck('a')) | |
68 call assert_equal('foobar', mapcheck('abc')) | |
69 call assert_equal('', mapcheck('ax')) | |
70 call assert_equal('', mapcheck('b')) | |
71 unmap ab | |
72 | |
73 map abc barfoo | |
74 call assert_equal('barfoo', mapcheck('a')) | |
75 call assert_equal('barfoo', mapcheck('a', 'n', 0)) | |
76 call assert_equal('', mapcheck('a', 'n', 1)) | |
77 call assert_equal('barfoo', mapcheck('abc')) | |
78 call assert_equal('', mapcheck('ax')) | |
79 call assert_equal('', mapcheck('b')) | |
80 unmap abc | |
81 | |
82 abbr ab abbrev | |
83 call assert_equal('abbrev', mapcheck('a', 'i', 1)) | |
84 call assert_equal('', mapcheck('a', 'n', 1)) | |
85 call assert_equal('', mapcheck('a', 'i', 0)) | |
86 unabbr ab | |
87 endfunc | |
88 | |
49 function Test_range_map() | 89 function Test_range_map() |
50 new | 90 new |
51 " Outside of the range, minimum | 91 " Outside of the range, minimum |
52 inoremap <Char-0x1040> a | 92 inoremap <Char-0x1040> a |
53 execute "normal a\u1040\<Esc>" | 93 execute "normal a\u1040\<Esc>" |