forked from aniani/vim
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Problem: Vim9: cannot pass "true" to win_splitmove(). Solution: Use dict_get_bool(). (closes #6862) Alphabetize test functions.
This commit is contained in:
parent
fcb6d7082d
commit
4b9bd692bd
@ -832,10 +832,10 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
d = argvars[2].vval.v_dict;
|
||||
if (dict_get_number(d, (char_u *)"vertical"))
|
||||
if (dict_get_bool(d, (char_u *)"vertical", FALSE))
|
||||
flags |= WSP_VERT;
|
||||
if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL)
|
||||
flags |= tv_get_number(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
|
||||
flags |= tv_get_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
|
||||
size = (int)dict_get_number(d, (char_u *)"size");
|
||||
}
|
||||
|
||||
|
@ -1408,41 +1408,14 @@ func Test_silent_echo()
|
||||
call delete('XTest_silent_echo')
|
||||
endfunc
|
||||
|
||||
def Test_search()
|
||||
new
|
||||
setline(1, ['foo', 'bar'])
|
||||
let val = 0
|
||||
# skip expr returns boolean
|
||||
assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
|
||||
:1
|
||||
assert_equal(0, search('bar', 'W', 0, 0, {-> val == 0}))
|
||||
# skip expr returns number, only 0 and 1 are accepted
|
||||
:1
|
||||
assert_equal(2, search('bar', 'W', 0, 0, {-> 0}))
|
||||
:1
|
||||
assert_equal(0, search('bar', 'W', 0, 0, {-> 1}))
|
||||
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
|
||||
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
|
||||
enddef
|
||||
""""""" builtin functions that behave differently in Vim9
|
||||
|
||||
def Test_readdir()
|
||||
eval expand('sautest')->readdir({e -> e[0] !=# '.'})
|
||||
eval expand('sautest')->readdirex({e -> e.name[0] !=# '.'})
|
||||
enddef
|
||||
|
||||
def Test_setbufvar()
|
||||
setbufvar(bufnr('%'), '&syntax', 'vim')
|
||||
assert_equal('vim', &syntax)
|
||||
setbufvar(bufnr('%'), '&ts', 16)
|
||||
assert_equal(16, &ts)
|
||||
settabwinvar(1, 1, '&syntax', 'vam')
|
||||
assert_equal('vam', &syntax)
|
||||
settabwinvar(1, 1, '&ts', 15)
|
||||
assert_equal(15, &ts)
|
||||
setlocal ts=8
|
||||
|
||||
setbufvar('%', 'myvar', 123)
|
||||
assert_equal(123, getbufvar('%', 'myvar'))
|
||||
def Test_bufname()
|
||||
split SomeFile
|
||||
assert_equal('SomeFile', bufname('%'))
|
||||
edit OtherFile
|
||||
assert_equal('SomeFile', bufname('#'))
|
||||
close
|
||||
enddef
|
||||
|
||||
def Test_bufwinid()
|
||||
@ -1459,6 +1432,29 @@ def Test_bufwinid()
|
||||
bwipe OtherFile
|
||||
enddef
|
||||
|
||||
def Test_count()
|
||||
assert_equal(3, count('ABC ABC ABC', 'b', true))
|
||||
assert_equal(0, count('ABC ABC ABC', 'b', false))
|
||||
enddef
|
||||
|
||||
def Test_expand()
|
||||
split SomeFile
|
||||
assert_equal(['SomeFile'], expand('%', true, true))
|
||||
close
|
||||
enddef
|
||||
|
||||
def Test_getbufinfo()
|
||||
let bufinfo = getbufinfo(bufnr())
|
||||
assert_equal(bufinfo, getbufinfo('%'))
|
||||
|
||||
edit Xtestfile1
|
||||
hide edit Xtestfile2
|
||||
hide enew
|
||||
getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false})
|
||||
->len()->assert_equal(3)
|
||||
bwipe Xtestfile1 Xtestfile2
|
||||
enddef
|
||||
|
||||
def Test_getbufline()
|
||||
e SomeFile
|
||||
let buf = bufnr()
|
||||
@ -1478,33 +1474,6 @@ def Test_getchangelist()
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
def Test_setreg()
|
||||
setreg('a', ['aaa', 'bbb', 'ccc'])
|
||||
let reginfo = getreginfo('a')
|
||||
setreg('a', reginfo)
|
||||
assert_equal(reginfo, getreginfo('a'))
|
||||
enddef
|
||||
|
||||
def Test_bufname()
|
||||
split SomeFile
|
||||
assert_equal('SomeFile', bufname('%'))
|
||||
edit OtherFile
|
||||
assert_equal('SomeFile', bufname('#'))
|
||||
close
|
||||
enddef
|
||||
|
||||
def Test_getbufinfo()
|
||||
let bufinfo = getbufinfo(bufnr())
|
||||
assert_equal(bufinfo, getbufinfo('%'))
|
||||
|
||||
edit Xtestfile1
|
||||
hide edit Xtestfile2
|
||||
hide enew
|
||||
getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false})
|
||||
->len()->assert_equal(3)
|
||||
bwipe Xtestfile1 Xtestfile2
|
||||
enddef
|
||||
|
||||
def Test_getchar()
|
||||
while getchar(0)
|
||||
endwhile
|
||||
@ -1518,69 +1487,6 @@ def Test_getcompletion()
|
||||
set wildignore&
|
||||
enddef
|
||||
|
||||
def Test_has()
|
||||
assert_equal(1, has('eval', true))
|
||||
enddef
|
||||
|
||||
def Test_list2str_str2list_utf8()
|
||||
let s = "\u3042\u3044"
|
||||
let l = [0x3042, 0x3044]
|
||||
assert_equal(l, str2list(s, true))
|
||||
assert_equal(s, list2str(l, true))
|
||||
enddef
|
||||
|
||||
def Test_nr2char()
|
||||
assert_equal('a', nr2char(97, true))
|
||||
enddef
|
||||
|
||||
def Test_searchcount()
|
||||
new
|
||||
setline(1, "foo bar")
|
||||
:/foo
|
||||
assert_equal(#{
|
||||
exact_match: 1,
|
||||
current: 1,
|
||||
total: 1,
|
||||
maxcount: 99,
|
||||
incomplete: 0,
|
||||
}, searchcount(#{recompute: true}))
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
def Test_searchdecl()
|
||||
assert_equal(1, searchdecl('blah', true, true))
|
||||
enddef
|
||||
|
||||
def Test_synID()
|
||||
new
|
||||
setline(1, "text")
|
||||
assert_equal(0, synID(1, 1, true))
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
def Fibonacci(n: number): number
|
||||
if n < 2
|
||||
return n
|
||||
else
|
||||
return Fibonacci(n - 1) + Fibonacci(n - 2)
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_count()
|
||||
assert_equal(3, count('ABC ABC ABC', 'b', true))
|
||||
assert_equal(0, count('ABC ABC ABC', 'b', false))
|
||||
enddef
|
||||
|
||||
def Test_index()
|
||||
assert_equal(3, index(['a', 'b', 'a', 'B'], 'b', 2, true))
|
||||
enddef
|
||||
|
||||
def Test_expand()
|
||||
split SomeFile
|
||||
assert_equal(['SomeFile'], expand('%', true, true))
|
||||
close
|
||||
enddef
|
||||
|
||||
def Test_getreg()
|
||||
let lines = ['aaa', 'bbb', 'ccc']
|
||||
setreg('a', lines)
|
||||
@ -1595,6 +1501,10 @@ def Test_globpath()
|
||||
assert_equal(['./runtest.vim'], globpath('.', 'runtest.vim', true, true, true))
|
||||
enddef
|
||||
|
||||
def Test_has()
|
||||
assert_equal(1, has('eval', true))
|
||||
enddef
|
||||
|
||||
def Test_hasmapto()
|
||||
assert_equal(0, hasmapto('foobar', 'i', true))
|
||||
iabbrev foo foobar
|
||||
@ -1602,6 +1512,17 @@ def Test_hasmapto()
|
||||
iunabbrev foo
|
||||
enddef
|
||||
|
||||
def Test_index()
|
||||
assert_equal(3, index(['a', 'b', 'a', 'B'], 'b', 2, true))
|
||||
enddef
|
||||
|
||||
def Test_list2str_str2list_utf8()
|
||||
let s = "\u3042\u3044"
|
||||
let l = [0x3042, 0x3044]
|
||||
assert_equal(l, str2list(s, true))
|
||||
assert_equal(s, list2str(l, true))
|
||||
enddef
|
||||
|
||||
def SID(): number
|
||||
return expand('<SID>')
|
||||
->matchstr('<SNR>\zs\d\+\ze_$')
|
||||
@ -1634,6 +1555,95 @@ def Test_mapcheck()
|
||||
iunabbrev foo
|
||||
enddef
|
||||
|
||||
def Test_nr2char()
|
||||
assert_equal('a', nr2char(97, true))
|
||||
enddef
|
||||
|
||||
def Test_readdir()
|
||||
eval expand('sautest')->readdir({e -> e[0] !=# '.'})
|
||||
eval expand('sautest')->readdirex({e -> e.name[0] !=# '.'})
|
||||
enddef
|
||||
|
||||
def Test_search()
|
||||
new
|
||||
setline(1, ['foo', 'bar'])
|
||||
let val = 0
|
||||
# skip expr returns boolean
|
||||
assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
|
||||
:1
|
||||
assert_equal(0, search('bar', 'W', 0, 0, {-> val == 0}))
|
||||
# skip expr returns number, only 0 and 1 are accepted
|
||||
:1
|
||||
assert_equal(2, search('bar', 'W', 0, 0, {-> 0}))
|
||||
:1
|
||||
assert_equal(0, search('bar', 'W', 0, 0, {-> 1}))
|
||||
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
|
||||
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
|
||||
enddef
|
||||
|
||||
def Test_searchcount()
|
||||
new
|
||||
setline(1, "foo bar")
|
||||
:/foo
|
||||
assert_equal(#{
|
||||
exact_match: 1,
|
||||
current: 1,
|
||||
total: 1,
|
||||
maxcount: 99,
|
||||
incomplete: 0,
|
||||
}, searchcount(#{recompute: true}))
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
def Test_searchdecl()
|
||||
assert_equal(1, searchdecl('blah', true, true))
|
||||
enddef
|
||||
|
||||
def Test_setbufvar()
|
||||
setbufvar(bufnr('%'), '&syntax', 'vim')
|
||||
assert_equal('vim', &syntax)
|
||||
setbufvar(bufnr('%'), '&ts', 16)
|
||||
assert_equal(16, &ts)
|
||||
settabwinvar(1, 1, '&syntax', 'vam')
|
||||
assert_equal('vam', &syntax)
|
||||
settabwinvar(1, 1, '&ts', 15)
|
||||
assert_equal(15, &ts)
|
||||
setlocal ts=8
|
||||
|
||||
setbufvar('%', 'myvar', 123)
|
||||
assert_equal(123, getbufvar('%', 'myvar'))
|
||||
enddef
|
||||
|
||||
def Test_setreg()
|
||||
setreg('a', ['aaa', 'bbb', 'ccc'])
|
||||
let reginfo = getreginfo('a')
|
||||
setreg('a', reginfo)
|
||||
assert_equal(reginfo, getreginfo('a'))
|
||||
enddef
|
||||
|
||||
def Test_synID()
|
||||
new
|
||||
setline(1, "text")
|
||||
assert_equal(0, synID(1, 1, true))
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
def Test_win_splitmove()
|
||||
split
|
||||
win_splitmove(1, 2, #{vertical: true, rightbelow: true})
|
||||
close
|
||||
enddef
|
||||
|
||||
""""""" end of builtin functions
|
||||
|
||||
def Fibonacci(n: number): number
|
||||
if n < 2
|
||||
return n
|
||||
else
|
||||
return Fibonacci(n - 1) + Fibonacci(n - 2)
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_recursive_call()
|
||||
assert_equal(6765, Fibonacci(20))
|
||||
enddef
|
||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1617,
|
||||
/**/
|
||||
1616,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user