annotate src/testdir/test_maparg.vim @ 14441:2d6703d4448a v8.1.0234

patch 8.1.0234: incorrect reference counting in Perl interface commit https://github.com/vim/vim/commit/41c363a3154dd1caeb431fa54748ad48ef6d3bd1 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 2 21:46:51 2018 +0200 patch 8.1.0234: incorrect reference counting in Perl interface Problem: Incorrect reference counting in Perl interface. Solution: Call SvREFCNT_inc more often, add a test. (Damien)
author Christian Brabandt <cb@256bit.org>
date Thu, 02 Aug 2018 22:00:06 +0200
parents 4a41a169e5ea
children 0a3b9ecf7cb8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for maparg().
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Also test utf8 map with a 0x80 byte.
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has("multi_byte")
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 function s:SID()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endfun
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 function Test_maparg()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 new
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 set cpo-=<
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 set encoding=utf8
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 " Test maparg() with a string result
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 map foo<C-V> is<F4>foo
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 vnoremap <script> <buffer> <expr> <silent> bar isbar
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let sid = s:SID()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal("is<F4>foo", maparg('foo<C-V>'))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>',
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'rhs': 'is<F4>foo',
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 \ 'buffer': 0}, maparg('foo<C-V>', '', 0, 1))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v',
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'rhs': 'isbar', 'buffer': 1},
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 \ maparg('bar', '', 0, 1))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 map <buffer> <nowait> foo bar
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ',
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'rhs': 'bar', 'buffer': 1},
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 \ maparg('foo', '', 0, 1))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 map abc x<char-114>x
13986
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
32 call assert_equal("xrx", maparg('abc'))
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 map abc y<S-char-114>y
13986
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
34 call assert_equal("yRy", maparg('abc'))
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
35
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
36 map abc <Nop>
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
37 call assert_equal("<Nop>", maparg('abc'))
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
38 unmap abc
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 endfunction
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 function Test_range_map()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 new
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 " Outside of the range, minimum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 inoremap <Char-0x1040> a
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 execute "normal a\u1040\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 " Inside of the range, minimum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 inoremap <Char-0x103f> b
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 execute "normal a\u103f\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 " Inside of the range, maximum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 inoremap <Char-0xf03f> c
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 execute "normal a\uf03f\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 " Outside of the range, maximum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 inoremap <Char-0xf040> d
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 execute "normal a\uf040\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal("abcd", getline(1))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunction