To: vim_dev@googlegroups.com Subject: Patch 8.2.0028 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0028 Problem: Searchpairpos() is not tested. Solution: Add tests. Also improve searchpair() testing. (Dominique Pelle, closes #5388) Files: src/testdir/test_search.vim *** ../vim-8.2.0027/src/testdir/test_search.vim 2019-11-23 21:36:57.000000000 +0100 --- src/testdir/test_search.vim 2019-12-21 21:56:45.548722712 +0100 *************** *** 57,63 **** call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 ! " eigth match call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 --- 57,63 ---- call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 ! " eighth match call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 *************** *** 99,105 **** call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 ! " eigth match call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 --- 99,105 ---- call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 ! " eighth match call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 *************** *** 290,304 **** func Test_searchpair() new ! call setline(1, ['other code here', '', '[', '" cursor here', ']']) 4 ! let a = searchpair('\[','',']','bW') ! call assert_equal(3, a) set nomagic 4 ! let a = searchpair('\[','',']','bW') ! call assert_equal(3, a) set magic q! endfunc --- 290,373 ---- func Test_searchpair() new ! call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]']) ! ! 4 ! call assert_equal(3, searchpair('\[', '', ']', 'bW')) ! call assert_equal([0, 3, 2, 0], getpos('.')) ! 4 ! call assert_equal(2, searchpair('\[', '', ']', 'bWr')) ! call assert_equal([0, 2, 6, 0], getpos('.')) ! 4 ! call assert_equal(1, searchpair('\[', '', ']', 'bWm')) ! call assert_equal([0, 3, 2, 0], getpos('.')) ! 4|norm ^ ! call assert_equal(5, searchpair('\[', '', ']', 'Wn')) ! call assert_equal([0, 4, 2, 0], getpos('.')) ! 4 ! call assert_equal(2, searchpair('\[', '', ']', 'bW', ! \ 'getline(".") =~ "^\\s*\["')) ! call assert_equal([0, 2, 6, 0], getpos('.')) ! set nomagic ! 4 ! call assert_equal(3, searchpair('\[', '', ']', 'bW')) ! call assert_equal([0, 3, 2, 0], getpos('.')) ! set magic ! 4|norm ^ ! call assert_equal(0, searchpair('{', '', '}', 'bW')) ! call assert_equal([0, 4, 2, 0], getpos('.')) ! ! %d ! call setline(1, ['if 1', ' if 2', ' else', ' endif 2', 'endif 1']) ! ! /\', '\', '\', 'W')) ! call assert_equal([0, 5, 1, 0], getpos('.')) ! /\', '\', '\', 'W')) ! call assert_equal([0, 3, 3, 0], getpos('.')) ! ! q! ! endfunc ! ! func Test_searchpairpos() ! new ! call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]']) ! ! 4 ! call assert_equal([3, 2], searchpairpos('\[', '', ']', 'bW')) ! call assert_equal([0, 3, 2, 0], getpos('.')) 4 ! call assert_equal([2, 6], searchpairpos('\[', '', ']', 'bWr')) ! call assert_equal([0, 2, 6, 0], getpos('.')) ! 4|norm ^ ! call assert_equal([5, 2], searchpairpos('\[', '', ']', 'Wn')) ! call assert_equal([0, 4, 2, 0], getpos('.')) ! 4 ! call assert_equal([2, 6], searchpairpos('\[', '', ']', 'bW', ! \ 'getline(".") =~ "^\\s*\["')) ! call assert_equal([0, 2, 6, 0], getpos('.')) ! 4 ! call assert_equal([2, 6], searchpairpos('\[', '', ']', 'bWr')) ! call assert_equal([0, 2, 6, 0], getpos('.')) set nomagic 4 ! call assert_equal([3, 2], searchpairpos('\[', '', ']', 'bW')) ! call assert_equal([0, 3, 2, 0], getpos('.')) set magic + 4|norm ^ + call assert_equal([0, 0], searchpairpos('{', '', '}', 'bW')) + call assert_equal([0, 4, 2, 0], getpos('.')) + + %d + call setline(1, ['if 1', ' if 2', ' else', ' endif 2', 'endif 1']) + /\', '\', '\', 'W')) + call assert_equal([0, 5, 1, 0], getpos('.')) + /\', '\', '\', 'W')) + call assert_equal([0, 3, 3, 0], getpos('.')) + q! endfunc *************** *** 310,323 **** call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 0, 99, 100)", 'E475: Invalid argument: 0') call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99') call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100') endfunc func Test_searchpair_skip() func Zero() ! return 0 endfunc func Partial(x) ! return a:x endfunc new call setline(1, ['{', 'foo', 'foo', 'foo', '}']) --- 379,406 ---- call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 0, 99, 100)", 'E475: Invalid argument: 0') call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99') call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100') + call assert_fails("call searchpair('start', 'middle', 'end', 'e')", 'E475: Invalid argument: e') + call assert_fails("call searchpair('start', 'middle', 'end', 'sn')", 'E475: Invalid argument: sn') + endfunc + + func Test_searchpairpos_errors() + call assert_fails("call searchpairpos([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: using List as a String') + call assert_fails("call searchpairpos('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: using Funcref as a String') + call assert_fails("call searchpairpos('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: using Dictionary as a String') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'flags', 'skip', 99, 100)", 'E475: Invalid argument: flags') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'bW', 0, 99, 100)", 'E475: Invalid argument: 0') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'e')", 'E475: Invalid argument: e') + call assert_fails("call searchpairpos('start', 'middle', 'end', 'sn')", 'E475: Invalid argument: sn') endfunc func Test_searchpair_skip() func Zero() ! return 0 endfunc func Partial(x) ! return a:x endfunc new call setline(1, ['{', 'foo', 'foo', 'foo', '}']) *************** *** 1184,1190 **** " This was causing E874. Also causes an invalid read? func Test_look_behind() new ! call setline(1, '0\|\&\n\@<=') call search(getline(".")) bwipe! endfunc --- 1267,1273 ---- " This was causing E874. Also causes an invalid read? func Test_look_behind() new ! call setline(1, '0\|\&\n\@<=') call search(getline(".")) bwipe! endfunc *************** *** 1213,1223 **** func Test_search_Ctrl_L_combining() " Make sure, that Ctrl-L works correctly with combining characters. " It uses an artificial example of an 'a' with 4 combining chars: ! " 'a' U+0061 Dec:97 LATIN SMALL LETTER A a /\%u61\Z "\u0061" " ' ̀' U+0300 Dec:768 COMBINING GRAVE ACCENT ̀ /\%u300\Z "\u0300" " ' ́' U+0301 Dec:769 COMBINING ACUTE ACCENT ́ /\%u301\Z "\u0301" " ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE ̇ /\%u307\Z "\u0307" ! " ' ̣' U+0323 Dec:803 COMBINING DOT BELOW ̣ /\%u323 "\u0323" " Those should also appear on the commandline if !exists('+incsearch') return --- 1296,1306 ---- func Test_search_Ctrl_L_combining() " Make sure, that Ctrl-L works correctly with combining characters. " It uses an artificial example of an 'a' with 4 combining chars: ! " 'a' U+0061 Dec:97 LATIN SMALL LETTER A a /\%u61\Z "\u0061" " ' ̀' U+0300 Dec:768 COMBINING GRAVE ACCENT ̀ /\%u300\Z "\u0300" " ' ́' U+0301 Dec:769 COMBINING ACUTE ACCENT ́ /\%u301\Z "\u0301" " ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE ̇ /\%u307\Z "\u0307" ! " ' ̣' U+0323 Dec:803 COMBINING DOT BELOW ̣ /\%u323 "\u0323" " Those should also appear on the commandline if !exists('+incsearch') return *** ../vim-8.2.0027/src/version.c 2019-12-21 18:47:05.128754192 +0100 --- src/version.c 2019-12-21 21:57:55.728562955 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 28, /**/ -- What the word 'politics' means: 'Poli' in Latin meaning 'many' and 'tics' meaning 'bloodsucking creatures'. /// 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 ///