feat: added syntax check

This commit is contained in:
2026-02-23 21:38:12 +01:00
parent e68e845e70
commit 7cc2f7cab2
14 changed files with 507 additions and 10 deletions

View File

@@ -134,6 +134,47 @@ describe('PythonRuntimeManager', () => {
await expect(inspectPromise).resolves.toEqual(['render', 'helper']);
});
it('checks syntax and returns structured syntax errors', async () => {
const worker = new MockWorker();
const manager = new PythonRuntimeManager(() => worker as unknown as Worker);
const initPromise = manager.initialize();
worker.emitMessage({ type: 'ready' });
await initPromise;
const syntaxPromise = manager.syntaxCheck('def broken(:\n pass');
await Promise.resolve();
const request = worker.postedMessages[0] as { type: string; requestId: string; code: string };
expect(request.type).toBe('syntaxCheck');
worker.emitMessage({
type: 'syntaxResult',
requestId: request.requestId,
errors: [
{
line: 1,
column: 11,
endLine: 1,
endColumn: 12,
message: 'invalid syntax',
},
],
});
await expect(syntaxPromise).resolves.toEqual({
errors: [
{
line: 1,
column: 11,
endLine: 1,
endColumn: 12,
message: 'invalid syntax',
},
],
});
});
it('rejects when runtime returns run error', async () => {
const worker = new MockWorker();
const manager = new PythonRuntimeManager(() => worker as unknown as Worker);