Skip to content

Commit 4b9bd69

Browse files
committed
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.
1 parent fcb6d70 commit 4b9bd69

3 files changed

Lines changed: 138 additions & 126 deletions

File tree

src/evalwindow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,10 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv)
832832
}
833833

834834
d = argvars[2].vval.v_dict;
835-
if (dict_get_number(d, (char_u *)"vertical"))
835+
if (dict_get_bool(d, (char_u *)"vertical", FALSE))
836836
flags |= WSP_VERT;
837837
if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL)
838-
flags |= tv_get_number(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
838+
flags |= tv_get_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
839839
size = (int)dict_get_number(d, (char_u *)"size");
840840
}
841841

src/testdir/test_vim9_func.vim

Lines changed: 134 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,41 +1408,14 @@ func Test_silent_echo()
14081408
call delete('XTest_silent_echo')
14091409
endfunc
14101410

1411-
def Test_search()
1412-
new
1413-
setline(1, ['foo', 'bar'])
1414-
let val = 0
1415-
# skip expr returns boolean
1416-
assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
1417-
:1
1418-
assert_equal(0, search('bar', 'W', 0, 0, {-> val == 0}))
1419-
# skip expr returns number, only 0 and 1 are accepted
1420-
:1
1421-
assert_equal(2, search('bar', 'W', 0, 0, {-> 0}))
1422-
:1
1423-
assert_equal(0, search('bar', 'W', 0, 0, {-> 1}))
1424-
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
1425-
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
1426-
enddef
1427-
1428-
def Test_readdir()
1429-
eval expand('sautest')->readdir({e -> e[0] !=# '.'})
1430-
eval expand('sautest')->readdirex({e -> e.name[0] !=# '.'})
1431-
enddef
1432-
1433-
def Test_setbufvar()
1434-
setbufvar(bufnr('%'), '&syntax', 'vim')
1435-
assert_equal('vim', &syntax)
1436-
setbufvar(bufnr('%'), '&ts', 16)
1437-
assert_equal(16, &ts)
1438-
settabwinvar(1, 1, '&syntax', 'vam')
1439-
assert_equal('vam', &syntax)
1440-
settabwinvar(1, 1, '&ts', 15)
1441-
assert_equal(15, &ts)
1442-
setlocal ts=8
1411+
""""""" builtin functions that behave differently in Vim9
14431412

1444-
setbufvar('%', 'myvar', 123)
1445-
assert_equal(123, getbufvar('%', 'myvar'))
1413+
def Test_bufname()
1414+
split SomeFile
1415+
assert_equal('SomeFile', bufname('%'))
1416+
edit OtherFile
1417+
assert_equal('SomeFile', bufname('#'))
1418+
close
14461419
enddef
14471420

14481421
def Test_bufwinid()
@@ -1459,6 +1432,29 @@ def Test_bufwinid()
14591432
bwipe OtherFile
14601433
enddef
14611434

1435+
def Test_count()
1436+
assert_equal(3, count('ABC ABC ABC', 'b', true))
1437+
assert_equal(0, count('ABC ABC ABC', 'b', false))
1438+
enddef
1439+
1440+
def Test_expand()
1441+
split SomeFile
1442+
assert_equal(['SomeFile'], expand('%', true, true))
1443+
close
1444+
enddef
1445+
1446+
def Test_getbufinfo()
1447+
let bufinfo = getbufinfo(bufnr())
1448+
assert_equal(bufinfo, getbufinfo('%'))
1449+
1450+
edit Xtestfile1
1451+
hide edit Xtestfile2
1452+
hide enew
1453+
getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false})
1454+
->len()->assert_equal(3)
1455+
bwipe Xtestfile1 Xtestfile2
1456+
enddef
1457+
14621458
def Test_getbufline()
14631459
e SomeFile
14641460
let buf = bufnr()
@@ -1478,33 +1474,6 @@ def Test_getchangelist()
14781474
bwipe!
14791475
enddef
14801476

1481-
def Test_setreg()
1482-
setreg('a', ['aaa', 'bbb', 'ccc'])
1483-
let reginfo = getreginfo('a')
1484-
setreg('a', reginfo)
1485-
assert_equal(reginfo, getreginfo('a'))
1486-
enddef
1487-
1488-
def Test_bufname()
1489-
split SomeFile
1490-
assert_equal('SomeFile', bufname('%'))
1491-
edit OtherFile
1492-
assert_equal('SomeFile', bufname('#'))
1493-
close
1494-
enddef
1495-
1496-
def Test_getbufinfo()
1497-
let bufinfo = getbufinfo(bufnr())
1498-
assert_equal(bufinfo, getbufinfo('%'))
1499-
1500-
edit Xtestfile1
1501-
hide edit Xtestfile2
1502-
hide enew
1503-
getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false})
1504-
->len()->assert_equal(3)
1505-
bwipe Xtestfile1 Xtestfile2
1506-
enddef
1507-
15081477
def Test_getchar()
15091478
while getchar(0)
15101479
endwhile
@@ -1518,69 +1487,6 @@ def Test_getcompletion()
15181487
set wildignore&
15191488
enddef
15201489

1521-
def Test_has()
1522-
assert_equal(1, has('eval', true))
1523-
enddef
1524-
1525-
def Test_list2str_str2list_utf8()
1526-
let s = "\u3042\u3044"
1527-
let l = [0x3042, 0x3044]
1528-
assert_equal(l, str2list(s, true))
1529-
assert_equal(s, list2str(l, true))
1530-
enddef
1531-
1532-
def Test_nr2char()
1533-
assert_equal('a', nr2char(97, true))
1534-
enddef
1535-
1536-
def Test_searchcount()
1537-
new
1538-
setline(1, "foo bar")
1539-
:/foo
1540-
assert_equal(#{
1541-
exact_match: 1,
1542-
current: 1,
1543-
total: 1,
1544-
maxcount: 99,
1545-
incomplete: 0,
1546-
}, searchcount(#{recompute: true}))
1547-
bwipe!
1548-
enddef
1549-
1550-
def Test_searchdecl()
1551-
assert_equal(1, searchdecl('blah', true, true))
1552-
enddef
1553-
1554-
def Test_synID()
1555-
new
1556-
setline(1, "text")
1557-
assert_equal(0, synID(1, 1, true))
1558-
bwipe!
1559-
enddef
1560-
1561-
def Fibonacci(n: number): number
1562-
if n < 2
1563-
return n
1564-
else
1565-
return Fibonacci(n - 1) + Fibonacci(n - 2)
1566-
endif
1567-
enddef
1568-
1569-
def Test_count()
1570-
assert_equal(3, count('ABC ABC ABC', 'b', true))
1571-
assert_equal(0, count('ABC ABC ABC', 'b', false))
1572-
enddef
1573-
1574-
def Test_index()
1575-
assert_equal(3, index(['a', 'b', 'a', 'B'], 'b', 2, true))
1576-
enddef
1577-
1578-
def Test_expand()
1579-
split SomeFile
1580-
assert_equal(['SomeFile'], expand('%', true, true))
1581-
close
1582-
enddef
1583-
15841490
def Test_getreg()
15851491
let lines = ['aaa', 'bbb', 'ccc']
15861492
setreg('a', lines)
@@ -1595,13 +1501,28 @@ def Test_globpath()
15951501
assert_equal(['./runtest.vim'], globpath('.', 'runtest.vim', true, true, true))
15961502
enddef
15971503

1504+
def Test_has()
1505+
assert_equal(1, has('eval', true))
1506+
enddef
1507+
15981508
def Test_hasmapto()
15991509
assert_equal(0, hasmapto('foobar', 'i', true))
16001510
iabbrev foo foobar
16011511
assert_equal(1, hasmapto('foobar', 'i', true))
16021512
iunabbrev foo
16031513
enddef
16041514

1515+
def Test_index()
1516+
assert_equal(3, index(['a', 'b', 'a', 'B'], 'b', 2, true))
1517+
enddef
1518+
1519+
def Test_list2str_str2list_utf8()
1520+
let s = "\u3042\u3044"
1521+
let l = [0x3042, 0x3044]
1522+
assert_equal(l, str2list(s, true))
1523+
assert_equal(s, list2str(l, true))
1524+
enddef
1525+
16051526
def SID(): number
16061527
return expand('<SID>')
16071528
->matchstr('<SNR>\zs\d\+\ze_$')
@@ -1634,6 +1555,95 @@ def Test_mapcheck()
16341555
iunabbrev foo
16351556
enddef
16361557

1558+
def Test_nr2char()
1559+
assert_equal('a', nr2char(97, true))
1560+
enddef
1561+
1562+
def Test_readdir()
1563+
eval expand('sautest')->readdir({e -> e[0] !=# '.'})
1564+
eval expand('sautest')->readdirex({e -> e.name[0] !=# '.'})
1565+
enddef
1566+
1567+
def Test_search()
1568+
new
1569+
setline(1, ['foo', 'bar'])
1570+
let val = 0
1571+
# skip expr returns boolean
1572+
assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
1573+
:1
1574+
assert_equal(0, search('bar', 'W', 0, 0, {-> val == 0}))
1575+
# skip expr returns number, only 0 and 1 are accepted
1576+
:1
1577+
assert_equal(2, search('bar', 'W', 0, 0, {-> 0}))
1578+
:1
1579+
assert_equal(0, search('bar', 'W', 0, 0, {-> 1}))
1580+
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
1581+
assert_fails("search('bar', '', 0, 0, {-> -1})", 'E1023:')
1582+
enddef
1583+
1584+
def Test_searchcount()
1585+
new
1586+
setline(1, "foo bar")
1587+
:/foo
1588+
assert_equal(#{
1589+
exact_match: 1,
1590+
current: 1,
1591+
total: 1,
1592+
maxcount: 99,
1593+
incomplete: 0,
1594+
}, searchcount(#{recompute: true}))
1595+
bwipe!
1596+
enddef
1597+
1598+
def Test_searchdecl()
1599+
assert_equal(1, searchdecl('blah', true, true))
1600+
enddef
1601+
1602+
def Test_setbufvar()
1603+
setbufvar(bufnr('%'), '&syntax', 'vim')
1604+
assert_equal('vim', &syntax)
1605+
setbufvar(bufnr('%'), '&ts', 16)
1606+
assert_equal(16, &ts)
1607+
settabwinvar(1, 1, '&syntax', 'vam')
1608+
assert_equal('vam', &syntax)
1609+
settabwinvar(1, 1, '&ts', 15)
1610+
assert_equal(15, &ts)
1611+
setlocal ts=8
1612+
1613+
setbufvar('%', 'myvar', 123)
1614+
assert_equal(123, getbufvar('%', 'myvar'))
1615+
enddef
1616+
1617+
def Test_setreg()
1618+
setreg('a', ['aaa', 'bbb', 'ccc'])
1619+
let reginfo = getreginfo('a')
1620+
setreg('a', reginfo)
1621+
assert_equal(reginfo, getreginfo('a'))
1622+
enddef
1623+
1624+
def Test_synID()
1625+
new
1626+
setline(1, "text")
1627+
assert_equal(0, synID(1, 1, true))
1628+
bwipe!
1629+
enddef
1630+
1631+
def Test_win_splitmove()
1632+
split
1633+
win_splitmove(1, 2, #{vertical: true, rightbelow: true})
1634+
close
1635+
enddef
1636+
1637+
""""""" end of builtin functions
1638+
1639+
def Fibonacci(n: number): number
1640+
if n < 2
1641+
return n
1642+
else
1643+
return Fibonacci(n - 1) + Fibonacci(n - 2)
1644+
endif
1645+
enddef
1646+
16371647
def Test_recursive_call()
16381648
assert_equal(6765, Fibonacci(20))
16391649
enddef

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1617,
757759
/**/
758760
1616,
759761
/**/

0 commit comments

Comments
 (0)