comparison src/testdir/test_syntax.vim @ 10476:751851a84c41 v8.0.0131

commit https://github.com/vim/vim/commit/73b484c4da00011317dc68ada4f5dfc6515ad263 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 11 15:11:17 2016 +0100 patch 8.0.0131 Problem: Not enough test coverage for syntax commands. Solution: Add more tests. (Dominique Pelle)
author Christian Brabandt <cb@256bit.org>
date Sun, 11 Dec 2016 15:15:04 +0100
parents da4f6e238374
children ea1beefcd664
comparison
equal deleted inserted replaced
10475:2eeefa20f13c 10476:751851a84c41
52 call assert_equal("\nsyntax iskeyword @,48-57,_,192-255", @c) 52 call assert_equal("\nsyntax iskeyword @,48-57,_,192-255", @c)
53 53
54 setlocal isk-=_ 54 setlocal isk-=_
55 call assert_equal('DLTD_BY', GetSyntaxItem('DLTD')) 55 call assert_equal('DLTD_BY', GetSyntaxItem('DLTD'))
56 /\<D\k\+\>/:norm! ygn 56 /\<D\k\+\>/:norm! ygn
57 let b2=@0 57 let b2 = @0
58 call assert_equal('DLTD', @0) 58 call assert_equal('DLTD', @0)
59 59
60 syn iskeyword clear 60 syn iskeyword clear
61 redir @c 61 redir @c
62 syn iskeyword 62 syn iskeyword
78 buf Xsomefile 78 buf Xsomefile
79 call assert_equal('hello', &filetype) 79 call assert_equal('hello', &filetype)
80 call assert_true(exists('g:gotit')) 80 call assert_true(exists('g:gotit'))
81 call delete('Xsomefile') 81 call delete('Xsomefile')
82 endfunc 82 endfunc
83
84 func Test_syntime()
85 if !has('profile')
86 finish
87 endif
88
89 syntax on
90 syntime on
91 let a = execute('syntime report')
92 call assert_equal("\nNo Syntax items defined for this buffer", a)
93
94 view ../memfile_test.c
95 setfiletype cpp
96 redraw
97 let a = execute('syntime report')
98 call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a)
99 call assert_match(' \d*\.\d* \+[^0]\d* .* cppRawString ', a)
100 call assert_match(' \d*\.\d* \+[^0]\d* .* cppNumber ', a)
101
102 syntime off
103 syntime clear
104 let a = execute('syntime report')
105 call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a)
106 call assert_notmatch('.* cppRawString *', a)
107 call assert_notmatch('.* cppNumber*', a)
108 call assert_notmatch('[1-9]', a)
109
110 call assert_fails('syntime abc', 'E475')
111
112 syntax clear
113 let a = execute('syntime report')
114 call assert_equal("\nNo Syntax items defined for this buffer", a)
115
116 bd
117 endfunc
118
119 func Test_syntax_list()
120 syntax on
121 let a = execute('syntax list')
122 call assert_equal("\nNo Syntax items defined for this buffer", a)
123
124 view ../memfile_test.c
125 setfiletype c
126
127 let a = execute('syntax list')
128 call assert_match('cInclude*', a)
129 call assert_match('cDefine', a)
130
131 let a = execute('syntax list cDefine')
132 call assert_notmatch('cInclude*', a)
133 call assert_match('cDefine', a)
134 call assert_match(' links to Macro$', a)
135
136 call assert_fails('syntax list ABCD', 'E28:')
137 call assert_fails('syntax list @ABCD', 'E392:')
138
139 syntax clear
140 let a = execute('syntax list')
141 call assert_equal("\nNo Syntax items defined for this buffer", a)
142
143 bd
144 endfunc
145
146 func Test_syntax_completion()
147 call feedkeys(":syn \<C-A>\<C-B>\"\<CR>", 'tx')
148 call assert_equal('"syn case clear cluster conceal enable include iskeyword keyword list manual match off on region reset spell sync', @:)
149
150 call feedkeys(":syn case \<C-A>\<C-B>\"\<CR>", 'tx')
151 call assert_equal('"syn case ignore match', @:)
152
153 call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
154 call assert_match('^"syn list Boolean Character ', @:)
155
156 call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
157 call assert_match('^"syn match Boolean Character ', @:)
158 endfunc