diff options
Diffstat (limited to 'plugin/test')
| -rw-r--r-- | plugin/test/highlighting.test.js | 16 |
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.'))); |
