diff --git a/test/unit/importAttributeBoundary.test.ts b/test/unit/importAttributeBoundary.test.ts new file mode 100644 index 0000000..9954619 --- /dev/null +++ b/test/unit/importAttributeBoundary.test.ts @@ -0,0 +1,74 @@ +import path from 'node:path'; +import { Edit, Language, Parser } from '@willbooster/web-tree-sitter'; +import { expect, test } from 'vitest'; + +test('preserves import attributes and requires explicit separation before with statements', async () => { + await Parser.init(); + const parser = new Parser().setLanguage( + await Language.load(path.join(import.meta.dirname, '../../tree-sitter-javascript.wasm')) + ); + try { + for (const declaration of ['import { A }', 'import A', 'export { A }', 'export *', 'export * as ns']) { + for (const trivia of [' ', '\n', ' /* c */ ', ' // c\n', ' c\n', ' /* a */