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