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 let sid = s:SID() 17 let lnum = expand('<sflnum>') 18 map foo<C-V> is<F4>foo 19 vnoremap <script> <buffer> <expr> <silent> bar isbar 20 call assert_equal("is<F4>foo", maparg('foo<C-V>')) 21 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 22 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 23 \ 'rhs': 'is<F4>foo', 'buffer': 0}, 24 \ maparg('foo<C-V>', '', 0, 1)) 25 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 26 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, 27 \ 'rhs': 'isbar', 'buffer': 1}, 28 \ maparg('bar', '', 0, 1)) 29 let lnum = expand('<sflnum>') 30 map <buffer> <nowait> foo bar 31 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 32 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', 33 \ 'buffer': 1}, 34 \ maparg('foo', '', 0, 1)) 35 36 map abc x<char-114>x 37 call assert_equal("xrx", maparg('abc')) 38 map abc y<S-char-114>y 39 call assert_equal("yRy", maparg('abc')) 40 41 map abc <Nop> 42 call assert_equal("<Nop>", maparg('abc')) 43 unmap abc 44endfunction 45 46function Test_range_map() 47 new 48 " Outside of the range, minimum 49 inoremap <Char-0x1040> a 50 execute "normal a\u1040\<Esc>" 51 " Inside of the range, minimum 52 inoremap <Char-0x103f> b 53 execute "normal a\u103f\<Esc>" 54 " Inside of the range, maximum 55 inoremap <Char-0xf03f> c 56 execute "normal a\uf03f\<Esc>" 57 " Outside of the range, maximum 58 inoremap <Char-0xf040> d 59 execute "normal a\uf040\<Esc>" 60 call assert_equal("abcd", getline(1)) 61endfunction 62