feat: free memory automatically (#5225)
This commit is contained in:
parent
b12009a746
commit
cd603fa981
9 changed files with 163 additions and 0 deletions
25
lib/binding_web/test/memory_unsupported.test.ts
Normal file
25
lib/binding_web/test/memory_unsupported.test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { describe, it } from 'vitest';
|
||||
|
||||
describe('FinalizationRegistry is unsupported', () => {
|
||||
it('test FinalizationRegistry is unsupported', async () => {
|
||||
// @ts-expect-error: test FinalizationRegistry is not supported
|
||||
globalThis.FinalizationRegistry = undefined;
|
||||
const { JavaScript } = await (await import('./helper')).default;
|
||||
const { Parser, Query } = await import('../src');
|
||||
const parser = new Parser();
|
||||
parser.setLanguage(JavaScript);
|
||||
const tree = parser.parse('1+1')!;
|
||||
const copyTree = tree.copy();
|
||||
const cursor = tree.walk();
|
||||
const copyCursor = cursor.copy();
|
||||
const lookaheadIterator = JavaScript.lookaheadIterator(cursor.currentNode.nextParseState)!;
|
||||
const query = new Query(JavaScript, '(identifier) @element');
|
||||
parser.delete();
|
||||
tree.delete();
|
||||
copyTree.delete();
|
||||
cursor.delete();
|
||||
copyCursor.delete();
|
||||
lookaheadIterator.delete();
|
||||
query.delete();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue