@@ -140,5 +140,90 @@ describe('Preprocessor directive comments', () => {
140140 } ) ;
141141 } ) ;
142142
143- // TODO: add tests for !#include, !#safari_cb_affinity and for unknown preprocessor directives
143+ describe ( '!#safari_cb_affinity' , ( ) => {
144+ test . each ( [
145+ {
146+ actual : '!#safari_cb_affinity(general)' ,
147+ expected : [
148+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
149+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
150+ { fragment : 'general' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
151+ { fragment : ')' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
152+ ] ,
153+ } ,
154+ {
155+ actual : '!#safari_cb_affinity(general,privacy)' ,
156+ expected : [
157+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
158+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
159+ { fragment : 'general' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
160+ { fragment : ',' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
161+ { fragment : 'privacy' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
162+ { fragment : ')' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
163+ ] ,
164+ } ,
165+ {
166+ actual : '!#safari_cb_affinity(all)' ,
167+ expected : [
168+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
169+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
170+ { fragment : 'all' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
171+ { fragment : ')' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
172+ ] ,
173+ } ,
174+ {
175+ actual : '!#safari_cb_affinity(advanced)' ,
176+ expected : [
177+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
178+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
179+ { fragment : 'advanced' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
180+ { fragment : ')' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
181+ ] ,
182+ } ,
183+ {
184+ actual : '!#safari_cb_affinity(privacy,advanced)' ,
185+ expected : [
186+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
187+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
188+ { fragment : 'privacy' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
189+ { fragment : ',' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
190+ { fragment : 'advanced' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
191+ { fragment : ')' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
192+ ] ,
193+ } ,
194+ ] ) ( "valid: '$actual'" , ( { actual, expected } ) => {
195+ expectTokens ( tokenize , actual , expected ) ;
196+ } ) ;
197+
198+ test . each ( [
199+ {
200+ actual : '!#safari_cb_affinity all' ,
201+ expected : [
202+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
203+ { fragment : ' all' , scopes : [ BASE_SCOPE , 'invalid.illegal' ] } ,
204+ ] ,
205+ } ,
206+ {
207+ actual : '!#safari_cb_affinity (all)' ,
208+ expected : [
209+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
210+ { fragment : ' (all)' , scopes : [ BASE_SCOPE , 'invalid.illegal' ] } ,
211+ ] ,
212+ } ,
213+ {
214+ actual : '!#safari_cb_affinity(social, other)' ,
215+ expected : [
216+ { fragment : '!#safari_cb_affinity' , scopes : [ BASE_SCOPE , 'keyword.preprocessor.directive' ] } ,
217+ { fragment : '(' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
218+ { fragment : 'social' , scopes : [ BASE_SCOPE , 'constant.language.contentblocker.name' ] } ,
219+ { fragment : ',' , scopes : [ BASE_SCOPE , 'keyword.control.characters' ] } ,
220+ { fragment : ' other)' , scopes : [ BASE_SCOPE , 'invalid.illegal' ] } ,
221+ ] ,
222+ } ,
223+ ] ) ( "invalid case '$actual'" , ( { actual, expected } ) => {
224+ expectTokens ( tokenize , actual , expected ) ;
225+ } ) ;
226+ } ) ;
227+
228+ // TODO: add tests for !#include and for other unknown preprocessor directives
144229} ) ;
0 commit comments