1" Tests for maparg(). 2" Also test utf8 map with a 0x80 byte. 3if !has("multi_byte") 4 finish 5endif 6 7function s:SID() 8 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) 9endfun 10 11function Test_maparg() 12 new 13 set cpo-=< 14 set encoding=utf8 15 " Test maparg() with a string result 16 map foo<C-V> is<F4>foo 17 vnoremap <script> <buffer> <expr> <silent> bar isbar 18 let sid = s:SID() 19 call assert_equal("is<F4>foo", maparg('foo<C-V>')) 20 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 21 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'rhs': 'is<F4>foo', 22 \ 'buffer': 0}, maparg('foo<C-V>', '', 0, 1)) 23 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'rhs': 'isbar', 'buffer': 1}, 25 \ maparg('bar', '', 0, 1)) 26 map <buffer> <nowait> foo bar 27 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 28 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'rhs': 'bar', 'buffer': 1}, 29 \ maparg('foo', '', 0, 1)) 30 31 map abc x<char-114>x 32 call assert_equal("xrx", maparg('abc')) 33 map abc y<S-char-114>y 34 call assert_equal("yRy", maparg('abc')) 35 36 map abc <Nop> 37 call assert_equal("<Nop>", maparg('abc')) 38 unmap abc 39endfunction 40 41function Test_range_map() 42 new 43 " Outside of the range, minimum 44 inoremap <Char-0x1040> a 45 execute "normal a\u1040\<Esc>" 46 " Inside of the range, minimum 47 inoremap <Char-0x103f> b 48 execute "normal a\u103f\<Esc>" 49 " Inside of the range, maximum 50 inoremap <Char-0xf03f> c 51 execute "normal a\uf03f\<Esc>" 52 " Outside of the range, maximum 53 inoremap <Char-0xf040> d 54 execute "normal a\uf040\<Esc>" 55 call assert_equal("abcd", getline(1)) 56endfunction 57