To: vim_dev@googlegroups.com Subject: Patch 8.2.1617 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1617 Problem: Vim9: cannot pass "true" to win_splitmove(). Solution: Use dict_get_bool(). (closes #6862) Alphabetize test functions. Files: src/evalwindow.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.1616/src/evalwindow.c 2020-09-03 18:52:20.223638410 +0200 --- src/evalwindow.c 2020-09-05 21:55:28.585397205 +0200 *************** *** 832,841 **** } d = argvars[2].vval.v_dict; ! if (dict_get_number(d, (char_u *)"vertical")) flags |= WSP_VERT; if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL) ! flags |= tv_get_number(&di->di_tv) ? WSP_BELOW : WSP_ABOVE; size = (int)dict_get_number(d, (char_u *)"size"); } --- 832,841 ---- } d = argvars[2].vval.v_dict; ! 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_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE; size = (int)dict_get_number(d, (char_u *)"size"); } *** ../vim-8.2.1616/src/testdir/test_vim9_func.vim 2020-09-05 21:41:53.127168164 +0200 --- src/testdir/test_vim9_func.vim 2020-09-05 21:54:06.389577849 +0200 *************** *** 1408,1448 **** 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 ! ! 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')) enddef def Test_bufwinid() --- 1408,1421 ---- call delete('XTest_silent_echo') endfunc ! """"""" builtin functions that behave differently in Vim9 ! def Test_bufname() ! split SomeFile ! assert_equal('SomeFile', bufname('%')) ! edit OtherFile ! assert_equal('SomeFile', bufname('#')) ! close enddef def Test_bufwinid() *************** *** 1459,1464 **** --- 1432,1460 ---- 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,1510 **** 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 --- 1474,1479 ---- *************** *** 1518,1586 **** 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) --- 1487,1492 ---- *************** *** 1595,1600 **** --- 1501,1510 ---- 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,1607 **** --- 1512,1528 ---- 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('') ->matchstr('\zs\d\+\ze_$') *************** *** 1634,1639 **** --- 1555,1649 ---- 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 *** ../vim-8.2.1616/src/version.c 2020-09-05 21:41:53.127168164 +0200 --- src/version.c 2020-09-05 21:44:58.414771888 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1617, /**/ -- If your life is a hard drive, Christ can be your backup. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///