diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-13 06:02:56 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-13 06:11:36 +0000 |
| commit | 9ec4fbddd559d93b3d6b072dc8f56d2a572585bd (patch) | |
| tree | ac576c0da3b936ca6198b7f84944c76727a89c6b /plugin/test/brackets.test.js | |
| parent | e52266d8ce8823866b2dad3e04ffc78438e08397 (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/brackets.test.js')
| -rw-r--r-- | plugin/test/brackets.test.js | 31 |
1 files changed, 31 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]); +}); |
