aboutsummaryrefslogtreecommitdiff
path: root/plugin/test
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 06:02:56 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 06:11:36 +0000
commit9ec4fbddd559d93b3d6b072dc8f56d2a572585bd (patch)
treeac576c0da3b936ca6198b7f84944c76727a89c6b /plugin/test
parente52266d8ce8823866b2dad3e04ffc78438e08397 (diff)
feat(plugin): color bracket pairs and mark unmatched brackets red
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'plugin/test')
-rw-r--r--plugin/test/brackets.test.js31
-rw-r--r--plugin/test/highlighting.test.js1
2 files changed, 32 insertions, 0 deletions
diff --git a/plugin/test/brackets.test.js b/plugin/test/brackets.test.js
new file mode 100644
index 0000000..acb18d0
--- /dev/null
+++ b/plugin/test/brackets.test.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const assert = require('node:assert/strict');
+const { test } = require('node:test');
+const { unmatchedBrackets } = require('../src/brackets');
+
+test('mixed nesting matches across lines and repaired brackets stop being errors', () => {
+ assert.deepEqual(unmatchedBrackets('A[(B + C)\n + D[1]]'), []);
+ assert.deepEqual(unmatchedBrackets('A['), [1]);
+ assert.deepEqual(unmatchedBrackets('A[1]'), []);
+ assert.deepEqual(unmatchedBrackets('(\n)'), []);
+});
+
+test('unpaired opening, closing and crossed bracket types are all reported', () => {
+ assert.deepEqual(unmatchedBrackets('(['), [0, 1]);
+ assert.deepEqual(unmatchedBrackets(')]'), [0, 1]);
+ assert.deepEqual(unmatchedBrackets('([)]'), [0, 1, 2, 3]);
+ assert.deepEqual(unmatchedBrackets('(]'), [0, 1]);
+});
+
+test('comments and quotes are ignored with correct UTF-16 offsets after Unicode and CRLF', () => {
+ assert.deepEqual(unmatchedBrackets('OUTPUT "[( //" // )]\nOUTPUT \'[\''), []);
+ const unfinished = 'OUTPUT "unfinished [\r\nA[';
+ assert.deepEqual(unmatchedBrackets(unfinished), [unfinished.length - 1]);
+ const unicode = 'OUTPUT "你好😀"\r\nA[';
+ assert.deepEqual(unmatchedBrackets(unicode), [unicode.length - 1]);
+ // Backslashes do not escape CIE quotes.
+ assert.deepEqual(unmatchedBrackets('"x\\"['), [4]);
+ const quoteChar = "OUTPUT ''' [";
+ assert.deepEqual(unmatchedBrackets(quoteChar), [quoteChar.length - 1]);
+});
diff --git a/plugin/test/highlighting.test.js b/plugin/test/highlighting.test.js
index df18f6a..89e031a 100644
--- a/plugin/test/highlighting.test.js
+++ b/plugin/test/highlighting.test.js
@@ -58,4 +58,5 @@ test('comments, strings, lowercase and keyword prefixes cannot become keywords',
assert.ok(grammar.tokenizeLine('IF X THEN', state).tokens[0].scopes.includes(
'keyword.control.cie-pseudocode'));
assert.ok(scopesAt('OUTPUT "x\\" + 1', '+').includes('keyword.operator.cie-pseudocode'));
+ assert.ok(scopesAt("OUTPUT ''' + 1", '+').includes('keyword.operator.cie-pseudocode'));
});