aboutsummaryrefslogtreecommitdiff
path: root/plugin/test
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-14 02:52:07 +0000
committer_ov4 <ov4@ov4.org>2026-10-14 02:52:07 +0000
commitd5851e995363e6f637a5f35cafe3ddaf8934705a (patch)
treed3d2b1b5474ca3c33e3025420152f7384572e977 /plugin/test
parent0e83581ed907aee1f6e59524c7d28b6f9c016f8e (diff)
feat(plugin): highlight exception keywords with C++ scopes
Reuse C++ try, catch and throw scopes for exception keywords, with ENDTRY sharing the TRY scope. Add an example and verify keyword boundaries, case sensitivity, comments and strings with TextMate tokenization. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'plugin/test')
-rw-r--r--plugin/test/highlighting.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugin/test/highlighting.test.js b/plugin/test/highlighting.test.js
index 24751bf..0f677a3 100644
--- a/plugin/test/highlighting.test.js
+++ b/plugin/test/highlighting.test.js
@@ -53,6 +53,22 @@ test('both assignment characters share the C++ assignment scope', () => {
assert.ok(!scopesAt('X - 1', '-').includes('keyword.operator.assignment.cpp'));
});
+test('exception keywords reuse C++ scopes and ignore non-keyword occurrences', () => {
+ for (const [word, scope] of [
+ ['TRY', 'keyword.control.try.cpp'],
+ ['CATCH', 'keyword.control.catch.cpp'],
+ ['THROW', 'keyword.control.throw.cpp'],
+ ['ENDTRY', 'keyword.control.try.cpp']
+ ]) {
+ assert.ok(scopesAt(word, word).includes(scope));
+ assert.ok(scopesAt(`// ${word}`, word).some(s => s.startsWith('comment.')));
+ assert.ok(scopesAt(`OUTPUT "${word}"`, word).some(s => s.startsWith('string.')));
+ for (const text of [word.toLowerCase(), `${word}Value`, `My${word}`, `${word}_1`]) {
+ assert.ok(!scopesAt(text, text).some(s => s.startsWith('keyword.')), text);
+ }
+ }
+});
+
test('comments, strings, lowercase and keyword prefixes cannot become keywords', () => {
assert.ok(scopesAt('// IF [(', 'IF').some(s => s.startsWith('comment.')));
assert.ok(scopesAt('OUTPUT "IF // ["', 'IF').some(s => s.startsWith('string.')));