summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-01 20:16:52 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-01 20:16:52 +0200
commita1449836334355b1fb00cd1bf083e7d353f6c4d7 (patch)
treef9623248fa3e1044acb35c25f155b7649f03c2b6 /src
parentdb022f3ffb57c5ff4b97b4e93a994d11e4c10466 (diff)
patch 8.1.1961: more functions can be used as a methodv8.1.1961
Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method. Add a test for mapcheck().
Diffstat (limited to 'src')
-rw-r--r--src/evalfunc.c28
-rw-r--r--src/testdir/test70.in2
-rw-r--r--src/testdir/test_functions.vim14
-rw-r--r--src/testdir/test_getcwd.vim2
-rw-r--r--src/testdir/test_maparg.vim42
-rw-r--r--src/testdir/test_match.vim8
-rw-r--r--src/version.c2
7 files changed, 70 insertions, 28 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 840b89a0cb..53f5e6da11 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -655,23 +655,23 @@ static funcentry_T global_functions[] =
{"luaeval", 1, 2, FEARG_1, f_luaeval},
#endif
{"map", 2, 2, FEARG_1, f_map},
- {"maparg", 1, 4, 0, f_maparg},
- {"mapcheck", 1, 3, 0, f_mapcheck},
- {"match", 2, 4, 0, f_match},
- {"matchadd", 2, 5, 0, f_matchadd},
- {"matchaddpos", 2, 5, 0, f_matchaddpos},
- {"matcharg", 1, 1, 0, f_matcharg},
- {"matchdelete", 1, 2, 0, f_matchdelete},
- {"matchend", 2, 4, 0, f_matchend},
- {"matchlist", 2, 4, 0, f_matchlist},
- {"matchstr", 2, 4, 0, f_matchstr},
- {"matchstrpos", 2, 4, 0, f_matchstrpos},
+ {"maparg", 1, 4, FEARG_1, f_maparg},
+ {"mapcheck", 1, 3, FEARG_1, f_mapcheck},
+ {"match", 2, 4, FEARG_1, f_match},
+ {"matchadd", 2, 5, FEARG_1, f_matchadd},
+ {"matchaddpos", 2, 5, FEARG_1, f_matchaddpos},
+ {"matcharg", 1, 1, FEARG_1, f_matcharg},
+ {"matchdelete", 1, 2, FEARG_1, f_matchdelete},
+ {"matchend", 2, 4, FEARG_1, f_matchend},
+ {"matchlist", 2, 4, FEARG_1, f_matchlist},
+ {"matchstr", 2, 4, FEARG_1, f_matchstr},
+ {"matchstrpos", 2, 4, FEARG_1, f_matchstrpos},
{"max", 1, 1, FEARG_1, f_max},
{"min", 1, 1, FEARG_1, f_min},
- {"mkdir", 1, 3, 0, f_mkdir},
- {"mode", 0, 1, 0, f_mode},
+ {"mkdir", 1, 3, FEARG_1, f_mkdir},
+ {"mode", 0, 1, FEARG_1, f_mode},
#ifdef FEAT_MZSCHEME
- {"mzeval", 1, 1, 0, f_mzeval},
+ {"mzeval", 1, 1, FEARG_1, f_mzeval},
#endif
{"nextnonblank", 1, 1, 0, f_nextnonblank},
{"nr2char", 1, 2, 0, f_nr2char},
diff --git a/src/testdir/test70.in b/src/testdir/test70.in
index 9fbe818b3d..9ee59c3a28 100644
--- a/src/testdir/test70.in
+++ b/src/testdir/test70.in
@@ -25,7 +25,7 @@ STARTTEST
:mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
:" scalar test
:let tmp_string = mzeval('"string"')
-:let tmp_1000 = mzeval('1000')
+:let tmp_1000 = '1000'->mzeval()
:if tmp_string . tmp_1000 == "string1000"
:let scalar_res = "OK"
:else
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 926713e87a..6984c23cce 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -655,8 +655,8 @@ func Test_mode()
exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
- call assert_equal('n', mode(0))
- call assert_equal('n', mode(1))
+ call assert_equal('n', 0->mode())
+ call assert_equal('n', 1->mode())
" i_CTRL-O
exe "normal i\<C-O>:call Save_mode()\<Cr>\<Esc>"
@@ -793,7 +793,7 @@ endfunc
func Test_match_func()
call assert_equal(4, match('testing', 'ing'))
- call assert_equal(4, match('testing', 'ing', 2))
+ call assert_equal(4, 'testing'->match('ing', 2))
call assert_equal(-1, match('testing', 'ing', 5))
call assert_equal(-1, match('testing', 'ing', 8))
call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing'))
@@ -802,7 +802,7 @@ endfunc
func Test_matchend()
call assert_equal(7, matchend('testing', 'ing'))
- call assert_equal(7, matchend('testing', 'ing', 2))
+ call assert_equal(7, 'testing'->matchend('ing', 2))
call assert_equal(-1, matchend('testing', 'ing', 5))
call assert_equal(-1, matchend('testing', 'ing', 8))
call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing'))
@@ -811,13 +811,13 @@ endfunc
func Test_matchlist()
call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
- call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
+ call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], 'acd'->matchlist('\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4))
endfunc
func Test_matchstr()
call assert_equal('ing', matchstr('testing', 'ing'))
- call assert_equal('ing', matchstr('testing', 'ing', 2))
+ call assert_equal('ing', 'testing'->matchstr('ing', 2))
call assert_equal('', matchstr('testing', 'ing', 5))
call assert_equal('', matchstr('testing', 'ing', 8))
call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing'))
@@ -826,7 +826,7 @@ endfunc
func Test_matchstrpos()
call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
- call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
+ call assert_equal(['ing', 4, 7], 'testing'->matchstrpos('ing', 2))
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
diff --git a/src/testdir/test_getcwd.vim b/src/testdir/test_getcwd.vim
index e732546611..b1470d76b7 100644
--- a/src/testdir/test_getcwd.vim
+++ b/src/testdir/test_getcwd.vim
@@ -35,7 +35,7 @@ function SetUp()
" we start from a clean state.
call delete("Xtopdir", "rf")
new
- call mkdir('Xtopdir')
+ eval 'Xtopdir'->mkdir()
cd Xtopdir
let g:topdir = getcwd()
call mkdir('Xdir1')
diff --git a/src/testdir/test_maparg.vim b/src/testdir/test_maparg.vim
index f7524f56d9..0284f31cbb 100644
--- a/src/testdir/test_maparg.vim
+++ b/src/testdir/test_maparg.vim
@@ -1,5 +1,6 @@
" Tests for maparg().
" Also test utf8 map with a 0x80 byte.
+" Also test mapcheck()
function s:SID()
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
@@ -22,7 +23,7 @@ function Test_maparg()
call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
\ 'rhs': 'isbar', 'buffer': 1},
- \ maparg('bar', '', 0, 1))
+ \ 'bar'->maparg('', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ',
@@ -46,6 +47,45 @@ function Test_maparg()
unmap abc
endfunction
+func Test_mapcheck()
+ call assert_equal('', mapcheck('a'))
+ call assert_equal('', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+
+ map a something
+ call assert_equal('something', mapcheck('a'))
+ call assert_equal('something', mapcheck('a', 'n'))
+ call assert_equal('', mapcheck('a', 'c'))
+ call assert_equal('', mapcheck('a', 'i'))
+ call assert_equal('something', 'abc'->mapcheck())
+ call assert_equal('something', 'ax'->mapcheck())
+ call assert_equal('', mapcheck('b'))
+ unmap a
+
+ map ab foobar
+ call assert_equal('foobar', mapcheck('a'))
+ call assert_equal('foobar', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+ unmap ab
+
+ map abc barfoo
+ call assert_equal('barfoo', mapcheck('a'))
+ call assert_equal('barfoo', mapcheck('a', 'n', 0))
+ call assert_equal('', mapcheck('a', 'n', 1))
+ call assert_equal('barfoo', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+ unmap abc
+
+ abbr ab abbrev
+ call assert_equal('abbrev', mapcheck('a', 'i', 1))
+ call assert_equal('', mapcheck('a', 'n', 1))
+ call assert_equal('', mapcheck('a', 'i', 0))
+ unabbr ab
+endfunc
+
function Test_range_map()
new
" Outside of the range, minimum
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 0bc186375d..f55922b3e0 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -15,7 +15,7 @@ function Test_match()
2match MyGroup2 /FIXME/
3match MyGroup3 /XXX/
call assert_equal(['MyGroup1', 'TODO'], matcharg(1))
- call assert_equal(['MyGroup2', 'FIXME'], matcharg(2))
+ call assert_equal(['MyGroup2', 'FIXME'], 2->matcharg())
call assert_equal(['MyGroup3', 'XXX'], matcharg(3))
" --- Check that "matcharg()" returns an empty list if the argument is not 1,
@@ -44,7 +44,7 @@ function Test_match()
" --- Check that "matchdelete()" deletes the matches defined in the previous
" --- test correctly.
call matchdelete(m1)
- call matchdelete(m2)
+ eval m2->matchdelete()
call matchdelete(m3)
call assert_equal([], getmatches())
@@ -56,7 +56,7 @@ function Test_match()
" --- Check that "clearmatches()" clears all matches defined by ":match" and
" --- "matchadd()".
let m1 = matchadd("MyGroup1", "TODO")
- let m2 = matchadd("MyGroup2", "FIXME", 42)
+ let m2 = "MyGroup2"->matchadd("FIXME", 42)
let m3 = matchadd("MyGroup3", "XXX", 60, 17)
match MyGroup1 /COFFEE/
2match MyGroup2 /HUMPPA/
@@ -118,7 +118,7 @@ function Test_match()
call clearmatches()
call setline(1, 'abcdΣabcdef')
- call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
+ eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]])
1
redraw!
let v1 = screenattr(1, 1)
diff --git a/src/version.c b/src/version.c
index 443531443c..6b30e7cf55 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1961,
+/**/
1960,
/**/
1959,