summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-19 18:31:25 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-19 18:31:25 +0200
commitfbf2122cf920a89274ffbefaaeb6c5eeacf5187b (patch)
treea3df590436a02b010d7a7f45cd443415796a7d1f
parent7bdaea6e0df849cf3dd7eaaf454eb88f637d1884 (diff)
patch 8.2.0606: several syntax HL errors not checkedv8.2.0606
Problem: Several syntax HL errors not checked. Solution: Add tests. (Yegappan Lakshmanan, closes #5954)
-rw-r--r--src/testdir/test_syntax.vim95
-rw-r--r--src/version.c2
2 files changed, 47 insertions, 50 deletions
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index c7fefa95b1..50e1a59b3c 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -320,6 +320,18 @@ func Test_syntax_arg_skipped()
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,69 +339,49 @@ func Test_syntax_invalid_arg()
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 include random_file', 'E484:')
+ call assert_fails('syntax include <afile>', '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:')
-
- 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)
+ 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
- let caught_52 = 0
- try
- syntax region MyRegion start='\z\(' end='\*/'
- catch /E52:/
- let caught_52 = 1
- endtry
- call assert_equal(1, caught_52)
+ call AssertFails("syntax region MyRegion start='\\z\\(' end='\\*/'", 'E52:')
- 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)
+ let cmd = "syntax region MyRegion start='"
+ let cmd ..= repeat("\\z\\(.\\)", 10) .. "' end='\*/'"
+ call AssertFails(cmd, 'E50:')
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)
+ call AssertFails("syntax region MyRegion start='\\z\\(' end='\\*/'", 'E54:')
- 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)
+ 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,6 +409,7 @@ func Test_syn_clear()
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,6 +558,8 @@ func Test_conceal()
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 '&amp;' conceal cchar=\<Tab>", 'E844:')
+
syn clear
set conceallevel&
bw!
diff --git a/src/version.c b/src/version.c
index 7af2e50e5a..b95c7eeab8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 606,
+/**/
605,
/**/
604,