To: vim_dev@googlegroups.com Subject: Patch 8.2.0606 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0606 Problem: Several syntax HL errors not checked. Solution: Add tests. (Yegappan Lakshmanan, closes #5954) Files: src/testdir/test_syntax.vim *** ../vim-8.2.0605/src/testdir/test_syntax.vim 2020-04-08 19:48:53.551732882 +0200 --- src/testdir/test_syntax.vim 2020-04-19 18:30:08.959623763 +0200 *************** *** 320,325 **** --- 320,337 ---- syn clear endfunc + " Check for an error. Used when multiple errors are thrown and we are checking + " for an earliest error. + func AssertFails(cmd, errcode) + let save_exception = '' + try + exe a:cmd + catch + let save_exception = v:exception + endtry + call assert_match(a:errcode, save_exception) + endfunc + func Test_syntax_invalid_arg() call assert_fails('syntax case asdf', 'E390:') if has('conceal') *************** *** 327,395 **** endif call assert_fails('syntax spell asdf', 'E390:') call assert_fails('syntax clear @ABCD', 'E391:') ! call assert_fails('syntax include @Xxx', 'E397:') ! call assert_fails('syntax region X start="{"', 'E399:') call assert_fails('syntax sync x', 'E404:') call assert_fails('syntax keyword Abc a[', 'E789:') call assert_fails('syntax keyword Abc a[bc]d', 'E890:') ! ! let caught_393 = 0 ! try ! syntax keyword cMyItem grouphere G1 ! catch /E393:/ ! let caught_393 = 1 ! endtry ! call assert_equal(1, caught_393) ! ! let caught_394 = 0 ! try ! syntax sync match Abc grouphere MyItem "abc"' ! catch /E394:/ ! let caught_394 = 1 ! endtry ! call assert_equal(1, caught_394) " Test for too many \z\( and unmatched \z\( " Not able to use assert_fails() here because both E50:/E879: and E475: " messages are emitted. set regexpengine=1 ! let caught_52 = 0 ! try ! syntax region MyRegion start='\z\(' end='\*/' ! catch /E52:/ ! let caught_52 = 1 ! endtry ! call assert_equal(1, caught_52) ! let caught_50 = 0 ! try ! let cmd = "syntax region MyRegion start='" ! let cmd ..= repeat("\\z\\(.\\)", 10) .. "' end='\*/'" ! exe cmd ! catch /E50:/ ! let caught_50 = 1 ! endtry ! call assert_equal(1, caught_50) set regexpengine=2 ! let caught_54 = 0 ! try ! syntax region MyRegion start='\z\(' end='\*/' ! catch /E54:/ ! let caught_54 = 1 ! endtry ! call assert_equal(1, caught_54) ! let caught_879 = 0 ! try ! let cmd = "syntax region MyRegion start='" ! let cmd ..= repeat("\\z\\(.\\)", 10) .. "' end='\*/'" ! exe cmd ! catch /E879:/ ! let caught_879 = 1 ! endtry ! call assert_equal(1, caught_879) set regexpengine& endfunc func Test_syn_sync() --- 339,387 ---- endif call assert_fails('syntax spell asdf', 'E390:') call assert_fails('syntax clear @ABCD', 'E391:') ! call assert_fails('syntax include random_file', 'E484:') ! call assert_fails('syntax include ', 'E495:') call assert_fails('syntax sync x', 'E404:') call assert_fails('syntax keyword Abc a[', 'E789:') call assert_fails('syntax keyword Abc a[bc]d', 'E890:') ! call assert_fails('syntax cluster Abc add=A add=', 'E475:') " Test for too many \z\( and unmatched \z\( " Not able to use assert_fails() here because both E50:/E879: and E475: " messages are emitted. set regexpengine=1 ! call AssertFails("syntax region MyRegion start='\\z\\(' end='\\*/'", 'E52:') ! let cmd = "syntax region MyRegion start='" ! let cmd ..= repeat("\\z\\(.\\)", 10) .. "' end='\*/'" ! call AssertFails(cmd, 'E50:') set regexpengine=2 ! call AssertFails("syntax region MyRegion start='\\z\\(' end='\\*/'", 'E54:') ! let cmd = "syntax region MyRegion start='" ! let cmd ..= repeat("\\z\\(.\\)", 10) .. "' end='\*/'" ! call AssertFails(cmd, 'E879:') set regexpengine& + + call AssertFails('syntax keyword cMyItem grouphere G1', 'E393:') + call AssertFails('syntax sync match Abc grouphere MyItem "abc"', 'E394:') + call AssertFails('syn keyword Type contains int', 'E395:') + call assert_fails('syntax include @Xxx', 'E397:') + call AssertFails('syntax region X start', 'E398:') + call assert_fails('syntax region X start="{"', 'E399:') + call AssertFails('syntax cluster contains=Abc', 'E400:') + call AssertFails("syntax match Character /'.'", 'E401:') + call AssertFails("syntax match Character /'.'/a", 'E402:') + call assert_fails('syntax sync linecont /pat', 'E404:') + call assert_fails('syntax sync linecont', 'E404:') + call assert_fails('syntax sync linecont /pat1/ linecont /pat2/', 'E403:') + call assert_fails('syntax sync minlines=a', 'E404:') + call AssertFails('syntax match ABC /x/ contains=', 'E406:') + call AssertFails("syntax match Character contains /'.'/", 'E405:') + call AssertFails('syntax match ccFoo "Foo" nextgroup=ALLBUT,F', 'E407:') + call AssertFails('syntax region Block start="{" contains=F,ALLBUT', 'E408:') + call AssertFails("syntax match Characters contains=a.*x /'.'/", 'E409:') endfunc func Test_syn_sync() *************** *** 417,422 **** --- 409,415 ---- hi clear Foo call assert_equal('Foo', synIDattr(hlID("Foo"), "name")) hi clear Bar + call assert_fails('syntax clear invalid_syngroup', 'E28:') endfunc func Test_invalid_name() *************** *** 565,570 **** --- 558,565 ---- call assert_match('16 ', ScreenLines(2, 7)[0]) call assert_equal([[0, '', 0], [1, '', 1], [1, '', 1], [1, '', 2], [1, '', 2], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)')) + call AssertFails("syntax match Entity '&' conceal cchar=\", 'E844:') + syn clear set conceallevel& bw! *** ../vim-8.2.0605/src/version.c 2020-04-19 18:27:20.791953204 +0200 --- src/version.c 2020-04-19 18:30:58.619589038 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 606, /**/ -- Git catch 22: "merge is not possible because you have unmerged files." /// 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 ///