diff --git a/src/grammar/store.ts b/src/grammar/store.ts index fc1f95798..f1c187fe1 100644 --- a/src/grammar/store.ts +++ b/src/grammar/store.ts @@ -42,4 +42,19 @@ export function openContext(ctx: CompilerContext, } ctx = store.set(ctx, 'types', { sources, funcSources, functions, constants, types }); return ctx; -} \ No newline at end of file +} + +// Creates a mock context with the given AST elements needed for testing +// purposes +export function openMockContext( + ctx: CompilerContext, + types: ASTType[], + functions: (ASTNativeFunction|ASTFunction)[], + constants: ASTConstant[], +) { + const sources: {code: string, path: string}[] = []; + const funcSources: {code: string, path: string}[] = []; + ctx = store.set(ctx, 'types', + {sources, funcSources, functions, constants, types}); + return ctx; +}