-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update syntax highlighting for exception scriptlet rules. #132 AG-31622
Squashed commit of the following: commit 316513f Author: scripthunter7 <[email protected]> Date: Tue Apr 2 19:08:31 2024 +0200 small improvements commit bc76fc7 Author: Slava Leleka <[email protected]> Date: Tue Apr 2 20:03:24 2024 +0300 update changelog commit f6bed55 Merge: 963e15d 32bd831 Author: Slava Leleka <[email protected]> Date: Tue Apr 2 18:31:07 2024 +0300 Merge branch 'fix/AG-31622' of ssh://bit.int.agrd.dev:7999/adguard-filters/vscode-adblock-syntax into fix/AG-31622 commit 963e15d Author: Slava Leleka <[email protected]> Date: Tue Apr 2 18:27:32 2024 +0300 fix linter commit 32bd831 Author: scripthunter7 <[email protected]> Date: Tue Apr 2 17:27:06 2024 +0200 fix linter commit af7f0a6 Author: Slava Leleka <[email protected]> Date: Tue Apr 2 18:20:20 2024 +0300 update changelog commit aee8fe9 Author: Slava Leleka <[email protected]> Date: Tue Apr 2 18:15:01 2024 +0300 add tests commit 31e2e88 Author: Slava Leleka <[email protected]> Date: Tue Apr 2 18:10:31 2024 +0300 fix scriptlet match commit 4514d5a Author: Slava Leleka <[email protected]> Date: Tue Apr 2 17:55:14 2024 +0300 update vscode-oniguruma commit 2a6e823 Author: scripthunter7 <[email protected]> Date: Tue Apr 2 15:58:59 2024 +0200 update test rules commit 4cdb98a Author: scripthunter7 <[email protected]> Date: Tue Apr 2 15:58:45 2024 +0200 update syntax highlighting Co-authored-by: Slava <[email protected]>
- Loading branch information
1 parent
b4a53be
commit d67bcc2
Showing
7 changed files
with
193 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/** | ||
* @file Tests for scriptlets rules | ||
*/ | ||
|
||
import { type AdblockTokenizer, getAdblockTokenizer } from '../common/get-adblock-tokenizer'; | ||
import { expectTokens } from '../common/token-expectation'; | ||
|
||
let tokenize: AdblockTokenizer; | ||
|
||
// Before running any tests, we should load the grammar and get the tokenizer | ||
beforeAll(async () => { | ||
tokenize = await getAdblockTokenizer(); | ||
}); | ||
|
||
describe('scriptlet rules', () => { | ||
describe('valid', () => { | ||
test('blocking', () => { | ||
// single quoted arguments | ||
expectTokens( | ||
tokenize, | ||
"#%#//scriptlet('foo', 'bar')", | ||
[ | ||
{ fragment: '#%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: "'foo'", scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ', ', scopes: ['text.adblock', 'keyword.operator.adblock'] }, | ||
{ fragment: "'bar'", scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
|
||
// double quoted arguments | ||
expectTokens( | ||
tokenize, | ||
'#%#//scriptlet("foo", "bar")', | ||
[ | ||
{ fragment: '#%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: '"foo"', scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ', ', scopes: ['text.adblock', 'keyword.operator.adblock'] }, | ||
{ fragment: '"bar"', scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
|
||
// should handle if the argument contain a different quote type | ||
expectTokens( | ||
tokenize, | ||
'#%#//scriptlet("foo\'bar")', | ||
[ | ||
{ fragment: '#%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: '"foo\'bar"', scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
}); | ||
|
||
test('exception for specific scriptlet', () => { | ||
expectTokens( | ||
tokenize, | ||
"#@%#//scriptlet('foo')", | ||
[ | ||
{ fragment: '#@%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: "'foo'", scopes: ['text.adblock', 'string.quoted.adblock'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
}); | ||
|
||
test('exception for all scriptlets', () => { | ||
expectTokens( | ||
tokenize, | ||
'#@%#//scriptlet()', | ||
[ | ||
{ fragment: '#@%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
|
||
expectTokens( | ||
tokenize, | ||
'#@%#//scriptlet( )', | ||
[ | ||
{ fragment: '#@%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet', scopes: ['text.adblock', 'entity.name.function.adblock'] }, | ||
{ fragment: '(', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
{ fragment: ' ', scopes: ['text.adblock', 'entity.name.section.adblock.empty-scriptlet'] }, | ||
{ fragment: ')', scopes: ['text.adblock', 'punctuation.section.adblock'] }, | ||
], | ||
); | ||
}); | ||
}); | ||
|
||
describe('invalid', () => { | ||
test('blocking', () => { | ||
expectTokens( | ||
tokenize, | ||
// blocking scriptlet rule cannot be used without any arguments | ||
'#%#//scriptlet()', | ||
[ | ||
{ fragment: '#%#', scopes: ['text.adblock', 'keyword.control.adblock'] }, | ||
{ fragment: '//scriptlet()', scopes: ['text.adblock', 'invalid.illegal'] }, | ||
], | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters